回答編集履歴

1

追加

2022/04/18 16:11

投稿

meg_
meg_

スコア10903

test CHANGED
@@ -19,3 +19,17 @@
19
19
  plt.show()
20
20
  ```
21
21
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-19/933a2743-8ccb-4a9e-9ee1-add95b272641.png)
22
+
23
+ ---
24
+ 追加の情報を受けての結果です。
25
+ ```Python
26
+ x = np.array([0.2, 0.3, 0.3, 0.4, 0.6])
27
+ y = np.array([2.171863648476775, 2.171863648476775, 2.171863648476775, 2.171863648476775, 3.7928153875935355])
28
+ lr = linear_model.LinearRegression(fit_intercept=False)
29
+ lr.fit(x.reshape(-1, 1), y)
30
+ plt.plot(np.append(0,x), np.append(0,lr.predict(x.reshape(-1, 1))))
31
+ plt.scatter(x, y)
32
+ plt.grid()
33
+ plt.show()
34
+ ```
35
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-19/c5fb8269-d9fe-42e8-9312-dd1302e1f570.png)