Python Forum
The behavior of tune model has changed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The behavior of tune model has changed
#1
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
Reply
#2
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?
Reply
#3
Before you tune the model, you must create the model.
Reply
#4
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
Reply
#5
The PyCaret homepage literally has a link on it that points you to their release notes.
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  model.fit and model.predict errors hatflyer 6 1,308 Nov-10-2023, 01:39 AM
Last Post: hatflyer
  How to fine tune cutecharts? Gigux 1 1,226 Jan-28-2022, 05:41 PM
Last Post: Larz60+
  FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles Anldra12 10 5,773 Jun-11-2021, 04:48 PM
Last Post: snippsat
  how can a variable change if I haven't changed it? niminim 5 3,043 Apr-07-2021, 06:57 PM
Last Post: niminim
  RuntimeError: dictionary changed size during iteration Shreeniket987 3 3,725 Jun-01-2019, 01:22 PM
Last Post: buran
  my list is being changed ivinjjunior 15 5,670 May-29-2019, 02:54 PM
Last Post: ivinjjunior
  RuntimeError: dictionary changed size during iteration anna 4 3,480 Feb-20-2019, 11:04 AM
Last Post: anna
  how to work with variables changed in definitions Prof_Jar_Jar 2 2,614 Dec-16-2018, 12:04 AM
Last Post: Prof_Jar_Jar
  RuntimeError: dictionary changed size during iteration Skaperen 1 9,134 Dec-10-2018, 10:14 PM
Last Post: nilamo
  Saving Values Changed in a database themick789 1 2,269 Nov-28-2018, 08:16 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020