I am storing the results from a sklearn regression model to the varibla prediction.
prediction = regressor.predict(data[['X']])
print(prediction)
The values of the prediction output looks like this
[ 266.77832991 201.06347505 446.00066136 499.76736079 295.15519906
214.50514991 422.1043505 531.13126879 287.68760191 201.06347505
402.68859792 478.85808879 286.19408248 192.10235848]
I am then trying to use the to_csv function to save the results to a local CSV file:
prediction.to_csv('C:/localpath/test.csv')
But the error I get back is:
AttributeError: 'numpy.ndarray' object has no attribute 'to_csv'
I am using Pandas/Numpy/SKlearn. Any idea on the basic fix?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…