How to fix “ValueError: Expected 2D array, got 1D array instead” in sklearn/python?

后端 未结 3 856
鱼传尺愫
鱼传尺愫 2021-01-13 21:51

I there. I just started with the machine learning with a simple example to try and learn. So, I want to classify the files in my disk based on the file type by making use of

3条回答
  •  灰色年华
    2021-01-13 22:44

    X=dataset.iloc[:, 0].values
    y=dataset.iloc[:, 1].values
    
    regressor=LinearRegression()
    X=X.reshape(-1,1)
    regressor.fit(X,y)
    

    I had the following code. The reshape operator is not an inplace operator. So we have to replace it's value by the value after reshaping like given above.

提交回复
热议问题