Comments (8)
Hi,
Take the utilities.py from chapter-2 code and put in your python 35 lib
and import it
from artificial-intelligence-with-python.
Hi,
Use (from pkgutil import extend_path) and run the code. It should work!
from artificial-intelligence-with-python.
Building a Decision Tree classifier in Chapter 3
Use the following below imports for "visualize_classifier" to work.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
from sklearn.metrics import classification_report,confusion_matrix
from sklearn.cross_validation import train_test_split
from sklearn.tree import DecisionTreeClassifier
Decision Trees classifier
params = {'random_state': 0, 'max_depth': 4}
classifier = DecisionTreeClassifier(**params)
classifier.fit(X_train, y_train)
visualize_classifier(classifier, X_train, y_train, 'Training dataset')
from artificial-intelligence-with-python.
which code of chapter 2 please explain or give the code @sabya786
from artificial-intelligence-with-python.
Hi, I'm having the same problem and I try what @asghar3166 said, but it did not work. Can some help us please!!
`Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license()" for more information.
import numpy as np
from sklearn import linear_model
import matplotlib.pyplot as plt
from utilities import visualize_classifier
Traceback (most recent call last):
File "<pyshell#3>", line 1, in
from utilities import visualize_classifier
ModuleNotFoundError: No module named 'utilities'
from pkgutil import extend_path
from utilities import visualize_classifier
Traceback (most recent call last):
File "<pyshell#5>", line 1, in
from utilities import visualize_classifier
ModuleNotFoundError: No module named 'utilities'
`
from artificial-intelligence-with-python.
Do use the following code in place of from utilities import visualize_classifier
to achieve the output.
def visualize_classifier(classifier, X, y):
# Define the minimum and maximum values for X and Y
# that will be used in the mesh grid
min_x, max_x = X[:, 0].min() - 1.0, X[:, 0].max() + 1.0
min_y, max_y = X[:, 1].min() - 1.0, X[:, 1].max() + 1.0
Hope this helps you find the solution.
You can find the code block in utilites.py file
from artificial-intelligence-with-python.
You can just remove the line 'utilities import visualize_classifier'. Then it will work fine as we are defining function visualize_classifier later in the code
from artificial-intelligence-with-python.
Apart from downgrading matplotlib to 3.5.3, you can disable File | Settings | Tools | Python Scientific | Show plots in tool window.
from artificial-intelligence-with-python.
Related Issues (20)
- code error
- Chapter 3, Building a Decision Tree Classifier HOT 1
- Ch 4: Building a classifier based on Gaussian Mixture Models HOT 2
- chapter04 stocks.py matplotlib.finance removed
- fit() missing 1 required positional argument: 'y'
- data_multivar_nb.txt file for Naïve Bayes classifier
- G
- true labels and pred labels
- OS error HOT 1
- Incorrect working grid_search. HOT 2
- error with naive_bayes.py HOT 1
- Chapter 3. Random Forest Classifier.
- Running this prime.py script
- python3 not found
- missing preprocessing.py HOT 1
- ch02/income_classifier throws bad_shape error HOT 6
- Chapter 6 - Virginia is not in Costal States HOT 1
- No module named 'utilities' HOT 3
- Artificial-Intelligence-with-Python/Chapter 03/code/traffic_prediction.py HOT 2
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 artificial-intelligence-with-python.