最近在使用RandomizedLogisticRegression(RLR)随机逻辑回归模型方法筛选出主要特征。
1.错误一:This solver needs samples of at least 2 classes in the data, but the data contains 1 class
原因是样本数据量太少,不够进行机器学习。
解决方案是增加样本数据就好。
2.错误一:IndexError: boolean index did not match indexed array along dimension 0; dimension is 9 but 8
这是由于rlr.get_support()方法的问题。
官网上的方法说明
可以看到returns部分,大概意思就是Indices是False,就返回一个类型是boolean的数组,如果indices是True,就返回一个整型数组,所以解决办法就是把参数改变。默认的是False,改成r1.get_support(indices=True)就好了。