Giter Club home page Giter Club logo

Comments (8)

sabya786 avatar sabya786 commented on July 16, 2024 6

Hi,
Take the utilities.py from chapter-2 code and put in your python 35 lib
and import it

from artificial-intelligence-with-python.

asghar3166 avatar asghar3166 commented on July 16, 2024

Hi,
Use (from pkgutil import extend_path) and run the code. It should work!

from artificial-intelligence-with-python.

asghar3166 avatar asghar3166 commented on July 16, 2024

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')

Output
decision_tree_chp_3

from artificial-intelligence-with-python.

 avatar commented on July 16, 2024

which code of chapter 2 please explain or give the code @sabya786

from artificial-intelligence-with-python.

diemgomez avatar diemgomez commented on July 16, 2024

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.

karant17 avatar karant17 commented on July 16, 2024

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.

GeniusMehra avatar GeniusMehra commented on July 16, 2024

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.

pr0steg avatar pr0steg commented on July 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.