Closed tasyacute closed 8 years ago
Can you give me some code to reproduce the error?
Dear Dr,
Fyi Dr, I'm using Ms Windows 7, Python 2.7, Deap 1.0.2 and sklearn-deap 0.1.4.
I'm running that code from https://github.com/rsteca/sklearn-deap
import sklearn.datasetsimport numpy as npimport random
data = sklearn.datasets.load_digits()X = data["data"] y = data["target"] from sklearn.svm import SVCfrom sklearn.cross_validation import StratifiedKFold
paramgrid = {"kernel": ["rbf"], "C" : np.logspace(-9, 9, num=25, base=10), "gamma" : np.logspace(-9, 9, num=25, base=10)}
random.seed(1) from evolutionary_search import EvolutionaryAlgorithmSearchCV cv = EvolutionaryAlgorithmSearchCV(estimator=SVC(), params=paramgrid, scoring="accuracy", cv=StratifiedKFold(y, n_folds=4), verbose=1, population_size=50, gene_mutation_prob=0.10, gene_crossover_prob=0.5, tournament_size=3, generations_number=5, n_jobs=4) cv.fit(X, y)
The error message like that shown:
C:\Anaconda2\lib\site-packages\sklearn\cross_validation.py:43: DeprecationWarning: This module has been deprecated in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20. "This module will be removed in 0.20.", DeprecationWarning)
---------------------------------------------------------------------------AttributeError
Traceback (most recent call
last)
C:\Anaconda2\lib\site-packages\evolutionary_searchinit.pyc in fit(self, X, y) 283 def fit(self, X, y=None): 284 self.bestestimator = None--> 285 self.bestscore = -1 286 self.bestparams = None 287 for possible_params in self.possible_params: AttributeError: can't set attribute
Thank you
Tasya Syafia
On 5 September 2016 at 21:05, rsteca notifications@github.com wrote:
Can you give me some code to reproduce the error?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rsteca/sklearn-deap/issues/11#issuecomment-244742484, or mute the thread https://github.com/notifications/unsubscribe-auth/AU98TLANqeYyJa3nJiJXSWF4Fh0QiOFwks5qnBORgaJpZM4J0iyZ .
I'm not able to reproduce any error. The DeprecationWarning is just a warning from scikit-learn. What scikit-learn version are you using?
For your information, I'm currently using scikit-learn 0.18.dev0 because I want to use MLP Classifier. The error shows somewhere in evolutionary_search package I guess.
On 21 September 2016 at 10:18, rsteca notifications@github.com wrote:
I'm not able to reproduce any error. The DeprecationWarning is just a warning from scikit-learn. What scikit-learn version are you using?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rsteca/sklearn-deap/issues/11#issuecomment-248492387, or mute the thread https://github.com/notifications/unsubscribe-auth/AU98TNB5oIPvqNquGQM-o1i13h16f3H_ks5qsJP_gaJpZM4J0iyZ .
@rsteca @tasyacute Hi I am trying to run the example of usage shown here: https://github.com/rsteca/sklearn-deap and I am getting the following error:
# ---------------------------------------------------------------------------
# AttributeError Traceback (most recent call last)
# <ipython-input-40-30ba9e09b73c> in <module>()
----> 1 cv.fit(X, y)
/usr/local/lib/python2.7/site-packages/evolutionary_search/__init__.pyc in fit(self, X, y)
283 def fit(self, X, y=None):
284 self.best_estimator_ = None
--> 285 self.best_score_ = float("-inf")
286 self.best_params_ = None
287 for possible_params in self.possible_params:
# AttributeError: can't set attribute
I get the same error for self.best_params_
if I comment self.best_score_
line
This is my setup
deap==1.0.2
sklearn-deap==0.1.5
scikit-learn==0.18
scipy==0.18.1
numpy==1.11.2
Thank you @rsteca and congratulations for this project, I can't wait to have it working!.
Ben
@tasyacute @TATABOX42
It seems that there is an incompatibility with scikit-learn 0.18, doing:
pip install scikit-learn==0.17.1
solves de problem.
I will have to make some more tests in order to know why it is not working with the latest sklearn version.
@tasyacute @TATABOX42
Ok, I finally solved it. Just do:
pip install sklearn-deap --upgrade
@rsteca thank you very much, the solution worked as intended. Greetings from Mexico and congrats for this package.
AttributeError: can't set attribute
It pointed out the error come from fit( ) method as
def fit(self, X, y=None): self.bestestimator = None --> self.bestscore = -1 self.bestparams = None for possible_params in self.possible_params: self._fit(X, y, possible_params) if self.refit: self.bestestimator = clone(self.estimator) self.bestestimator.set_params(**self.bestparams) self.bestestimator.fit(X, y)