Skip to content

Instantly share code, notes, and snippets.

@joao-timescale
Created November 26, 2017 12:37
Show Gist options
  • Save joao-timescale/0d617b219ffdb13dd980332c0a5b606d to your computer and use it in GitHub Desktop.
Save joao-timescale/0d617b219ffdb13dd980332c0a5b606d to your computer and use it in GitHub Desktop.
KNN Dataset
from sklearn.datasets import load_digits
import matplotlib.pyplot as plt
# Load data set and corresponding labels
digits_data = load_digits()
digits = digits_data.data
labels = digits_data.target
class_names = digits_data.target_names
# Partition data set into training and test data sets
train_data_ratio = 0.75 # test_data_ratio = 1 - train_data_ratio
train_data_idx = int(train_data_ratio * digits.shape[0])
train_data = digits[:train_data_idx]
train_data_labels = labels[:train_data_idx]
test_data = digits[train_data_idx:]
test_data_labels = labels[train_data_idx:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment