1515from matplotlib import pylab
1616from sklearn .cluster import KMeans
1717
18+ from utils import DATA_DIR , CHART_DIR
19+
1820seed = 2
1921sp .random .seed (seed ) # to reproduce the data later on
2022
@@ -55,7 +57,7 @@ def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
5557
5658i = 1
5759plot_clustering (x , y , "Vectors" )
58- pylab .savefig (os .path .join (".." , "1400_03_0%i.png" % i ))
60+ pylab .savefig (os .path .join (CHART_DIR , "1400_03_0%i.png" % i ))
5961pylab .clf ()
6062
6163i += 1
@@ -80,7 +82,7 @@ def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
8082c1a , c1b , c1c = km .cluster_centers_
8183pylab .scatter (km .cluster_centers_ [:, 0 ], km .cluster_centers_ [:, 1 ],
8284marker = 'x' , linewidth = 2 , s = 100 , color = 'black' )
83- pylab .savefig (os .path .join (".." , "1400_03_0%i.png" % i ))
85+ pylab .savefig (os .path .join (CHART_DIR , "1400_03_0%i.png" % i ))
8486pylab .clf ()
8587
8688i += 1
@@ -110,7 +112,7 @@ def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
110112pylab .gca ().add_patch (
111113pylab .Arrow (c1c [0 ], c1c [1 ], c2c [0 ] - c1c [0 ], c2c [1 ] - c1c [1 ], width = 0.1 ))
112114
113- pylab .savefig (os .path .join (".." , "1400_03_0%i.png" % i ))
115+ pylab .savefig (os .path .join (CHART_DIR , "1400_03_0%i.png" % i ))
114116pylab .clf ()
115117
116118i += 1
@@ -131,7 +133,7 @@ def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
131133
132134pylab .scatter (km .cluster_centers_ [:, 0 ], km .cluster_centers_ [:, 1 ],
133135marker = 'x' , linewidth = 2 , s = 100 , color = 'black' )
134- pylab .savefig (os .path .join (".." , "1400_03_0%i.png" % i ))
136+ pylab .savefig (os .path .join (CHART_DIR , "1400_03_0%i.png" % i ))
135137pylab .clf ()
136138
137139i += 1
0 commit comments