Skip to content

Commit

Permalink
Merge pull request #28 from lacava/revert-26-standard_scaler
Browse files Browse the repository at this point in the history
Revert "standard scaler pipeline"
  • Loading branch information
lacava committed Jul 7, 2017
2 parents aa214bb + 3b60381 commit 81b2221
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions few/few.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
from sklearn.tree import export_graphviz
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
from sklearn.pipeline import Pipeline
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score, accuracy_score
from sklearn.preprocessing import Imputer, StandardScaler
from sklearn.preprocessing import Imputer
from sklearn.utils import check_random_state
from DistanceClassifier import DistanceClassifier
import numpy as np
Expand Down Expand Up @@ -106,8 +105,8 @@ def __init__(self, population_size=50, generations=100,
self.boolean = boolean
self.classification = classification
self.clean = clean
self.ml = Pipeline([('standardScaler',StandardScaler()), ('ml', ml)])
self.ml_type = type(self.ml.named_steps['ml']).__name__
self.ml = ml
self.ml_type = type(self.ml).__name__
self.track_diversity = track_diversity
self.mdr = mdr
self.otype = otype
Expand All @@ -117,13 +116,11 @@ def __init__(self, population_size=50, generations=100,
self.boolean = True

# instantiate sklearn estimator according to specified machine learner
if self.ml.named_steps['ml'] is None:
if self.ml is None:
if self.classification:
self.ml = Pipeline([('standardScaler',StandardScaler()), ('ml', LogisticRegression(solver='sag'))])
self.ml_type = type(self.ml.named_steps['ml']).__name__
self.ml = LogisticRegression(solver='sag')
else:
self.ml = Pipeline([('standardScaler',StandardScaler()), ('ml', LassoLarsCV())])
self.ml_type = type(self.ml.named_steps['ml']).__name__
self.ml = LassoLarsCV()
if not self.scoring_function:
if self.classification:
self.scoring_function = accuracy_score
Expand All @@ -149,7 +146,7 @@ def __init__(self, population_size=50, generations=100,
type(DecisionTreeClassifier()): 'r2',
type(DistanceClassifier()): 'silhouette',
type(KNeighborsClassifier()): 'r2',
}[type(self.ml.named_steps['ml'])]
}[type(self.ml)]


# Columns to always ignore when in an operator
Expand Down Expand Up @@ -509,7 +506,7 @@ def export(self, output_file_name):
with open(output_file_name, 'w') as output_file:
output_file.write(self.print_model())
# if decision tree, print tree into dot file
if 'DecisionTree' in self.ml_type:
if 'DecisionTree' in type(self.ml).__name__:
export_graphviz(self._best_estimator,
out_file=output_file_name+'.dot',
feature_names = self.stacks_2_eqns(self._best_inds)
Expand Down

0 comments on commit 81b2221

Please sign in to comment.