Giter VIP home page Giter VIP logo

getting-better-at-digits's Introduction

Getting better at digits

The Setting

Let us put together the code we had used in the class for image classification using digits.

import matplotlib.pyplot as plt
from sklearn import datasets, svm, metrics
from sklearn.linear_model import LogisticRegression

digits = datasets.load_digits()
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))

# Create a classifier
classifier = LogisticRegression()

# We learn the digits on the first half of the digits
classifier.fit(data[:n_samples // 2], digits.target[:n_samples // 2])

# Now predict the value of the digit on the second half:
expected = digits.target[n_samples // 2:]
predicted = classifier.predict(data[n_samples // 2:])

print("Accuracy: %s\n" % (metrics.accuracy_score(expected, predicted)))

The accuracy using Logistic Regression is 91.7%.

Problem Statement

Write a function called solution() which

  • accepts the parameters X_train_digits and y_train_digits datasets (available in your environment) for training, and
  • Use SVC algorithm
  • returns the trained model as output

Hint

  • We'll create X_train_digits, y_train_digits, X_test and y_test
  • X_train_digits and y_train_digits will be available in student's environment
  • X_test and y_test will be available to us to evaluate the output from student's function

getting-better-at-digits's People

Contributors

sangamangreg avatar

Watchers

Soumendra Prasad Dhanee avatar James Cloos avatar Suraj Jadhav avatar PradeepJaiswar avatar Mayuresh Suresh Shilotri avatar  avatar Shweta Doshi avatar

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.