pycaret / pycaret

An open-source, low-code machine learning library in Python
https://www.pycaret.org
MIT License
8.94k stars 1.77k forks source link

[BUG]: IllegalMonthError: bad month number nan; must be 1-12 #3268

Closed KhalidAmine closed 1 year ago

KhalidAmine commented 1 year ago

pycaret version checks

Issue Description

While setting up pycaret environment with following code

from pycaret.classification import *

setting up env pycaret

exp_class = setup(data = df, target='ETH-USD_up', session_id=123, normalize=True, use_gpu = True, fold_strategy = 'timeseries')

I get the following error, for which after hours of searching I cannot solve. My data consists only of numeric value without any date variable:

596 if log_plots == True:
597     log_plots = ["auc", "confusion_matrix", "feature"]

--> 599 return pycaret.internal.tabular.setup( 600 ml_usecase="classification", 601 available_plots=available_plots, 602 data=data, 603 target=target, 604 train_size=train_size, 605 test_data=test_data, 606 preprocess=preprocess, 607 imputation_type=imputation_type, 608 iterative_imputation_iters=iterative_imputation_iters, 609 categorical_features=categorical_features, 610 categorical_imputation=categorical_imputation, 611 categorical_iterative_imputer=categorical_iterative_imputer, 612 ordinal_features=ordinal_features, 613 high_cardinality_features=high_cardinality_features, 614 high_cardinality_method=high_cardinality_method, ... --> 124 raise IllegalMonthError(month) 125 day1 = weekday(year, month, 1) 126 ndays = mdays[month] + (month == February and isleap(year))

IllegalMonthError: bad month number nan; must be 1-12

Reproducible Example

/

Expected Behavior

I expect the setup function to setup the pycaret environment for classification.

Actual Results

---------------------------------------------------------------------------
IllegalMonthError                         Traceback (most recent call last)
Cell In[17], line 2
      1 # setting up env pycaret 
----> 2 exp_class = setup(data = df, target='ETH-USD_up', session_id=123, normalize=True, use_gpu = True) #, fold_strategy = 'timeseries'

File ~/Desktop/dev/Eth_ML_predictor/CryptoML/lib/python3.8/site-packages/pycaret/classification.py:599, 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, experiment_custom_tags, log_plots, log_profile, log_data, silent, verbose, profile, profile_kwargs)
    596 if log_plots == True:
    597     log_plots = ["auc", "confusion_matrix", "feature"]
--> 599 return pycaret.internal.tabular.setup(
    600     ml_usecase="classification",
    601     available_plots=available_plots,
    602     data=data,
    603     target=target,
    604     train_size=train_size,
    605     test_data=test_data,
    606     preprocess=preprocess,
    607     imputation_type=imputation_type,
    608     iterative_imputation_iters=iterative_imputation_iters,
    609     categorical_features=categorical_features,
    610     categorical_imputation=categorical_imputation,
    611     categorical_iterative_imputer=categorical_iterative_imputer,
    612     ordinal_features=ordinal_features,
    613     high_cardinality_features=high_cardinality_features,
    614     high_cardinality_method=high_cardinality_method,
...
--> 124     raise IllegalMonthError(month)
    125 day1 = weekday(year, month, 1)
    126 ndays = mdays[month] + (month == February and isleap(year))

IllegalMonthError: bad month number nan; must be 1-12

Installed Versions

>>> import pycaret; pycaret.__version__ '2.3.10'
KhalidAmine commented 1 year ago

Issue was with the input data.