Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning using Scipy with Pandas

I'm working with Python 2.7 to test the following example:

# 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)

But the response is:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/basic.py:1018: RuntimeWarning: internal gelsd driver lwork query error, required iwork dimension not returned. This is likely the result of LAPACK bug 0038, fixed in LAPACK 3.2.2 (released July 21, 2010). Falling back to 'gelss' driver. warnings.warn(mesg, RuntimeWarning)

I used Brew and PIP to install Scipy.

How can I fix it?

like image 457
Daniel ORTIZ Avatar asked Apr 21 '17 14:04

Daniel ORTIZ


People also ask

Can you ignore Settingswithcopywarning?

SettingWithCopyWarning is a warning which means that your code may still be functional. However, it's important not to ignore it but instead, understand why it has been raised in the first place. This way it will be much easier for you to adjust your code accordingly so that the warning is no longer raised.

Does pandas include Scipy?

This means that Numpy is required by pandas. Scipy and Matplotlib on the other hand are not required by pandas but they are extremely useful. That's why the Pandas project lists them as "optional dependency". Pandas is a software library written for the Python programming language.

What is SettingWithCopyWarning?

A SettingWithCopyWarning warns the user of a potential bug and should never be ignored even if the program runs as expected. The warning arises when a line of code both gets an item and sets an item. Pandas does not assure whether the get item returns a view or a copy of the dataframe.


1 Answers

This is harmless and can be ignored.

The reason for the warning is just what it says: the default LAPACK which comes on macOS is a little old and SciPy works around a bug it has.

like image 85
ev-br Avatar answered Sep 21 '22 07:09

ev-br