import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import argparse
from sklearn.preprocessing import StandardScaler

from sklearn import decomposition
from sklearn import datasets

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-f", "--file", required = True,
    help = "path to the evolution run file")
args = vars(ap.parse_args())

np.random.seed(5)

centers = [[1, 1], [-1, -1], [1, -1]]
iris = datasets.load_iris()

raw = np.genfromtxt(args["file"], delimiter=',', dtype=float)

X = raw[:,7:12]
scaler = StandardScaler()
X = scaler.fit_transform(X)
y = iris.target

fig = plt.figure(1, figsize=(8, 6))
plt.clf()
ax = Axes3D(fig, elev=48, azim=134)

plt.cla()
pca = decomposition.PCA(n_components=3)
pca.fit(X)
X3d = pca.transform(X)

for name, label in [('Setosa', 0), ('Versicolour', 1), ('Virginica', 2)]:
    """
    ax.text3D(X[y == label, 0].mean(),
              X[y == label, 1].mean() + 1.5,
              X[y == label, 2].mean(), name,
              horizontalalignment='center',
              bbox=dict(alpha=.5, edgecolor='w', facecolor='w'))
              """
# Reorder the labels to have colors matching the cluster results
y = np.choose(y, [1, 2, 0]).astype(np.float)
ax.scatter(X3d[:, 0], X3d[:, 1], X3d[:, 2], c=raw[:,30], cmap=plt.cm.spectral)

"""
x_surf = [X[:, 0].min(), X[:, 0].max(),
          X[:, 0].min(), X[:, 0].max()]
y_surf = [X[:, 0].max(), X[:, 0].max(),
          X[:, 0].min(), X[:, 0].min()]
x_surf = np.array(x_surf)
y_surf = np.array(y_surf)
v0 = pca.transform(pca.components_[0])
v0 /= v0[-1]
v1 = pca.transform(pca.components_[1])
v1 /= v1[-1]

ax.w_xaxis.set_ticklabels([])
ax.w_yaxis.set_ticklabels([])
ax.w_zaxis.set_ticklabels([])
"""
plt.show()
a6c016ac4774af00cdd9cdb3ab2bd31df6ee75e3
<mask token>

<mask token>
ap.add_argument('-f', '--file', required=True, help=
    'path to the evolution run file')
<mask token>
np.random.seed(5)
<mask token>
plt.clf()
<mask token>
plt.cla()
<mask token>
pca.fit(X)
<mask token>
for name, label in [('Setosa', 0), ('Versicolour', 1), ('Virginica', 2)]:
    """
    ax.text3D(X[y == label, 0].mean(),
              X[y == label, 1].mean() + 1.5,
              X[y == label, 2].mean(), name,
              horizontalalignment='center',
              bbox=dict(alpha=.5, edgecolor='w', facecolor='w'))
              """
<mask token>
ax.scatter(X3d[:, 0], X3d[:, 1], X3d[:, 2], c=raw[:, 30], cmap=plt.cm.spectral)
<mask token>
plt.show()

<mask token>
ap = argparse.ArgumentParser()
ap.add_argument('-f', '--file', required=True, help=
    'path to the evolution run file')
args = vars(ap.parse_args())
np.random.seed(5)
centers = [[1, 1], [-1, -1], [1, -1]]
iris = datasets.load_iris()
raw = np.genfromtxt(args['file'], delimiter=',', dtype=float)
X = raw[:, 7:12]
scaler = StandardScaler()
X = scaler.fit_transform(X)
y = iris.target
fig = plt.figure(1, figsize=(8, 6))
plt.clf()
ax = Axes3D(fig, elev=48, azim=134)
plt.cla()
pca = decomposition.PCA(n_components=3)
pca.fit(X)
X3d = pca.transform(X)
for name, label in [('Setosa', 0), ('Versicolour', 1), ('Virginica', 2)]:
    """
    ax.text3D(X[y == label, 0].mean(),
              X[y == label, 1].mean() + 1.5,
              X[y == label, 2].mean(), name,
              horizontalalignment='center',
              bbox=dict(alpha=.5, edgecolor='w', facecolor='w'))
              """
