Error in Python script “Expected 2D array, got 1D array instead:”?

后端 未结 9 738
执念已碎
执念已碎 2020-11-30 01:29

I\'m following this tutorial to make this ML prediction:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style

style.use(\"ggplot\         


        
9条回答
  •  失恋的感觉
    2020-11-30 02:05

    I faced the same problem. You just have to make it an array and moreover you have to put double squared brackets to make it a single element of the 2D array as first bracket initializes the array and the second makes it an element of that array.

    So simply replace the last statement by:

    print(clf.predict(np.array[[0.58,0.76]]))
    

提交回复
热议问题