1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

バレンタインチョコの個数を線形回帰で予測してみました。

Posted at
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression

chocolates = np.array([0, 1]).reshape(1, -1).T
year = np.array([2021, 2022]).reshape(1, -1).T
model = LinearRegression()
model.fit(year, chocolates)
future = np.linspace(2021, 2050, 30).reshape(1, -1).T
plt.scatter(year, chocolates, label="Observed")
plt.plot(future, model.predict(future), label="Predicted")
plt.title("Linear Regression")
plt.xlabel("Year")
plt.ylabel("Chocolates")
plt.grid()
plt.legend()
plt.show()

chocolates.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?