y = np.choose(y, [1, 2, 0]).astype(np.float)
ax.scatter(X3d[:, 0], X3d[:, 1], X3d[:, 2], c=raw[:, 30], cmap=plt.cm.spectral)
<mask token>
plt.show()

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import argparse
from sklearn.preprocessing import StandardScaler
from sklearn import decomposition
from sklearn import datasets
ap = argparse.ArgumentParser()
ap.add_argument('-f', '--file', required=True, help=
    'path to the evolution run file')
args = vars(ap.parse_args())
np.random.seed(5)
centers = [[1, 1], [-1, -1], [1, -1]]
iris = datasets.load_iris()
raw = np.genfromtxt(args['file'], delimiter=',', dtype=float)
X = raw[:, 7:12]
scaler = StandardScaler()
X = scaler.fit_transform(X)
y = iris.target
fig = plt.figure(1, figsize=(8, 6))
plt.clf()
ax = Axes3D(fig, elev=48, azim=134)
plt.cla()
pca = decomposition.PCA(n_components=3)
pca.fit(X)
X3d = pca.transform(X)
for name, label in [('Setosa', 0), ('Versicolour', 1), ('Virginica', 2)]:
    """
    ax.text3D(X[y == label, 0].mean(),
              X[y == label, 1].mean() + 1.5,
              X[y == label, 2].mean(), name,
              horizontalalignment='center',
              bbox=dict(alpha=.5, edgecolor='w', facecolor='w'))
              """
y = np.choose(y, [1, 2, 0]).astype(np.float)
ax.scatter(X3d[:, 0], X3d[:, 1], X3d[:, 2], c=raw[:, 30], cmap=plt.cm.spectral)
<mask token>
plt.show()

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import argparse
from sklearn.preprocessing import StandardScaler

from sklearn import decomposition
from sklearn import datasets

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-f", "--file", required = True,
    help = "path to the evolution run file")
args = vars(ap.parse_args())

np.random.seed(5)

centers = [[1, 1], [-1, -1], [1, -1]]
iris = datasets.load_iris()

raw = np.genfromtxt(args["file"], delimiter=',', dtype=float)

X = raw[:,7:12]
scaler = StandardScaler()
X = scaler.fit_transform(X)
y = iris.target

fig = plt.figure(1, figsize=(8, 6))
plt.clf()
ax = Axes3D(fig, elev=48, azim=134)

plt.cla()
pca = decomposition.PCA(n_components=3)
pca.fit(X)
X3d = pca.transform(X)

for name, label in [('Setosa', 0), ('Versicolour', 1), ('Virginica', 2)]:
    """
    ax.text3D(X[y == label, 0].mean(),
              X[y == label, 1].mean() + 1.5,
              X[y == label, 2].mean(), name,
              horizontalalignment='center',
              bbox=dict(alpha=.5, edgecolor='w', facecolor='w'))
              """
# Reorder the labels to have colors matching the cluster results
y = np.choose(y, [1, 2, 0]).astype(np.float)
ax.scatter(X3d[:, 0], X3d[:, 1], X3d[:, 2], c=raw[:,30], cmap=plt.cm.spectral)

"""
x_surf = [X[:, 0].min(), X[:, 0].max(),
          X[:, 0].min(), X[:, 0].max()]
y_surf = [X[:, 0].max(), X[:, 0].max(),
          X[:, 0].min(), X[:, 0].min()]
x_surf = np.array(x_surf)
y_surf = np.array(y_surf)
v0 = pca.transform(pca.components_[0])
v0 /= v0[-1]
v1 = pca.transform(pca.components_[1])
v1 /= v1[-1]

ax.w_xaxis.set_ticklabels([])
ax.w_yaxis.set_ticklabels([])
ax.w_zaxis.set_ticklabels([])
"""
plt.show()