Giter Club home page Giter Club logo

Comments (2)

deepish avatar deepish commented on May 14, 2024

Hi @Sarwat-Fatima ,
That's the accuracy score which is normalized i.e between the value from 0-1, where 0 means none of the output were accurate and 1 means every prediction was accurate.
You should not be multiplying with number of observations directly. 0.96666667 means 96% of your observations are correctly predicted.

If you want to know how many observations were correctly predicted, just pass normalize=False as show in the example http://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html

accuracy_score(y_true, y_pred, normalize=False)

@justmarkham , This is really a nice piece of tutorial series you have prepared for beginners. Thanks for that.

from scikit-learn-videos.

justmarkham avatar justmarkham commented on May 14, 2024

@Sarwat-Fatima I assume you are asking about the output from this code:

knn = KNeighborsClassifier(n_neighbors=5)
scores = cross_val_score(knn, X, y, cv=10, scoring='accuracy')
print scores
print scores.mean()

In this case, there are 150 response values in the y object. Since this is 10-fold cross-validation, each iteration of cross-validation involves predicting 15 response values. A score of "1" means 15 of 15 were predicted correctly, a score of 0.9333 means 14 of 15 were predicted correctly, etc.

The 0.9666 number is the average of those 10 scores. You can multiply it by 150 and get 145, meaning 145 response values were correctly predicted.

I think you were confused by code in the notebook that showed an example dataset in which there were 25 observations. The relevant data actually had 150 observations.

Hope that helps!

@deepish Thanks for your kind words, I'm glad you like the video series!

from scikit-learn-videos.

Related Issues (11)

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.