Data Analysis With Pandas Tutorial 16 Breast Cancer Diagnostics Challenge

by: Barthordijk11, 8 years ago


When I execute the code found in the hints, I obtain the following error:

DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
  DeprecationWarning)

When I then apply the advocated solution of reshaping, I obtain another error:

ValueError: X and y have incompatible shapes.
X has 5592 samples, but y has 699.

I feel like I'm missing something theoretical behind this error, probably something to do with multiplying matrices. The error can come from a whole different source though, not really sure. Does anyone have any ideas about:

* How to correctly solve this challenge now
* (if possible) some deeper, theoretical ideas about where things go wrong

The first question is most relevant, the second is more of a bonus. Any help is much appreciated:)

from sklearn import svm
import pandas as pd

df = pd.read_csv('breast-cancer-wisconsin.data.txt',
                 names=['sample_code_num',
                       'clump_thickness',
                       'Uniformity of Cell Size',
                       'Uniformity of Cell Shape',
                       'Marginal Adhesion',
                       'Single Epithelial Cell Size',
                       'Bare Nuclei',
                        'Bland Chromatin',
                       'Normal Nucleoli,Mitoses',
                       'Class'])


y = df['Class'].values.tolist()
X = df.drop('Class', 1)._get_numeric_data().values.tolist()

clf = svm.SVC()
clf.fit(X, y)


# malignant tumor.
print(clf.predict([8,7,5,10,7,9,5,5]))




You must be logged in to post. Please login or register an account.



Check out:

https://pythonprogramming.net/k-nearest-neighbors-application-machine-learning-tutorial/?

Near the end, you can do a control+f for "deprecation warning."

We cover specifically how to handle for this reshaping there.

-Harrison 8 years ago

You must be logged in to post. Please login or register an account.