我正在尝试使用graphlab创建线性回归模型。我有200个样本和1个预测器。但是我遇到了“数值溢出错误”,这是输出:
model_all = graphlab.linear_regression.create(data2.tail(200), target='output', features=['input'],validation_set=None,l2_penalty=0.0002,solver = 'auto')
Linear regression:
--------------------------------------------------------
Number of examples : 200
Number of features : 1
Number of unpacked features : 1
Number of coefficients : 2
Starting Newton Method
--------------------------------------------------------
+-----------+----------+--------------+--------------------+---------------+
| Iteration | Passes | Elapsed Time | Training-max_error | Training-rmse |
+-----------+----------+--------------+--------------------+---------------+
+-----------+----------+--------------+--------------------+---------------+
TERMINATED: Terminated due to numerical overflow error.
This model may not be ideal. To improve it, consider doing one of the following:
(a) Increasing the regularization.
(b) Standardizing the input data.
(c) Removing highly correlated features.
(d) Removing `inf` and `NaN` values in the training data
提示(b),(c)和(d)不适用于我的情况,因为只有1个特征,并且没有inf或NaN值。我尝试了各种l2_penalty但都没用。如果我将样本的数量限制为较小的数字,例如180,它将起作用。
model_all = graphlab.linear_regression.create(data2.tail(180), target='output', features=['input'],validation_set=None,l2_penalty=0.0002,solver = 'auto')
model_all.get("coefficients").print_rows(num_rows=100)
Linear regression:
--------------------------------------------------------
Number of examples : 180
Number of features : 1
Number of unpacked features : 1
Number of coefficients : 2
Starting Newton Method
--------------------------------------------------------
+-----------+----------+--------------+--------------------+---------------+
| Iteration | Passes | Elapsed Time | Training-max_error | Training-rmse |
+-----------+----------+--------------+--------------------+---------------+
| 1 | 2 | 0.000866 | 9.873043 | 4.272624 |
+-----------+----------+--------------+--------------------+---------------+
SUCCESS: Optimal solution found.
+----------------+-------+------------------+-------------------+
| name | index | value | stderr |
+----------------+-------+------------------+-------------------+
| (intercept) | None | 9.3412783539 | 3.80166353756 |
| DOEDDIST.Index | None | 0.00226165438702 | 0.000975084975224 |
+----------------+-------+------------------+-------------------+
[2 rows x 4 columns]
我不明白导致数字溢出错误的原因。有人可以帮忙解释一下吗?
谢谢。
答案 0 :(得分:0)
我加倍检查了我的数据,确实有一个NaN条目。我的错。
data.dropna(axis = 'index',how = 'any',inplace=True)
解决了这个问题。