Skip to content

How can I get/export a production model from a trained model (after refit) with autosklearn? #1467

Open
@seraus

Description

@seraus

Hello team,
I'm doing some tests with autosklearn and I would like to know I can get/export a trained autosklearn model for production use.
Could you please explain which is the process I have to follow?
Currently I am doing this:

automl = autosklearn.classification.AutoSklearnClassifier(
    time_left_for_this_task=3600,
    per_run_time_limit=1800,
    n_jobs=2,
    tmp_folder='/workspace/automl/unito/tmp',
    delete_tmp_folder_after_terminate=False,
    memory_limit=15240,
    resampling_strategy='cv',
    resampling_strategy_arguments={'folds':10},
    metric=autosklearn.metrics.f1_macro,
    scoring_functions=[
        autosklearn.metrics.accuracy,
        autosklearn.metrics.precision,
        autosklearn.metrics.recall,
        autosklearn.metrics.f1_macro
    ]
    include={'classifier': ['random_forestt']},
)
(...)

automl.fit(X_train, y_train, X_test, y_test, dataset_name='mydataset')

y_hat = automl.predict(X_test)
print("Accuracy score", sklearn.metrics.accuracy_score(y_test, y_hat))
print("F1 score", sklearn.metrics.f1_score(y_test, y_hat, average='macro'))
    

automl.refit(X, Y)
y_hat=automl.predict(X_test)
print("F1 score", sklearn.metrics.f1_score(y_test, y_hat, average='macro'))
print("Accuracy score", sklearn.metrics.accuracy_score(y_test, y_hat))

And then I'm using "automl "as a sklearn model and I'm logging it on mlflow but It is rather big (>1 GB).
Is this the right way or there are better ways?

For now I don't need an automatic way, a manual process is sufficient for my tests

Thanks a lot
Sergio

Short Question Description

A clear single sentence question we can try to help with?

With some extra context to follow it up. This way the question is clear for both you and us without it being lost in the paragraph.
Some useful information to help us with your question:

  • How did this question come about?
  • Would a small code snippet help?
  • What have you already looked at?

Before you ask, please have a look at the

  • Documentation
    • If it's related but not clear, please include it in your question with a link, we'll try to make it better!
  • Examples
    • Likewise, an example can answer many questions! However we can't cover all question with examples but if you think your question would benefit from an example, let us know!
  • Issues
    • We try to label all questions with the label Question, maybe someone has already asked. If the question is about a feature, try searching more of the issues. If you find something related but doesn't directly answer your question, please link to it with #(issue number)!

System Details (if relevant)

  • Which version of auto-sklearn are you using?

  • Are you running this on Linux / Mac / ... ?

  • auto-sklearn==0.14.6

  • linux centos 7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions