Example #1
0
 def learn(self, Xtrain, ytrain):
     self.features = Xtrain.shape[1]
     if not self.usecolumnones:
         self.features -= 1
         Xtrain = Xtrain[:,0:self.features]
     zeroindex = ytrain == 0
     self.priozero = float(sum(zeroindex)/Xtrain.shape[0])
     self.prioone = 1 - self.priozero
     classzero = Xtrain[zeroindex,:]
     classone = Xtrain[-zeroindex,:]
     self.meanstdev = np.empty((2,2,self.features))
     for f in xrange(self.features):
         data = classzero[:,f]
         self.meanstdev[0,0,f] = utils.mean(data)
         self.meanstdev[0,1,f] = utils.stdev(data)
         data = classone[:,f]
         self.meanstdev[1,0,f] = utils.mean(data)
         self.meanstdev[1,1,f] = utils.stdev(data)
 def learn(self, Xtrain, ytrain):
     # Separate by class
     separated = {}
     for tt in range(Xtrain.shape[0]):
         inputv = Xtrain[tt]
         outputy = ytrain[tt]
         if outputy not in separated:
             separated[outputy] = []
         separated[outputy].append(inputv)
     for classValue, instances in separated.iteritems():
         summ = [(utils.mean(attribute), utils.stdev(attribute)) for attribute in zip(*instances)]
         del summ[-1]
         self.summaries[classValue] = summ
    def divide(self,ds):
	dividedDS = [(utils.mean(x), utils.stdev(x)) for x in zip(*ds)]
	del dividedDS[-1]
	return dividedDS
Example #4
0
 def end_game(self):
     self.mean_a = mean(self.a1)
     self.mean_a2 = mean(self.a2)
     self.mean_t1 = mean(self.time1)
     self.mean_t2 = mean(self.time2)
     self.mean_tC = mean(self.trap_body_c)