Getting error while fitting regression model

Hi, when i tried to fit LinearRegression model for smokers, i am getting an following error.
ValueError:Expected 2D array, got 1D instead.

Can someone tell me how to convert 1D array to 2D array.

Hey @pranitanap3, welcome to the community.
It seems the inputs array you are passing is of 1-Dimension, i.e the shape of the input_array is (n, ), you have to make it a 2-D array as fit() function accepts 2-D values. Use input_array.reshape(1,-1) to convert the 1-D array to 2-D array.

2 Likes