automl / auto-sklearn

Automated Machine Learning with scikit-learn
https://automl.github.io/auto-sklearn
BSD 3-Clause "New" or "Revised" License
7.58k stars 1.28k forks source link

[Question] automl.show_models() "'sklearn_classifier': None" #1572

Open FelixNeutatz opened 2 years ago

FelixNeutatz commented 2 years ago

Hi everybody,

I printed the ensemble models and got the following output:

automl = AutoSklearn2Classifier()
automl.fit(X_train_hold, y_train_hold, feat_type=feat_type)
print(automl.show_models())
>> {5: {
'model_id': 5, 
'rank': 1, 
'cost': 0.4498021750477469, 
'ensemble_weight': 0.18, 
'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f529fd0fe10>, 
'balancing': Balancing(random_state=0, strategy='weighting'), 
'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f529fd55$
10>, 
'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f529fd55950>, 
'sklearn_classifier': None}}

Now, I am wondering what classifier AutoSklearn2 chose. Can anybody help me here?

Best regards, Felix

eddiebergman commented 2 years ago

Hi @FelixNeutatz,

This appears to be a bug and I'll mark it as such. You could still access it through the "classifier" field, it should be something like pipeline["classifier"].choice.estimator.

Best, Eddie

FelixNeutatz commented 2 years ago

Hi @eddiebergman, thank you for the hint, I found that automl.get_models_with_weights() works:

#get_models_with_weights():
(0.56, SimpleClassificationPipeline({'balancing:strategy': 'weighting', 'classifier:__choice__': 'gradient_boosting', 'data_preprocessor:__choice__': 'feature_type', 'feature_preprocessor:__choice__': 'no_preprocessing', 'classifier:gradient_boosting:early_stop': 'train', 'classifier:gradient_boosting:l2_regularization': 8.789671314063565e-10, 'classifier:gradient_boosting:learning_rate': 0.19595673731599184, 'classifier:gradient_boosting:loss': 'auto', 'classifier:gradient_boosting:max_bins': 255, 'classifier:gradient_boosting:max_depth': 'None', 'classifier:gradient_boosting:max_leaf_nodes': 10, 'classifier:gradient_boosting:min_samples_leaf': 2, 'classifier:gradient_boosting:scoring': 'loss', 'classifier:gradient_boosting:tol': 1e-07, 'data_preprocessor:feature_type:categorical_transformer:categorical_encoding:__choice__': 'no_encoding', 'data_preprocessor:feature_type:categorical_transformer:category_coalescence:__choice__': 'minority_coalescer', 'data_preprocessor:feature_type:numerical_transformer:imputation:strategy': 'median', 'data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__': 'none', 'classifier:gradient_boosting:n_iter_no_change': 13, 'data_preprocessor:feature_type:categorical_transformer:category_coalescence:minority_coalescer:minimum_fraction': 0.0013138596672908974},
dataset_properties={
  'task': 2,
  'sparse': False,
  'multilabel': False,
  'multiclass': True,
  'target_type': 'classification',
  'signed': False}))

#show_models()
 {4: {'model_id': 4, 'rank': 1, 'cost': 0.14806765477285358, 'ensemble_weight': 0.56, 'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f56a90c2950>, 'balancing': Balancing(random_state=1, strategy='weighting'), 'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f56a77727d0>, 'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f56a7772790>, 'sklearn_classifier': None}}

Best regards, Felix