[942]IndexError: boolean index did not match indexed array along dimension 0

在学习回归算法的时候,使用sklearn.linear_model下的RandomizedLogisticRegression(下列简称为RLR)来做预测但是总是会遇到下面这个错误:

IndexError: boolean index did not match indexed array along dimension 0; dimension is 9 but corresponding boolean dimension is 8
之后就想看下这个get_support()函数原型,找到官方文档,截个图:

[942]IndexError: boolean index did not match indexed array along dimension 0_第1张图片

可以看到returns部分,大概意思就是Indices是False,就返回一个类型是boolean的数组,如果indices是True,就返回一个整型数组,所以解决办法就是把参数改变。默认的是False,改成r1.get_support(indices=True)就好了。

参考:https://blog.csdn.net/pcy1127918/article/details/79975152

你可能感兴趣的:(异常)