freqtrade_strategy icon indicating copy to clipboard operation
freqtrade_strategy copied to clipboard

CatBoostError: Labels variable is empty.

Open shimuldn opened this issue 3 years ago • 0 comments

Hi, Trying to train the model. When running this code block.

model_return = CatBoostClassifier(iterations=12000,
                          #boosting_type='dart',
                          #random_state=42,
                          #num_leaves=41,
                          learning_rate=0.002,
                          #max_bin =10,
                          task_type='GPU')
model_return.fit(train[col_use], train['target'],
             #eval_metric='binary_error',
             verbose=100,
             #early_stopping_rounds=200,
             eval_set=[(val[col_use], val['target'])],
                )

This error pops up.

---------------------------------------------------------------------------
CatBoostError                             Traceback (most recent call last)
<ipython-input-61-0a1e5b6aac9f> in <module>
      6                           #max_bin =10,
      7                           task_type='GPU')
----> 8 model_return.fit(train[col_use], train['target'],
      9              #eval_metric='binary_error',
     10              verbose=100,

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in fit(self, X, y, cat_features, text_features, embedding_features, sample_weight, baseline, use_best_model, eval_set, verbose, logging_level, plot, column_description, verbose_eval, metric_period, silent, early_stopping_rounds, save_snapshot, snapshot_file, snapshot_interval, init_model)
   4537             self._check_is_classification_objective(params['loss_function'])
   4538 
-> 4539         self._fit(X, y, cat_features, text_features, embedding_features, None, sample_weight, None, None, None, None, baseline, use_best_model,
   4540                   eval_set, verbose, logging_level, plot, column_description, verbose_eval, metric_period,
   4541                   silent, early_stopping_rounds, save_snapshot, snapshot_file, snapshot_interval, init_model)

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in _fit(self, X, y, cat_features, text_features, embedding_features, pairs, sample_weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, use_best_model, eval_set, verbose, logging_level, plot, column_description, verbose_eval, metric_period, silent, early_stopping_rounds, save_snapshot, snapshot_file, snapshot_interval, init_model)
   1902             raise CatBoostError("y may be None only when X is an instance of catboost.Pool or string")
   1903 
-> 1904         train_params = self._prepare_train_params(
   1905             X=X, y=y, cat_features=cat_features, text_features=text_features, embedding_features=embedding_features,
   1906             pairs=pairs, sample_weight=sample_weight, group_id=group_id, group_weight=group_weight,

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in _prepare_train_params(self, X, y, cat_features, text_features, embedding_features, pairs, sample_weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, use_best_model, eval_set, verbose, logging_level, plot, column_description, verbose_eval, metric_period, silent, early_stopping_rounds, save_snapshot, snapshot_file, snapshot_interval, init_model)
   1792         embedding_features = _process_feature_indices(embedding_features, X, params, 'embedding_features')
   1793 
-> 1794         train_pool = _build_train_pool(X, y, cat_features, text_features, embedding_features, pairs,
   1795                                        sample_weight, group_id, group_weight, subgroup_id, pairs_weight,
   1796                                        baseline, column_description)

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in _build_train_pool(X, y, cat_features, text_features, embedding_features, pairs, sample_weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, column_description)
   1118         if y is None:
   1119             raise CatBoostError("y has not initialized in fit(): X is not catboost.Pool object, y must be not None in fit().")
-> 1120         train_pool = Pool(X, y, cat_features=cat_features, text_features=text_features, embedding_features=embedding_features, pairs=pairs, weight=sample_weight, group_id=group_id,
   1121                           group_weight=group_weight, subgroup_id=subgroup_id, pairs_weight=pairs_weight, baseline=baseline)
   1122     return train_pool

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in __init__(self, data, label, cat_features, text_features, embedding_features, column_description, pairs, delimiter, has_header, ignore_csv_quoting, weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, feature_names, thread_count)
    586                     )
    587 
--> 588                 self._init(data, label, cat_features, text_features, embedding_features, pairs, weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, feature_names, thread_count)
    589         super(Pool, self).__init__()
    590 

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in _init(self, data, label, cat_features, text_features, embedding_features, pairs, weight, group_id, group_weight, subgroup_id, pairs_weight, baseline, feature_names, thread_count)
   1050         if label is not None:
   1051             self._check_label_type(label)
-> 1052             self._check_label_empty(label)
   1053             label = self._label_if_pandas_to_numpy(label)
   1054             if len(np.shape(label)) == 1:

/home/ubuntu/Desktop/freqtrade/.env/lib/python3.8/site-packages/catboost/core.py in _check_label_empty(self, label)
    694         """
    695         if len(label) == 0:
--> 696             raise CatBoostError("Labels variable is empty.")
    697 
    698     def _check_label_shape(self, label, samples_count):

CatBoostError: Labels variable is empty.

If you can help. Thanks

shimuldn avatar May 19 '21 10:05 shimuldn