代码能运行,结果和老师的也是一样,但是程序有个warning
UserWarning: X does not have valid feature names, but CategoricalNB was fitted with feature names warnings.warn(
怎么调整都不行
UserWarning: X does not have valid feature names, but CategoricalNB was fitted with feature names warnings.warn(
怎么调整都不行
2021-12-01
#测试样本 #x_test=np.array([[0,0,0,1,1,0]]) x_test = pd.DataFrame([[0,0,0,1,1,0]], columns=list(['gender','age','status','city','cost','device'])) print(x_test) #x_feature_name=np.array(['gender','age','status','city','cost','device']) #print(x_test) y_test_pred_prob=model.predict(x_test) print(y_test_pred_prob) 测试数据类型的问题 x_test=np.array([[0,0,0,1,1,0]]) 是numpy里的ndarry类型;只有数据 要用pandas中DataFrame类型,这种类型里面包含feature_name,不会有warning.
举报