forked from pycaret/pycaret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.py
54 lines (40 loc) · 1.34 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#dataset and target
dataset = 'juice'
target = 'Purchase'
#checking version
from pycaret.utils import version
version()
import time
t0 = time.time()
#loading dataset
from pycaret.datasets import get_data
data = get_data(dataset, verbose=False)
#init regression
from pycaret.classification import setup
exp1 = setup(data, target = target, silent=True, html=False, verbose=False)
#RECEIPE #1 - SELECT TOP 5 MODELS
from pycaret.classification import compare_models
top5 = compare_models(n_select=5, whitelist = ['dt', 'lr', 'rf', 'lightgbm', 'xgboost'])
#RECEIPE #2 - TUNE TOP 5 MODELS
from pycaret.classification import tune_model
tuned_top5 = [tune_model(i) for i in top5]
print(len(tuned_top5))
#RECIPE #3
from pycaret.classification import blend_models
blender = blend_models(top5, verbose=False)
print(blender)
from pycaret.classification import pull
pull()
#FINALIZE BEST MODEL
from pycaret.classification import automl
best_model = automl(optimize='MCC', use_holdout=True)
print(best_model)
t1 = time.time()
tt = round(t1-t0,4)
from pycaret.classification import plot_model
plot_model(best_model, plot = 'confusion_matrix')
from pycaret.classification import create_model
xgboost = create_model('xgboost', verbose=False)
from pycaret.classification import interpret_model
interpret_model(xgboost)
print("Succesfully Completed in {} Seconds".format(tt))