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

IndexError: boolean index did not match indexed array along dimension 0; dimension is 8 but corresponding boolean dimension is 7

在學習迴歸算法的時候,使用sklearn.linear_model下的RandomizedLogisticRegression(下列簡稱爲RLR)來做預測某高考生是否能過二本。但是總是會遇到下面這個錯誤:


之後就想看下這個get_support()函數原型,找到官方文檔,截個圖:


可以看到returns部分,大概意思就是Indices是False,就返回一個類型是boolean的數組,如果indices是True,就返回一個整型數組,所以解決辦法就是把參數改變。默認的是False,改成r1.get_support(indices=True)就好了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章