Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix(examples/trails/sklearn)-fix the incorrect input name for run fun… #1751

Merged
merged 2 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/trials/sklearn/classification/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import logging
import numpy as np


LOG = logging.getLogger('sklearn_classification')

def load_data():
'''Load dataset, use 20newsgroups dataset'''
digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, random_state=99, test_size=0.25)
X_train, X_test, y_train, y_test = train_test_split(
digits.data, digits.target, random_state=99, test_size=0.25)

ss = StandardScaler()
X_train = ss.fit_transform(X_train)
Expand Down Expand Up @@ -59,7 +59,7 @@ def get_model(PARAMS):

return model

def run(X_train, X_test, y_train, y_test, PARAMS):
def run(X_train, X_test, y_train, y_test, model):
'''Train model and predict result'''
model.fit(X_train, y_train)
score = model.score(X_test, y_test)
Expand Down
14 changes: 6 additions & 8 deletions examples/trials/sklearn/regression/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@
def load_data():
'''Load dataset, use boston dataset'''
boston = load_boston()
X_train, X_test, y_train, y_test = train_test_split(boston.data, boston.target, random_state=99, test_size=0.25)
X_train, X_test, y_train, y_test = train_test_split(
boston.data, boston.target, random_state=99, test_size=0.25)
#normalize data
ss_X = StandardScaler()
ss_y = StandardScaler()

X_train = ss_X.fit_transform(X_train)
X_test = ss_X.transform(X_test)
y_train = ss_y.fit_transform(y_train[:, None])[:,0]
y_test = ss_y.transform(y_test[:, None])[:,0]
y_train = ss_y.fit_transform(y_train[:, None])[:, 0]
y_test = ss_y.transform(y_test[:, None])[:, 0]

return X_train, X_test, y_train, y_test

def get_default_parameters():
'''get default parameters'''
params = {
'model_name': 'LinearRegression'
}
params = {'model_name': 'LinearRegression'}
return params

def get_model(PARAMS):
Expand All @@ -76,8 +75,7 @@ def get_model(PARAMS):
raise
return model


def run(X_train, X_test, y_train, y_test, PARAMS):
def run(X_train, X_test, y_train, y_test, model):
'''Train model and predict result'''
model.fit(X_train, y_train)
predict_y = model.predict(X_test)
Expand Down