Comments (6)
Am also working thru the scripts in chapter 2 using Jupyter Lab in Windows 11. Tried numerous various but couldn't solve the cmap problem so I rewrote it using scatter3D. This works:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
X_new = np.hstack([X, X[:, 1:] ** 2])
ax = plt.figure().add_subplot(projection='3d')
ax.view_init(elev=-152, azim=-26)
mask = y == 0
ax.scatter3D(X_new[mask, 0], X_new[mask, 1], X_new[mask, 2], c='b', s=60, edgecolor='k')
ax.scatter3D(X_new[~mask, 0], X_new[~mask, 1], X_new[~mask, 2], c='r', marker='^', s=60, edgecolor='k')
ax.set_xlabel("feature0")
ax.set_ylabel("feature1")
ax.set_zlabel("feature1 ** 2")
plt.show()
Script [77] has the same problem. If you run these sequentially in Jupyter do not need the first three lines. This works:
linear_svm_3d = LinearSVC().fit(X_new, y)
coef, intercept = linear_svm_3d.coef_.ravel(), linear_svm_3d.intercept_
ax = plt.figure().add_subplot(projection='3d')
ax.view_init(elev=-152, azim=-26)
xx = np.linspace(X_new[:, 0].min() - 2, X_new[:, 0].max() + 2, 50)
yy = np.linspace(X_new[:, 1].min() - 2, X_new[:, 1].max() + 2, 50)
XX, YY = np.meshgrid(xx, yy)
ZZ = (coef[0] * XX + coef[1] * YY + intercept) / -coef[2]
ax.plot_surface(XX, YY, ZZ, rstride=8, cstride=8, alpha=0.3)
ax.scatter3D(X_new[mask, 0], X_new[mask, 1], X_new[mask, 2], c='b', s=60, edgecolor='k')
ax.scatter3D(X_new[~mask, 0], X_new[~mask, 1], X_new[~mask, 2], c='r', marker='^', s=60, edgecolor='k')
ax.set_xlabel("feature0")
ax.set_ylabel("feature1")
ax.set_zlabel("feature1 ** 2")
from introduction_to_ml_with_python.
Legend thankyou
from introduction_to_ml_with_python.
thx for the solution
from introduction_to_ml_with_python.
from introduction_to_ml_with_python.
from introduction_to_ml_with_python.
you, my friend, hero!
thanks for the solution.
from introduction_to_ml_with_python.
Related Issues (20)
- Bug in plot_cross_val_selection method HOT 3
- Mglearn : Memory(cachedir="cache") HOT 8
- Problem with Boston Housing Data HOT 3
- TypeError: __init__() got an unexpected keyword argument 'cachedir' HOT 3
- Section 2.5 ("Summary and Outlook") seems to be blank HOT 2
- got HTTPError: HTTP Error 403: Forbidden when execute fetch_lfw_people HOT 2
- Different results when using unsupervised learning and faces dataset HOT 1
- ImportError: `load_boston` has been removed from scikit-learn since version 1.2. HOT 3
- ModuleNotFoundError: No module named 'sklearn.externals.six' HOT 1
- ModuleNotFoundError: No module named 'MGLEARN' in Jupyterlab browser version HOT 2
- Intro2MLpython HOT 1
- mglearn error HOT 4
- I was trying to import make_forge from mglearn, it threw Import error about load buston. How does load Boston relate with make_forge? HOT 8
- get_feature_names() -> get_feature_names_out() HOT 4
- New spaCy version requires
- New spaCy version requires "en_core_web_sm" full name instead of just "en"
- Ml - введение в машинное обучение
- mglearn.plots.plot_pca_faces(X_train, X_test, image_shape) HOT 2
- mglearn/load_boston issue HOT 6
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 introduction_to_ml_with_python.