Comments (3)
Hi, seth814,
hope we can figure on what's going on here in your case. I think the easiest way would be if you could upload your script (if you are okay with sharing it) so that I can take a look and inspect what's going on inside the plot_decision_regions
function that may cause this behavior on your dataset.
One thing that I could think of may be non-supported input shapes of the numpy arrays "X" and "y" in plot_decision_regions(X, y, classifier, resolution=0.02)
. This decision region plotting functions expects these X
and y
in the shape that scikit-learn works with. E.g., the y-array has to be a 1D integer type array. And X
has to be a 2D
float (or integer) type array.
Would be nice if you could check your input data and let me know what the result of the "print" functions (see below) looks like -- that would be very helpful
Input:
import numpy as np
y = np.array([1, 2, 0, 0, 2])
X = np.array([[1., 2.],
[3., 4.],
[5., 6.],
[8., 9.],
[7., 8.]])
print('y:', y.shape, y.dtype)
print('X:', X.shape, X.dtype)
Output:
y: (5,) int64
X: (5, 2) float64
Above is an example of how the expected shape may look like.
PS: I have a slightly more sophisticated function implemented here: http://rasbt.github.io/mlxtend/user_guide/evaluate/plot_decision_regions/
I am currently a bit busy (at SciPy 2016), but several people asked me about 3D decision spaces recently, which I am going to add soon!
from python-machine-learning-book.
No worries. I'm not in a huge hurry, but I am curious as to what is going on in the function.
I uploaded the data and file under Vertical Abduction in my repo. I tried to upload a zip but it said the format wasn't supported. The shapes and datatypes are both correct so it's probably something else.
from python-machine-learning-book.
About the FutureWarning
, I think that's not an issue here; it comes from the fact that y_train
is a Pandas DataFrame, not a NumPy array. I'd just recommend putting a y_train = y_train.values
into your code.
Hm, about the plot itself, I don't think this is a bug. This is how the decision region of the SVM looks like in this case -- you may want to do some hyperparameter tuning here.
E.g., when I plot the first 2 dimensions of the input data, it kind of looks like this:
plt.scatter(X_train.values[:, 0], X_train.values[:, 1])
So, for a more visually pleasing analysis, you could maybe try a non-linear dimensionality reduction technique (e.g., Kernel SVM or other algorithms for manifold learning that are implemented in scikit-learn: http://scikit-learn.org/stable/modules/manifold.html)
from python-machine-learning-book.
Related Issues (20)
- Machine learning HOT 1
- i need to find somebody who can automate a trading strategy HOT 1
- ch.06(Tuning hyperparameters via grid search) HOT 4
- mlxtend no longer has tf_classifier HOT 3
- ValueError: operands could not be broadcast together with shapes HOT 1
- Chapter 8: Shuffling the DataFrame in newer versions of pandas HOT 1
- ValueError: operands could not be broadcast together with shapes (400,2) (400,)
- AttributeError: 'SGDClassifier' object has no attribute 'max_iter' HOT 1
- Chapter 15: Padding modes figure HOT 1
- Notebook error HOT 2
- IndexError: too many indices for array in CH-5 PCA Plot Code HOT 3
- Python Machine learning
- ValueError: operands could not be broadcast together with shapes (200,) (30000,) HOT 1
- Machine Learning (Python)
- Hello Kaggle! It is a guide for new kaggler
- How to Use the code files HOT 2
- [QUESTION] in ch3.py line 64 HOT 3
- why this is the self.eta*X.T.dot(errors) rather than the -self.eta*X.T.dot(errors) HOT 1
- Graph of curve is misleading HOT 1
- Python machine learning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-machine-learning-book.