Skip to content

Commit

Permalink
Revert to scikit-learn 0.19.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
PGijsbers committed Jan 10, 2019
1 parent 5f9e257 commit 408b414
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions gama/gama.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import arff
import pandas as pd
import numpy as np
from sklearn.preprocessing import OneHotEncoder
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import OneHotEncoder, Imputer

import gama.genetic_programming.compilers.scikitlearn
from gama.genetic_programming.algorithms.metrics import Metric
Expand Down Expand Up @@ -345,7 +344,7 @@ def _preprocess_numpy(self, X, y):
# This helps us use a wider variety of algorithms without constructing a grammar.
# One should note that ideally imputation should not always be done since some methods work well without.
# Secondly, the way imputation is done can also be dependent on the task. Median is generally not the best.
self._imputer = SimpleImputer(strategy="median")
self._imputer = Imputer(strategy="median")
self._imputer.fit(X)
if np.isnan(X).any():
log.info("Feature matrix X has been found to contain NaN-labels. Data will be imputed using median.")
Expand All @@ -355,7 +354,7 @@ def _preprocess_numpy(self, X, y):

def _construct_y_score(self, y):
if any(metric.requires_probabilities for metric in self._metrics):
return OneHotEncoder(categories='auto').fit_transform(y.reshape(-1, 1)).todense()
return OneHotEncoder().fit_transform(y.reshape(-1, 1)).todense()
return y

def _search_phase(self, X, y, warm_start=False, restart_criteria=None, timeout=1e6):
Expand Down
2 changes: 1 addition & 1 deletion gama/utilities/auto_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def __init__(self, metric, y_true, label_encoder=None, *args, **kwargs):
self._label_encoder = label_encoder

# For metrics that only require class labels, we still want to apply one-hot-encoding to average predictions.
self._one_hot_encoder = OneHotEncoder(categories='auto').fit(self._y_true.reshape(-1, 1))
self._one_hot_encoder = OneHotEncoder().fit(self._y_true.reshape(-1, 1))

if self._metric.requires_probabilities:
self._y_score = self._one_hot_encoder.transform(self._y_true.reshape(-1, 1)).toarray()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
requirements = [
'numpy>=1.14.0',
'scipy>=1.0.0',
'scikit-learn==0.20.0',
'scikit-learn==0.19.1',
'stopit>=1.1.1',
'liac-arff>=2.2.2',
'category-encoders>=1.2.8'
Expand Down

0 comments on commit 408b414

Please sign in to comment.