线性回归预测模型参数调优

请问在用线性回归模型进行预测时,当预测效果不好的时候,通过改变参数来调整模型的预测效果,请问具体应该怎么做呢




```import torch
import torch.nn as nn
from sklearn.linear_model import LinearRegression
loss = torch.nn.MSELoss()
def get_net(feature_num):
    net = nn.Linear(feature_num, 1)
    for param in net.parameters():
        nn.init.normal_(param, mean=0, std=0.01)
    return net
import numpy as np 
import pandas as pd 
import tushare as ts
df = ts.get_hist_data('300936',start='2017-01-01',end='2023-01-01')
df.reset_index(inplace=True)
df.to_csv(u'3.csv',index=False)
print(np.shape(df))
df.head()
df['date'] = pd.to_datetime(df['date'])
df = df.set_index('date')
df.sort_values(by=['date'], inplace=True, ascending=True) 
df.head(10) 
num = 5
df['label'] = df['close'].shift(-num) 
df.dropna(inplace = True)
df = df.apply(
    lambda x: (x - x.mean()) / (x.std()))
X = df.drop(['price_change', 'label', 'p_change'],axis=1)
X = X.values
for x in X:
     lambda x: (x - x.mean()) / (x.std())
y = df.label.values
print(np.shape(X), np.shape(y))
X_train, y_train = X[0:370, :], y[0:370]
X_test, y_test = X[370:529, :], y[370:529]
print(X_train.shape)
print(y_train.shape)
print(X_test.shape)
print(y_test.shape)lr = LinearRegression()
lr.fit(X_train, y_train)
lr.score(X_test, y_test)
R2 = lr.score(X_test, y_test)
- 
print('R^2:', R2)}




```

尝试调整模型的超参数,如正则化系数等;
也可以使用网格搜索或随机搜索等方法进行超参数调优;
或者尝试其他回归方法,如支持向量回归。