警告使用Scipy with Pandas

时间:2017-04-21 14:11:15

标签: python python-2.7 pandas numpy scipy

我正在使用Python 2.7来测试以下示例:

# importando pandas, numpy y matplotlib
import matplotlib as matplotlib
import scipy as scipy
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# importando los datasets de sklearn
from sklearn import datasets

boston = datasets.load_boston()
boston_df = pd.DataFrame(boston.data, columns=boston.feature_names)
boston_df['TARGET'] = boston.target
boston_df.head() # estructura de nuestro dataset.

from sklearn.linear_model import LinearRegression

rl = LinearRegression() # Creando el modelo.
rl.fit(boston.data, boston.target) # ajustando el modelo
list(zip(boston.feature_names, rl.coef_))

# haciendo las predicciones
predicciones = rl.predict(boston.data)
predicciones_df = pd.DataFrame(predicciones, columns=['Pred'])
predicciones_df.head() # predicciones de las primeras 5 lineas


np.mean(boston.target - predicciones)

但回应是:

  

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/basic.py:1018:   RuntimeWarning:内部gelsd驱动程序lwork查询错误,必需   iwork维度没有返回。这可能是LAPACK错误的结果   0038,修复于LAPACK 3。2。2(2010年7月21日发布)。回到   'gelss'司机。 warnings.warn(mesg,RuntimeWarning)

我使用Brew和PIP安装Scipy。

我该如何解决?

2 个答案:

答案 0 :(得分:11)

这是无害的,可以忽略。

警告的原因就是它所说的:macOS上的默认LAPACK有点老了,SciPy解决了它的错误。

答案 1 :(得分:6)

请尝试以下代码来解决问题:

import warnings

warnings.filterwarnings(action="ignore", module="scipy", message="^internal gelsd")