成功解决IndexError: index 14 is out of bounds for axis 1 with size 14

 

 

目录

解决问题

解决思路

解决方法


 

 

 

解决问题

IndexError: index 14 is out of bounds for axis 1 with size 14

 

解决思路

索引错误:索引14超出轴1的界限,大小为14

 

解决方法

       自定义的列表混淆,向上查找正确的自定义参数!参数是df_test_5而不是最最上边定义的df_test参数,因为两者的shape不一样,所以会导致索引错误!

test = df_test.filter(regex='Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass.*|Mother|Child|Family|Title')
    
print('开始输出predictions')
predictions = bagging_clf.predict(test)


改为



test = df_test_5.filter(regex='Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass.*|Mother|Child|Family|Title')
    
print('开始输出predictions')
predictions = bagging_clf.predict(test)

 


本文转载:CSDN博客