成功解决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)
哈哈,大功告成!
到此这篇关于成功解决ValueError: Supported target types are: (‘binary‘, ‘multiclass‘). Got ‘continuous‘ instead.的文章就介绍到这了,更多相关Supported target types are内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!