Example #1
0
 def task(self):
     dataset = clust.parse_input(open('adults.txt', 'r'), 1000)
     all_errors = []
     # Generate a random initial assignment
     for clusters in self.CLUSTERS:
         # get the lowest error over three runs
         errors = [
             clust.kmeans(dataset, clusters)[1]
             for i in xrange(self.SAMPLES)
         ]
         error = sorted(errors)[0]
         all_errors.append({"x": clusters, "y": error})
     chart = {
         "chart": {
             "defaultSeriesType": "line"
         },
         "xAxis": {
             "title": {
                 "text": "Clusters"
             },
             "min": 1
         },
         "yAxis": {
             "title": {
                 "text": "Mean Squared Error"
             }
         },
         "title": {
             "text": "K-means Results"
         },
         "series": [{
             "data": all_errors
         }]
     }
     return chart
Example #2
0
 def task(self):
   dataset = clust.parse_input(open('adults.txt', 'r'), 1000)
   all_errors = []
   # Generate a random initial assignment
   for clusters in self.CLUSTERS:
     # get the lowest error over three runs
     errors = [ clust.kmeans(dataset, clusters)[1] for i in xrange(self.SAMPLES) ]
     error = sorted(errors)[0]
     all_errors.append({ "x": clusters, "y": error })
   chart = {"chart": {"defaultSeriesType": "line"},
            "xAxis": {"title": {"text": "Clusters"}, "min": 1 },
            "yAxis": {"title": {"text": "Mean Squared Error"}},
            "title": {"text": "K-means Results"},
            "series": [ {"data": all_errors } ]}
   return chart
Example #3
0
 def get_dataset(self):
     return clust.parse_input(open('adults-small.txt', 'r'), 200)
Example #4
0
 def get_dataset(self):
   return clust.parse_input(open('adults-small.txt', 'r'), 100)
Example #5
0
 def setUp(self):
   self.dataset = clust.parse_input(open('adults.txt', 'r'), 100)
Example #6
0
 def setUp(self):
     self.dataset = clust.parse_input(open('adults.txt', 'r'), 100)