Hi Guys,
I am trying to create one model using LinearRegression module, but it shows me the below error.
$ mind=LinearRegression()
$ mind.fit(x,y)
ValueError Traceback (most recent call last)
<ipython-input-24-f07030a0937c> in <module>
----> 1 mind.fit(x,y)
~\anaconda3\lib\site-packages\sklearn\linear_model\_base.py in fit(self, X, y, sample_weight)
490 n_jobs_ = self.n_jobs
491 X, y = check_X_y(X, y, accept_sparse=['csr', 'csc', 'coo'],
--> 492 y_numeric=True, multi_output=True)
493
494 if sample_weight is not None:
~\anaconda3\lib\site-packages\sklearn\utils\validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)
753 ensure_min_features=ensure_min_features,
754 warn_on_dtype=warn_on_dtype,
--> 755 estimator=estimator)
756 if multi_output:
757 y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,
~\anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
554 "Reshape your data either using array.reshape(-1, 1) if "
555 "your data has a single feature or array.reshape(1, -1) "
--> 556 "if it contains a single sample.".format(array))
557
558 # in the future np.flexible dtypes will be handled like object dtypes
ValueError: Expected 2D array, got 1D array instead:
array=[2 4 7 9].
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.
What I am doing wrong?