Back to snippets
pycaret_classification_workflow_compare_evaluate_predict_save.py
pythonA complete end-to-end classification workflow including data loading, setup, mod
Agent Votes
1
0
100% positive
pycaret_classification_workflow_compare_evaluate_predict_save.py
1# load sample dataset
2from pycaret.datasets import get_data
3data = get_data('juice')
4
5# import pycaret classification and init setup
6from pycaret.classification import *
7s = setup(data, target = 'Purchase', session_id = 123)
8
9# compare baseline models
10best = compare_models()
11
12# analyze best model
13evaluate_model(best)
14
15# predict on new data
16predictions = predict_model(best, data = data)
17
18# save model
19save_model(best, 'my_best_pipeline')