import ML
[Notice] [ML_1]
import numpy as np
from sklearn.linear_model import LinearRegression
x = np.arange(10).reshape(-1, 1)
y = (2*x + 1).reshape(-1, 1)
x
array([[0],
[1],
[2],
[3],
[4],
[5],
[6],
[7],
[8],
[9]])
y
array([[ 1],
[ 3],
[ 5],
[ 7],
[ 9],
[11],
[13],
[15],
[17],
[19]])
Model declaration, fit (training), predict (prediction)
model = LinearRegression()
model
LinearRegression()
model.fit(x, y)
LinearRegression()
prediction = model.predict([[10.0]])
prediction
array([[21.]])
댓글남기기