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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

一个处女座的程序猿   2023-03-23 我要评论

成功解决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)

哈哈,大功告成!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们