【问题标题】:What to do next after predicting y?预测 y 后下一步该做什么?
【发布时间】:2018-09-11 09:57:33
【问题描述】:

我已经对数据集进行了预处理,并检查了自变量可能存在的多重共线性。

数据集有 6 列 31 行,我用来生成 1/3 作为 X_test 和 y_test,剩下的是 X_train 和 y_train。

我使用 sklearn.linear_model LinearRegression 函数将 X_train 和 y_train 拟合到回归量,并使用 X_test 的 predict 函数得到 y 的预测值。

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('daily_raw_status.csv')
X = dataset.iloc[:, :-1].values # IVs
y = dataset.iloc[:, 6].values # DV

# Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 1/3, random_state = 0)

# Fitting MLR to the Training Set
from sklearn.linear_model import LinearRegression
regressor = LinearRegression() # create object
regressor.fit(X_train, y_train) # using fit method, fit the multiple regressor to training set

# Predicting the Test set results
y_pred = regressor.predict(X_test)
Now that I have the y_pred, I can now check the y_pred to the y_test if it's nearly the same.

问题是:

我还能用 y_pred 做什么,或者在解释模型时我应该把重点放在哪里?以及关于如何将模型重新用于可能的实时数据集的任何想法/概念?

【问题讨论】:

    标签: machine-learning regression linear-regression


    【解决方案1】:

    解释回归模型的一个非常典型的步骤是方差分析。这种常见的分析类型允许您评估您的整体模型显着性、系数的显着性和大小、R² 等。有关使用“statsmodels”包的示例,请参阅ANOVA example。 Statsmodels 通常提供更多工具来解释和评估回归模型。

    要查看您的模型是否适合预测,您可能需要检查预测质量是否符合您的目的。这可以包括

    • 寻找合适的指标
    • 比较训练集和测试集的性能
    • 检查值的范围

    从实际角度来看,绘制预测值和实际值通常很有用,以了解您的预测质量。

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 2019-04-15
        • 1970-01-01
        • 2016-08-26
        • 2018-02-01
        • 1970-01-01
        • 2014-02-28
        • 2020-08-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多