작성
·
196
0
from sklearn.model_selection import train_test_split
X_train_dataset, X_test, y_train_dataset, y_test = train_test_split(
X_scaled,y, test_size=0.2, random_state=42)
sgd_regressor = SGDRegressor(
eta0=eta0, max_iter=max_iter, warm_start=True, learning_rate="constant")
rmse_val_score = []
rmse_train_score = []
model_list = []
X_train, X_val, y_train, y_val = train_test_split(
X_train_dataset,y_train_dataset, test_size=0.2, random_state=42)
sgd_regressor.fit(X_train,y_train)
for i in range(300):
y_pred = sgd_regressor.predict(X_train)
y_true = y_train
rmse_train_score.append(rmse(y_pred, y_true))
y_pred = sgd_regressor.predict(X_val)
y_true = y_val
rmse_val_score.append(rmse(y_pred, y_true))
model_list.append(sgd_regressor)
coef = sgd_regressor.coef_.copy()
intercept = sgd_regressor.intercept_.copy()
sgd_regressor = SGDRegressor(
eta0=eta0, max_iter=max_iter, warm_start=True, learning_rate="constant")
sgd_regressor.fit(X_train,y_train, coef_init=coef, intercept_init=intercept)
이런식으로 코드를 작성했는데 강의 내용과 그래프가 일치 하지 않습니다. 이미지파일로 올릴라고해도 올려지지가 않네요