Hi Guys,I am trying to develop one version using LinearRegression module, however it reflects me the listed below error.

You are watching: Valueerror: expected 2d array, got 1d array instead:

$ mind=LinearRegression()$ mind.fit(x,y)ValueError Traceback (most recent contact last) in ----> 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 # later on np.flexible dtypes will certainly be handled like object dtypesValueError: supposed 2D array, obtained 1D selection instead:array=<2 4 7 9>.Reshape her data either using array.reshape(-1, 1) if your data has a solitary feature or array.reshape(1, -1) if it includes a single sample.What ns am law wrong?


\"*\"
Apr 9, 2020in an equipment Learningby akhtar•38,210 point out •8,000 views
answercomment
flag

Your discuss this question:

Your name to display screen (optional):
Email me at this attend to if a comment is added after mine:Email me if a comment is included after mine

Privacy: her email resolve will only be offered for sending these notifications.

See more: Yuragi-Sou No Yuuna-San Ova


Add commentCancel

1 answer to this question.


Your answer

Your surname to screen (optional):
Email me in ~ this attend to if mine answer is selected or comment on:Email me if mine answer is selected or comment on