3

I'm trying to save all models generated by autosklearn, but I can only get the best model.

    import sklearn.datasets
    import sklearn.metrics
    
    import autosklearn.classification
    
    # Load data
    X, y = sklearn.datasets.load_breast_cancer(return_X_y=True)
    X_train, X_test, y_train, y_test = \
        sklearn.model_selection.train_test_split(X, y, random_state=1)
    
    automl = autosklearn.classification.AutoSklearnClassifier(
        time_left_for_this_task=120,
        per_run_time_limit=30,
        tmp_folder='/tmp/autosklearn_classification_example_tmp',
        output_folder='/tmp/autosklearn_classification_example_out',
    )
    automl.fit(X_train, y_train, dataset_name='breast_cancer')
    
    # Show all models
    print(automl.show_models())
    
    # Here it uses the best model
    predictions = automl.predict(X_test)
    print("Accuracy score:", sklearn.metrics.accuracy_score(y_test, predictions))
  • Is show_models() printing models being used in the best ensamble model?
  • Is there any way to get other models?
Israel Varea
  • 2,600
  • 2
  • 17
  • 24

1 Answers1

0

Autosklearn pipelines may be checked in some ways, one of which is by using PipelineProfiler; this allows you to examine all of the best-performing pipelines.

To begin, install the pipeline profile on your machine:

pip install pipelineprofiler

Then write the following code:

import PipelineProfiler
# automl is an object Which has already been created.
profiler_data= PipelineProfiler.import_autosklearn(automl)
PipelineProfiler.plot_pipeline_matrix(profiler_data)

Your output should be a plot that shows all the pipelines.

stonechat
  • 11
  • 3