Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code 60 error
#1
# check pycaret vrsion
import pycaret
print('PyCaret: %s' % pycaret.__version__)
from sklearn.ensemble import ExtraTreesClassifier
import pandas as pd
from pycaret.classification import setup
from pycaret.classification import compare_models

#define the location o the dataset
url = 'http://raw.githubusercontent.com/jbrownlee/Datasets/master/sonar.csv'
#load the dataset
df = pd.read_csv(url, header=None)
#sumarize the shape of the dataset
print(df.shape)

#set column names as the column number
n_cols = df.shape[1]
df.colums = [str(i) for i in range(n_cols)]

# summarize the first few rows of data
print(df.head(0))

# load the sonar dataset
from pandas import read_csv
#define the location of the dataset
url = 'http://raw.githubusercontent.com/jbrownlee/Datasets/master/sonar.csv'
# load the dataset
df = read_csv(url, header=None)
# summarize the shape of the dataset
print(df.shape)
#  set ccolumnn names as the column number
n_cos = df.shape[1]
df_columns = [str(i) for i in range(n_cols)]
#  summarize the first few rows of data
print(df.head())

grid = setup(data=df, target=df.columns[-1], html=False, silent=True, verbose=False)
# evaluate models and compare  results
best=compare_models()

# tune model hyperparameters
best = tune_model(ExtraTreesClassifier(), n_iter=200)
# report th best model
print(best)
Generates the following error:

Error:
# check pycaret vrsion import pycaret print('PyCaret: %s' % pycaret.__version__) from sklearn.ensemble import ExtraTreesClassifier import pandas as pd from pycaret.classification import setup from pycaret.classification import compare_models #define the location o the dataset url = 'http://raw.githubusercontent.com/jbrownlee/Datasets/master/sonar.csv' #load the dataset df = pd.read_csv(url, header=None) #sumarize the shape of the dataset print(df.shape) #set column names as the column number n_cols = df.shape[1] df.colums = [str(i) for i in range(n_cols)] # summarize the first few rows of data print(df.head(0)) # load the sonar dataset from pandas import read_csv #define the location of the dataset url = 'http://raw.githubusercontent.com/jbrownlee/Datasets/master/sonar.csv' # load the dataset df = read_csv(url, header=None) # summarize the shape of the dataset print(df.shape) # set ccolumnn names as the column number n_cos = df.shape[1] df_columns = [str(i) for i in range(n_cols)] # summarize the first few rows of data print(df.head()) grid = setup(data=df, target=df.columns[-1], html=False, silent=True, verbose=False) # evaluate models and compare results best=compare_models() # tune model hyperparameters best = tune_model(ExtraTreesClassifier(), n_iter=200) # report th best model print(best)
I am baffled. What is a code 60 error.

Any help appreciated. Thanks in advance.

Respectfully,

