Python Forum
The behavior of tune model has changed - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: The behavior of tune model has changed (/thread-35323.html)



The behavior of tune model has changed - Led_Zeppelin - Oct-20-2021

import pandas as pd                #data loading and manipulation
import matplotlib.pyplot as plt     #ploting
import seaborn as sns              #statistical plotiing

diabetes = pd.read_csv("diabetes.csv")
diabetes.head()
diabetes.info()

from pycaret.classification import *

dia_clf = setup(data = diabetes,
                 target =  'diabetes',
                 numeric_features=["pregnant"],
                 train_size = 0.8,
                 normalize=True,
                 session_id=123)

tune_gb = tune_model("xgboost", optimize = "AUC", n_iter = 500)
tune_xgb
plot_model(tuned_xgb, plot='feature')
plot_model(tuned_xgb, plot = 'auc')
plot_model(tuned_xgb, plot = 'pr')

predict_model(tuned_xgb)
final_gbc = finalize_model(tuned_xgb)

save_model(tuned_xgb,'Final tuned_xgb Model 11July2020')
saved_final_lightxgb = load_model('Final tuned_xgb Model 11July2020')
The output shows this:

Output:
Description Value 0 session_id 123 1 Target diabetes 2 Target Type Binary 3 Label Encoded neg: 0, pos: 1 4 Original Data (392, 9) 5 Missing Values False 6 Numeric Features 8 7 Categorical Features 0 8 Ordinal Features False 9 High Cardinality Features False 10 High Cardinality Method None 11 Transformed Train Set (313, 8) 12 Transformed Test Set (79, 8) 13 Shuffle Train-Test True 14 Stratify Train-Test False 15 Fold Generator StratifiedKFold 16 Fold Number 10 17 CPU Jobs -1 18 Use GPU False 19 Log Experiment False 20 Experiment Name clf-default-name 21 USI ca0c 22 Imputation Type simple 23 Iterative Imputation Iteration None 24 Numeric Imputer mean 25 Iterative Imputation Numeric Model None 26 Categorical Imputer constant 27 Iterative Imputation Categorical Model None 28 Unknown Categoricals Handling least_frequent 29 Normalize True 30 Normalize Method zscore 31 Transformation False 32 Transformation Method None 33 PCA False 34 PCA Method None 35 PCA Components None 36 Ignore Low Variance False 37 Combine Rare Levels False 38 Rare Level Threshold None 39 Numeric Binning False 40 Remove Outliers False 41 Outliers Threshold None 42 Remove Multicollinearity False 43 Multicollinearity Threshold None 44 Clustering False 45 Clustering Iteration None 46 Polynomial Features False 47 Polynomial Degree None 48 Trignometry Features False 49 Polynomial Threshold None 50 Group Features False 51 Feature Selection False 52 Feature Selection Method classic 53 Features Selection Threshold None 54 Feature Interaction False 55 Feature Ratio False 56 Interaction Threshold None 57 Fix Imbalance False 58 Fix Imbalance Method SMOTE
Error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-27b2d1513045> in <module> 16 session_id=123) 17 ---> 18 tune_gb = tune_model("xgboost", optimize = "AUC", n_iter = 500) 19 tune_xgb 20 plot_model(tuned_xgb, plot='feature') ~\miniconda3\envs\pycaret_env\lib\site-packages\pycaret\classification.py in tune_model(estimator, fold, round, n_iter, custom_grid, optimize, custom_scorer, search_library, search_algorithm, early_stopping, early_stopping_max_iters, choose_better, fit_kwargs, groups, return_tuner, verbose, tuner_verbose, **kwargs) 1100 verbose=verbose, 1101 tuner_verbose=tuner_verbose, -> 1102 **kwargs, 1103 ) 1104 ~\miniconda3\envs\pycaret_env\lib\site-packages\pycaret\internal\tabular.py in tune_model_supervised(estimator, fold, round, n_iter, custom_grid, optimize, custom_scorer, search_library, search_algorithm, early_stopping, early_stopping_max_iters, choose_better, fit_kwargs, groups, return_tuner, verbose, tuner_verbose, display, **kwargs) 3787 if type(estimator) is str: 3788 raise TypeError( -> 3789 "The behavior of tune_model in version 1.0.1 is changed. Please pass trained model object." 3790 ) 3791 TypeError: The behavior of tune_model in version 1.0.1 is changed. Please pass trained model object.
I do not know how the behavior of tune_model 1.0.1 is changed.

I am not sure how to modify the code to eliminate the error.

Any help appreciated. Thanks in advance.

Respectfully,

LZ


RE: The behavior of tune model has changed - ndc85430 - Oct-20-2021

Have you looked at the documentation for the library to see how to use the function in this version? What about checking the release notes (if they produce them) to see the changes between versions?


RE: The behavior of tune model has changed - jefsummers - Oct-20-2021

Before you tune the model, you must create the model.


RE: The behavior of tune model has changed - Led_Zeppelin - Oct-21-2021

If I had the release note I would look at them. I googled the term and nothing came up that was helpful.

Where are release notes? If Google can not find them do they exist??

I would not put the question up if I could have found the answer online.

Respectfully,

LZ


RE: The behavior of tune model has changed - ndc85430 - Oct-21-2021

The PyCaret homepage literally has a link on it that points you to their release notes.


RE: The behavior of tune model has changed - jefsummers - Oct-21-2021

Here is where I found the docs for the classification model.

Here are tutorials.

Look here and scroll down to tune_model to get an example use of tune model.