如何修改机器学习实例错误bad input shape()
1、嚼但匙噻首先将训练输入的数据转变为数组修改前代码:input_data_encoded[i] = int(labe造婷用痃l_encoder[count].transform(input_data[i]))修改后代码:input_data_encoded[i] = int(label_encoder[count].transform([input_data[i]]))


2、经过上一步的操作会出现数组大小错误Reshape your data either using array.reshape(-1, 1) if your data has 锾攒揉敫a single feature or array.reshape(1, -1) if it contains a single sample.

3、最后将数组转为一维数组,满足predict函数对数组大小的要求input_data_encoded = np.array(input_data_encoded)input_data_encoded = input_data_encoded.reshape(1, len(input_data))