LZ
Reply
#2
Looks like you've reposted the code rather than error/traceback. Can you post the error?
Reply
#3
It doesn't look like you've posted any errors; you've just posted the code again.
Reply
#4
Error:
PyCaret: 2.3.0 (208, 61) Empty DataFrame Columns: [0, 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, 55, 56, 57, 58, 59, 60] Index: [] (208, 61) 0 1 2 3 4 5 6 7 8 \ 0 0.0200 0.0371 0.0428 0.0207 0.0954 0.0986 0.1539 0.1601 0.3109 1 0.0453 0.0523 0.0843 0.0689 0.1183 0.2583 0.2156 0.3481 0.3337 2 0.0262 0.0582 0.1099 0.1083 0.0974 0.2280 0.2431 0.3771 0.5598 3 0.0100 0.0171 0.0623 0.0205 0.0205 0.0368 0.1098 0.1276 0.0598 4 0.0762 0.0666 0.0481 0.0394 0.0590 0.0649 0.1209 0.2467 0.3564 9 10 11 12 13 14 15 16 17 \ 0 0.2111 0.1609 0.1582 0.2238 0.0645 0.0660 0.2273 0.3100 0.2999 1 0.2872 0.4918 0.6552 0.6919 0.7797 0.7464 0.9444 1.0000 0.8874 2 0.6194 0.6333 0.7060 0.5544 0.5320 0.6479 0.6931 0.6759 0.7551 3 0.1264 0.0881 0.1992 0.0184 0.2261 0.1729 0.2131 0.0693 0.2281 4 0.4459 0.4152 0.3952 0.4256 0.4135 0.4528 0.5326 0.7306 0.6193 18 19 20 21 22 23 24 25 26 \ 0 0.5078 0.4797 0.5783 0.5071 0.4328 0.5550 0.6711 0.6415 0.7104 1 0.8024 0.7818 0.5212 0.4052 0.3957 0.3914 0.3250 0.3200 0.3271 2 0.8929 0.8619 0.7974 0.6737 0.4293 0.3648 0.5331 0.2413 0.5070 3 0.4060 0.3973 0.2741 0.3690 0.5556 0.4846 0.3140 0.5334 0.5256 4 0.2032 0.4636 0.4148 0.4292 0.5730 0.5399 0.3161 0.2285 0.6995 27 28 29 30 31 32 33 34 35 \ 0 0.8080 0.6791 0.3857 0.1307 0.2604 0.5121 0.7547 0.8537 0.8507 1 0.2767 0.4423 0.2028 0.3788 0.2947 0.1984 0.2341 0.1306 0.4182 2 0.8533 0.6036 0.8514 0.8512 0.5045 0.1862 0.2709 0.4232 0.3043 3 0.2520 0.2090 0.3559 0.6260 0.7340 0.6120 0.3497 0.3953 0.3012 4 1.0000 0.7262 0.4724 0.5103 0.5459 0.2881 0.0981 0.1951 0.4181 36 37 38 39 40 41 42 43 44 \ 0 0.6692 0.6097 0.4943 0.2744 0.0510 0.2834 0.2825 0.4256 0.2641 1 0.3835 0.1057 0.1840 0.1970 0.1674 0.0583 0.1401 0.1628 0.0621 2 0.6116 0.6756 0.5375 0.4719 0.4647 0.2587 0.2129 0.2222 0.2111 3 0.5408 0.8814 0.9857 0.9167 0.6121 0.5006 0.3210 0.3202 0.4295 4 0.4604 0.3217 0.2828 0.2430 0.1979 0.2444 0.1847 0.0841 0.0692 45 46 47 48 49 50 51 52 53 \ 0 0.1386 0.1051 0.1343 0.0383 0.0324 0.0232 0.0027 0.0065 0.0159 1 0.0203 0.0530 0.0742 0.0409 0.0061 0.0125 0.0084 0.0089 0.0048 2 0.0176 0.1348 0.0744 0.0130 0.0106 0.0033 0.0232 0.0166 0.0095 3 0.3654 0.2655 0.1576 0.0681 0.0294 0.0241 0.0121 0.0036 0.0150 4 0.0528 0.0357 0.0085 0.0230 0.0046 0.0156 0.0031 0.0054 0.0105 54 55 56 57 58 59 60 0 0.0072 0.0167 0.0180 0.0084 0.0090 0.0032 R 1 0.0094 0.0191 0.0140 0.0049 0.0052 0.0044 R 2 0.0180 0.0244 0.0316 0.0164 0.0095 0.0078 R 3 0.0085 0.0073 0.0050 0.0044 0.0040 0.0117 R 4 0.0110 0.0015 0.0072 0.0048 0.0107 0.0094 R --------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~\miniconda3\envs\pycaret_env\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2897 try: -> 2898 return self._engine.get_loc(casted_key) 2899 except KeyError as err: pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 60 The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) <ipython-input-1-b411004c7c69> in <module> 35 print(df.head()) 36 ---> 37 grid = setup(data=df, target=df.columns[-1], html=False, silent=True, verbose=False) 38 # evaluate models and compare results 39 best=compare_models() ~\miniconda3\envs\pycaret_env\lib\site-packages\pycaret\classification.py in setup(data, target, train_size, test_data, preprocess, imputation_type, iterative_imputation_iters, categorical_features, categorical_imputation, categorical_iterative_imputer, ordinal_features, high_cardinality_features, high_cardinality_method, numeric_features, numeric_imputation, numeric_iterative_imputer, date_features, ignore_features, normalize, normalize_method, transformation, transformation_method, handle_unknown_categorical, unknown_categorical_method, pca, pca_method, pca_components, ignore_low_variance, combine_rare_levels, rare_level_threshold, bin_numeric_features, remove_outliers, outliers_threshold, remove_multicollinearity, multicollinearity_threshold, remove_perfect_collinearity, create_clusters, cluster_iter, polynomial_features, polynomial_degree, trigonometry_features, polynomial_threshold, group_features, group_names, feature_selection, feature_selection_threshold, feature_selection_method, feature_interaction, feature_ratio, interaction_threshold, fix_imbalance, fix_imbalance_method, data_split_shuffle, data_split_stratify, fold_strategy, fold, fold_shuffle, fold_groups, n_jobs, use_gpu, custom_pipeline, html, session_id, log_experiment, experiment_name, log_plots, log_profile, log_data, silent, verbose, profile, profile_kwargs) 652 verbose=verbose, 653 profile=profile, --> 654 profile_kwargs=profile_kwargs, 655 ) 656 ~\miniconda3\envs\pycaret_env\lib\site-packages\pycaret\internal\tabular.py in setup(data, target, ml_usecase, available_plots, train_size, test_data, preprocess, imputation_type, iterative_imputation_iters, categorical_features, categorical_imputation, categorical_iterative_imputer, ordinal_features, high_cardinality_features, high_cardinality_method, numeric_features, numeric_imputation, numeric_iterative_imputer, date_features, ignore_features, normalize, normalize_method, transformation, transformation_method, handle_unknown_categorical, unknown_categorical_method, pca, pca_method, pca_components, ignore_low_variance, combine_rare_levels, rare_level_threshold, bin_numeric_features, remove_outliers, outliers_threshold, remove_multicollinearity, multicollinearity_threshold, remove_perfect_collinearity, create_clusters, cluster_iter, polynomial_features, polynomial_degree, trigonometry_features, polynomial_threshold, group_features, group_names, feature_selection, feature_selection_threshold, feature_selection_method, feature_interaction, feature_ratio, interaction_threshold, fix_imbalance, fix_imbalance_method, transform_target, transform_target_method, data_split_shuffle, data_split_stratify, fold_strategy, fold, fold_shuffle, fold_groups, n_jobs, use_gpu, custom_pipeline, html, session_id, log_experiment, experiment_name, log_plots, log_profile, log_data, silent, verbose, profile, profile_kwargs, display) 1173 feature_interactions_top_features_to_select_percentage=interaction_threshold, 1174 display_types=display_dtypes_pass, # this is for inferred input box -> 1175 random_state=seed, 1176 ) 1177 ~\miniconda3\envs\pycaret_env\lib\site-packages\pycaret\internal\preprocess.py in Preprocess_Path_One(train_data, target_variable, ml_usecase, test_data, categorical_features, numerical_features, time_features, features_todrop, display_types, imputation_type, numeric_imputation_strategy, categorical_imputation_strategy, imputation_classifier, imputation_regressor, imputation_max_iter, imputation_warm_start, imputation_order, apply_zero_nearZero_variance, club_rare_levels, rara_level_threshold_percentage, apply_untrained_levels_treatment, untrained_levels_treatment_method, apply_ordinal_encoding, ordinal_columns_and_categories, apply_cardinality_reduction, cardinal_method, cardinal_features, apply_binning, features_to_binn, apply_grouping, group_name, features_to_group_ListofList, apply_polynomial_trigonometry_features, max_polynomial, trigonometry_calculations, top_poly_trig_features_to_select_percentage, scale_data, scaling_method, Power_transform_data, Power_transform_method, remove_outliers, outlier_contamination_percentage, outlier_methods, dummify_categoricals, apply_feature_selection, feature_selection_top_features_percentage, feature_selection_method, remove_multicollinearity, maximum_correlation_between_features, remove_perfect_collinearity, apply_feature_interactions, feature_interactions_to_apply, feature_interactions_top_features_to_select_percentage, cluster_entire_data, range_of_clusters_to_try, apply_pca, pca_method, pca_variance_retained_or_number_of_components, random_state, n_jobs) 3309 else: 3310 # WE NEED TO AUTO INFER the ml use case -> 3311 inferred_ml_usecase, subcase = infer_ml_usecase(train_data[target_variable]) 3312 if ml_usecase is None: 3313 ml_usecase = inferred_ml_usecase ~\miniconda3\envs\pycaret_env\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 2904 if self.columns.nlevels > 1: 2905 return self._getitem_multilevel(key) -> 2906 indexer = self.columns.get_loc(key) 2907 if is_integer(indexer): 2908 indexer = [indexer] ~\miniconda3\envs\pycaret_env\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2898 return self._engine.get_loc(casted_key) 2899 except KeyError as err: -> 2900 raise KeyError(key) from err 2901 2902 if tolerance is not None: KeyError: 60
Okay, I made this mistake. Here is the error posted above.

Respectfully,

LZ
Reply


Forum Jump:

User Panel Messages

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