<jupyter_start><jupyter_text>A tutorial exercise regarding the use of classification techniques on the Digits dataset.This exercise is used in the [Classification](http://scikit-learn.org/stable/tutorial/statistical_inference/supervised_learning.htmlclf-tut) part of the [Supervised learning: predicting an output variable from high-dimensional observations](http://scikit-learn.org/stable/tutorial/statistical_inference/supervised_learning.htmlsupervised-learning-tut) section of the [A tutorial on statistical-learning for scientific data processing](http://scikit-learn.org/stable/tutorial/statistical_inference/index.htmlstat-learn-tut-index).  New to Plotly?Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).You can set up Plotly to work in [online](https://plot.ly/python/getting-started/initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/start-plotting-online).We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!  Version<jupyter_code>import sklearn
sklearn.__version__<jupyter_output><empty_output><jupyter_text>Imports<jupyter_code>print(__doc__)

from sklearn import datasets, neighbors, linear_model<jupyter_output>Automatically created module for IPython interactive environment<jupyter_text>Calculatons<jupyter_code>digits = datasets.load_digits()
X_digits = digits.data
y_digits = digits.target

n_samples = len(X_digits)

X_train = X_digits[:.9 * n_samples]
y_train = y_digits[:.9 * n_samples]
X_test = X_digits[.9 * n_samples:]
y_test = y_digits[.9 * n_samples:]

knn = neighbors.KNeighborsClassifier()
logistic = linear_model.LogisticRegression()

print('KNN score: %f' % knn.fit(X_train, y_train).score(X_test, y_test))
print('LogisticRegression score: %f'
      % logistic.fit(X_train, y_train).score(X_test, y_test))
from IPython.display import display, HTML

display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))

! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
    'Digits Classification Exercise.ipynb', 'scikit-learn/digits-classification-exercise/', 'Digits Classification Exercise | plotly',
    ' ',
    title = 'Digits Classification Exercise | plotly',
    name = 'Digits Classification Exercise',
    has_thumbnail='true', thumbnail='thumbnail/scikit-default.jpg', 
    language='scikit-learn', page_type='example_index',
    display_as='tutorial_exercises', order=1,
    ipynb= '~Diksha_Gabha/3068')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12749918059652574, 'fraction_numerical': 0.008849557522123894, 'mean_word_length': 6.610972568578553, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '223012', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 1041, 'n_tokens_neox': 974, 'n_words': 183, 'path': '_posts/scikit/digits-classification/Digits Classification Exercise.ipynb', 'repo_name': 'bmb804/documentation', 'size': '3051'}