valueError: This solver needs samples of at least 2 classes in the data, but the data contains only
Posted 飞翔—鸟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了valueError: This solver needs samples of at least 2 classes in the data, but the data contains only 相关的知识,希望对你有一定的参考价值。
问题描述:执行下面的代码,报错valueError: This solver needs samples of at least 2 classes in the data, but the data contains only one class: 0
原因:数据量太少
解决方案:增加训练数据量
代码如下:
filename = "test.csv" data = pd.read_csv(filename,sep=‘ ‘) data = pd.DataFrame(data) x = data.iloc[:,:8].as_matrix() y = data.iloc[:,8].as_matrix() from sklearn.linear_model import LogisticRegression as LR from sklearn.linear_model import RandomizedLogisticRegression as RLR rlr = RLR() # 建立随机逻辑回归模型,筛选变量 rlr.fit(x, y) rlr.get_support() print (rlr.get_support()) print ("*********************88") print (u‘有效特征:%s‘ % ‘,‘.join(data.columns[rlr.get_support()]))
以上是关于valueError: This solver needs samples of at least 2 classes in the data, but the data contains only 的主要内容,如果未能解决你的问题,请参考以下文章
ValueError: This ORT build has [‘TensorrtExecutionProvider‘, ‘CUDAExecutionProvider‘, ‘CPUExecutionP
ValueError: This ORT build has [‘TensorrtExecutionProvider‘, ‘CUDAExecutionProvider‘, ‘CPUExecutionP
HDF5 min_itemsize 错误:ValueError: Trying to store a string with len [##] in [y] column but this colum