Auutobot15
Auutobot15

Reputation: 47

Method .as_matrix will be removed in a future version. Use .values instead

I'm making a SVM Model to support my machine learning model." Method .as_matrix will be removed in a future version. Use .values instead". error keeps showing up after running my code. what should I do?

I've tried following it's instructions to change it to .values, however, compiler says that TypeError: 'numpy.ndarray' object is not callable

here's the code:

d = pd.read_csv('voice.csv')
d.head()
sns.lmplot('IQR','meanfun', data=d, hue='label',
           palette='Set1', fit_reg=False, scatter_kws={'s': 1})
ERROR --> IQR_meanfun = d[['IQR','meanfun']].as_matrix()
type_label = np.where(d['Type']=='Male', 0, 1)

Upvotes: 1

Views: 2235

Answers (1)

cs95
cs95

Reputation: 402872

TLDR; as_matrix() is a method, values is an attribute.

But both return a 2D array. as_matrix() is straight up deprecated, so using it is out of the question. That just leaves us with values, which is used like this:

IQR_meanfun = d[['IQR','meanfun']].values

(You probably called .values() which manifested as a TypeError.)


If you're running v0.24 or greater, .values is no longer the recommended method for extracting an array from a DataFrame. See the docs, and this answer which goes into this in gory detail.

# Recommended method from v0.24 onwards,
# IQR_meanfun = d[['IQR','meanfun']].to_numpy(copy=True)
# Same as,
IQR_meanfun = d[['IQR','meanfun']].to_numpy()

Upvotes: 3

Related Questions