Open PhanindraPanthagani opened 5 years ago
I believe this error is stemming from some of the sklearn classifiers being searched over not having a predict_proba
method. It looks like using 'continuous_loss_fn=True' assumes this is the case. Instead of using any_classifier
you'll have to restrict your search space to those that are able to return probabilities.
It definitely would be a useful addition to have another predefined high level search space that covers these classifiers
Try to set continuous_loss_fn to False, since roc_auc_score do not need probabilities.
remove continuous_loss_fn
I am using the following code to define a continous loss function AUC for classifier but It throws the error below .Can you please add AUC functionality to the code.
Code : from tpot import TPOTClassifier
from hpsklearn import HyperoptEstimator, any_classifier,any_preprocessing from sklearn.datasets import load_iris from hyperopt import tpe import numpy as np
from sklearn.metrics import roc_auc_score
Make roc_auc_score loss function
def roclossfn(y_true, y_probabilities): lossroc=1-roc_auc_score(y_true, y_probabilities) return lossroc
Instantiate a HyperoptEstimator with the search space and number of evaluations
estim = HyperoptEstimator(classifier=any_classifier('clf'), preprocessing=any_preprocessing('my_pre'), algo=tpe.suggest, max_evals=30, trial_timeout=180,seed=30,continuous_loss_fn=True,loss_fn=roclossfn )
preprocessing=any_preprocessing('my_pre'),
print("estim is",estim)
Search the hyperparameter space based on the data
estim.fit(X_trainnp, y_trainnp)
print("Validation score is ",estim.score(X_validnp, y_validnp)) print( estim.best_model() )
Error:
AttributeError Traceback (most recent call last)