You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to retrieve the individual models from the final ensemble? I mean, not only the hyperparameters used to train it, but the individual weights learned in the fitting/training phase.
Thank you
The text was updated successfully, but these errors were encountered:
This is not documented and should be made more accessible as in our plans for the future but here is a code snippet to help you out. I've also renamed your question to be more precise.
fromautosklearn.pipeline.utilimportget_datasetfromautosklearn.classificationimportAutoSklearnClassifierX_train, y_train, X_test, y_test=get_dataset('iris')
automodel=AutoSklearnClassifier(time_left_for_this_task=60)
automodel.fit(X_train, y_train)
# A list of pipelines with their weights [ (ensemble_weight, Pipeline) ]models_with_weights=automodel.get_models_with_weights()
# Get the first model with it's weightweight, model=models_with_weights[0]
# Note that these models and the following are sklearn compatible# The steps in the models pipeline# [ # ('data_preprocessing', DataPreprocessor),# ('balancing', Balancing ),# ('feature_preprocessor', FeaturePreprocessorChoice)# ('classifier', ClassifierChoice)# ]models_steps=model.steps# Get the ClassifierChoice wrapperclassifier_str, classifier=model.steps[-1]
# The autosklearn wrapped model classifier=classifier.choiceprint(type(classifier)) # autosklearn.pipeline.components.classification.random_forest.RandomForest# The sklearn modelsklearn_classifier=classifier.estimator
Note that these models were trained with the other three parts of the pipeline in mind so if you were planning to use them in some way, you'd have to consider those too.
eddiebergman
changed the title
[Question] My Question?
[Question] How to get individual models from the ensemble?
Aug 17, 2021
Hello, nice project!
Is there a way to retrieve the individual models from the final ensemble? I mean, not only the hyperparameters used to train it, but the individual weights learned in the fitting/training phase.
Thank you
The text was updated successfully, but these errors were encountered: