Closed drakeeee closed 6 years ago
Ah I think I might have solved my own issue,
pipe = autosklearn.classification.AutoSklearnClassifier()
pipe.fit(clf_x[tr_idx], labels[tr_idx],
metric=make_scorer('log_loss', metrics.log_loss, needs_proba=True))
probs = pipe.predict_proba(clf_x) # Error happens here
roc_auc = metrics.roc_auc_score(labels, probs[:, 1])
print(roc_auc)
I'll close if this solves the issue.
When closing, could you please briefly describe what you changed?
I also see this error. I reproduced it by modifying your example
$ git diff
diff --git a/example/example_sequential.py b/example/example_sequential.py
index 019ad3b..c325cee 100644
--- a/example/example_sequential.py
+++ b/example/example_sequential.py
@@ -25,7 +25,7 @@ def main():
# This call to fit_ensemble uses all models trained in the previous call
# to fit to build an ensemble which can be used with automl.predict()
automl.fit_ensemble(y_train, ensemble_size=50)
-
+ probs = automl.predict_proba(X_train)
print(automl.show_models())
predictions = automl.predict(X_test)
print(automl.sprint_statistics())
$ python example/example_sequential.py
Traceback (most recent call last):
File "example/example_sequential.py", line 36, in <module>
main()
File "example/example_sequential.py", line 28, in main
probs = automl.predict_proba(X_train)
File "/auto-sklearn/autosklearn/estimators.py", line 432, in predict_proba
X, batch_size=batch_size, n_jobs=n_jobs)
File "/auto-sklearn/autosklearn/automl.py", line 946, in predict_proba
return self._automl.predict(X, batch_size=batch_size, n_jobs=n_jobs)
AttributeError: 'AutoMLClassifier' object has no attribute '_automl'
Hello,
I have the same issue with the latest version available on Pypi; has the fix been pushed ? Thanks!
The fix is only in the development branch, but not yet on Pypi.
Thanks for your answer. I've installed the GitHub version and got the following error when using predict_proba:
AttributeError: 'NoneType' object has no attribute 'get_model_identifiers'
The parameters for the classifiers were the following: automl = autosklearn.classification.AutoSklearnClassifier( tmp_folder='/tmp/autosklearn_cv_example_tmp', output_folder='/tmp/autosklearn_cv_example_out', delete_tmp_folder_after_terminate=False, seed=42,initial_configurations_via_metalearning=0, ml_memory_limit=10000, ensemble_size=0 )
Here is the Traceback:
AttributeError Traceback (most recent call last)
Could you please paste a minimal working example?
Here is the example.
from sklearn.datasets import load_digits import autosklearn.classification import pandas as pd import numpy as np automl = autosklearn.classification.AutoSklearnClassifier( tmp_folder='/tmp/autosklearn_cv_example_tmp', output_folder='/tmp/autosklearn_cv_example_out', delete_tmp_folder_after_terminate=False, seed=42,initial_configurations_via_metalearning=0, ml_memory_limit=10000, ensemble_size=0) X, y = load_digits(return_X_y=True) X_train, X_test, y_train, y_test = \ train_test_split(X, y, random_state=1) automl.fit(X_train, y_train, dataset_name='digits', metric=auc) automl.predict_proba(X_test)`
AttributeError Traceback (most recent call last)
I think there are two issues here:
The following works:
from sklearn.datasets import load_digits
import autosklearn.classification
from sklearn.model_selection import train_test_split
from autosklearn.metrics import f1_macro
automl = autosklearn.classification.AutoSklearnClassifier(
tmp_folder='/tmp/autosklearn_cv_example_tmp',
output_folder='/tmp/autosklearn_cv_example_out',
delete_tmp_folder_after_terminate=False,
seed=42, initial_configurations_via_metalearning=0,
ml_memory_limit=10000,
ensemble_size=1,
time_left_for_this_task=60,
)
X, y = load_digits(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1)
automl.fit(X_train, y_train, dataset_name='digits', metric=f1_macro)
automl.predict_proba(X_test)
Re-opening this to remind us to add better error messages.
Thanks. I'll have a look at your solution!
The code posted by @mfeurer does not solve the issue. I still get 'AutoMLClassifier' object has no attribute '_automl'
.
NVM: My version of autoML was not updated.
@chrisby could you please upload the log of Auto-sklearn somewhere (either as a file on github, or to pastebin)?
I've changed a string in automl.py and got expected probabilities
def predict_proba(self, X, batch_size=None, n_jobs=1):
# return self._automl.predict(X, batch_size=batch_size, n_jobs=n_jobs)
return super().predict(X, batch_size=batch_size, n_jobs=n_jobs)
Thanks @barley99 we will put your fix in the next release.
The fix by @barley99 is already in the development branch, so this issue can be closed.
Has this issue been fixed? Has anyone else also tried everything here and still receive the same error?
Hello. Thanks for the great library. I am getting an AttributeError when trying to call predict_proba on a fit classifier. Have you seen this error before?