Dan*_*TIZ 5 python numpy scipy python-2.7 pandas
我正在使用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)
Run Code Online (Sandbox Code Playgroud)
但回应是:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/basic.py:1018:RuntimeWarning:内部gelsd驱动程序lwork查询错误,未返回所需的iwork维度.这很可能是LAPACK bug 0038的结果,修复了LAPACK 3.2.2(2010年7月21日发布).回到'gelss'司机.warnings.warn(mesg,RuntimeWarning)
我使用Brew和PIP来安装Scipy.
我该如何解决?
ev-*_*-br 11
这是无害的,可以忽略.
警告的原因正是它所说的:macOS上的默认LAPACK有点旧,SciPy可以解决它所遇到的错误.
小智 6
请尝试以下代码来解决问题:
import warnings
warnings.filterwarnings(action="ignore", module="scipy", message="^internal gelsd")
Run Code Online (Sandbox Code Playgroud)