分享

成功解决ValueError: Supported target types are: (‘binary‘, ‘multiclass‘). Got ‘continuous‘ instead.

 处女座的程序猿 2023-03-01 发布于上海

成功解决ValueError: Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead.



解决问题

问题背景如下:

SKFold = StratifiedKFold(n_splits=cv_i,shuffle=True,random_state=123)

解决思路

值错误:支持的目标类型为:('binary', 'multiclass'),需要用“continuous”替代。


解决方法

stratify只处理分类任务问题,对于回归任务,采用以下问题解决

from sklearn.model_selection import KFold,StratifiedKFold
n_SKFold = StratifiedKFold(n_splits=cv_i,shuffle=True,random_state=123)

替换为

from sklearn.model_selection import KFold,StratifiedKFold
n_SKFold = KFold(n_splits=n_folds ,shuffle=True,random_state=123)

哈哈,大功告成!

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章