2016-11-22 1 views
1

sklearnの単純な線形回帰を実行しようとしています。私は「好き」と「出席」の2つの列を持つパンダのデータフレームを持っています。どちらの列も18サンプルあります。sklearn linear regressionを実行して、「サンプル数の不一致の配列」エラーを取得する

lr = LinearRegression() 
lr.fit(Likes,Attendance) 

私は次のエラーを取得する:

C:\Anaconda3\lib\site-packages\sklearn\utils\validation.py:386: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample. DeprecationWarning)

...

ValueError: Found arrays with inconsistent numbers of samples: [ 1 18]

私はLikes.reshape(-1、1)を使用してデータを整形した後でも、私は同じエラーを得ました。

誰でも手助けできますか?

+0

私はチェックし、LikesとAttendanceの両方の形が "(18、)"であることを確認しました。 –

答えて

0

あなたのデータには1つの機能があります(投稿したエラーの示唆したように)。 "X.reshape(-1、1)を使用してデータを整形..."。

lr = LinearRegression() 
lr.fit(X=Likes.reshape(-1, 1), y=Attendance) 

これを試したことがわかりました。上のコードはうまくいきませんか?

関連する問題