Skip to content

Instantly share code, notes, and snippets.

@celiacintas
Created March 6, 2015 14:37
Show Gist options
  • Save celiacintas/a62f1d7ba3cb989f5b2f to your computer and use it in GitHub Desktop.
Save celiacintas/a62f1d7ba3cb989f5b2f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
from sklearn.metrics import confusion_matrix
def plot_PCA(Xp, y):
"""
"""
# Plot individuals
populations = np.unique(y)
print populations
colors = plt.get_cmap("hsv")
plt.figure(figsize=(10, 4))
hair = np.unique(y)
for i, p in enumerate(hair):
mask = (y == p)
plt.scatter(Xp[mask, 0], Xp[mask, 1],
c=colors(1. * i / 11), label=p)
#plt.xlim([-30, 50])
plt.legend(loc="best")
plt.show()
def plot_confusion_matrix(y_pred, y, title, method=None):
"""
"""
plt.imshow(confusion_matrix(y, y_pred), cmap=plt.cm.binary, interpolation='nearest')
plt.title(title)
plt.colorbar()
plt.xlabel('true value')
plt.ylabel('predicted value')
plt.savefig(title +'_SVM.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment