https://git.imooc.com/coding-169/coding-169/src/master/06-Gradient-Descent/07-SGD-in-scikit-learn/playML/LinearRegression.py
line86改成: learning_rate(i_iter * i)
使用波士顿房价数据:
data = datasets.load_boston()
X = data.data
y = data.target
X = X[y<50]
y = y[y<50]
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=666)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=666)
standardScaler = StandardScaler()
standardScaler.fit(X_train)
X_train_standard = standardScaler.transform(X_train)
X_test_standard = standardScaler.transform(X_test)
reg = LineRegressor()
reg.fit_sgd(X_train_standard, y_train)
reg.r2_score(X_test_standard, y_test)
计算出来的 r2_score 是负数