mlfinlab icon indicating copy to clipboard operation
mlfinlab copied to clipboard

problems when using ml_cross_val_score

Open zhangda425 opened this issue 1 year ago • 0 comments

my version is 1.6 on win10 although the attachment "Trend_Follow_Question_Extended_SB_Cross_Val" is not updated, I use the new function in mlfinlab 1.6 I met the bugs.

C:\ProgramData\Anaconda3\envs\mlfinlab\lib\site-packages\sklearn\metrics_classification.py in precision_recall_fscore_support(y_true, y_pred, beta, labels, pos_label, average, warn_for, sample_weight, zero_division) 1462 if beta < 0: 1463 raise ValueError("beta should be >=0 in the F-beta score") -> 1464 labels = _check_set_wise_labels(y_true, y_pred, average, labels, 1465 pos_label) 1466

C:\ProgramData\Anaconda3\envs\mlfinlab\lib\site-packages\sklearn\metrics_classification.py in _check_set_wise_labels(y_true, y_pred, average, labels, pos_label) 1275 str(average_options)) 1276 -> 1277 y_type, y_true, y_pred = _check_targets(y_true, y_pred) 1278 # Convert to Python primitive type to avoid NumPy type / Python str 1279 # comparison. See https://github.com/numpy/numpy/issues/6784

C:\ProgramData\Anaconda3\envs\mlfinlab\lib\site-packages\sklearn\metrics_classification.py in _check_targets(y_true, y_pred) 90 91 if len(y_type) > 1: ---> 92 raise ValueError("Classification metrics can't handle a mix of {0} " 93 "and {1} targets".format(type_true, type_pred)) 94

ValueError: Classification metrics can't handle a mix of binary and continuous-multioutput targets

clf_base = DecisionTreeClassifier(criterion='entropy', random_state=42, max_depth=7, class_weight='balanced') clf = SequentiallyBootstrappedBaggingClassifier(samples_info_sets=triple_barrier_events.loc[X_train.index].t1, price_bars = data.loc[X_train.index.min():X_train.index.max(), 'close'], n_estimators=100, base_estimator=clf_base, random_state=42, n_jobs=-1, oob_score=False, max_features=1.) temp_score_base =ml_cross_val_score(clf, X_train, y_train, cv_gen_purged, scoring=f1_score, sample_weight_train=return_based_sample_weights.values)

zhangda425 avatar Sep 07 '22 00:09 zhangda425