Warning: Declaration of action_plugin_tablewidth::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/tablewidth/action.php on line 93
code:cross_validation [CS545 fall 2016]

User Tools

Site Tools


code:cross_validation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

code:cross_validation [2016/09/20 14:17]
asa created
code:cross_validation [2016/09/22 18:44] (current)
asa
Line 40: Line 40:
             converged = True             converged = True
             for i in range(len(X)) :             for i in range(len(X)) :
-                if y[i] * self.discriminant(X[i]) <= 0 :+                if y[i] * self.decision_function(X[i]) <= 0 :
                     self.w = self.w + y[i] * self.learning_rate * X[i]                     self.w = self.w + y[i] * self.learning_rate * X[i]
                     converged = False                     converged = False
Line 48: Line 48:
             print ('​converged in %d iterations ' % iterations)             print ('​converged in %d iterations ' % iterations)
  
-    def discriminant(self, ​x) : +    def decision_function(self, ​X) : 
-        return np.inner(self.w, ​x)+        return np.inner(self.w, ​X)
  
     def predict(self,​ X) :     def predict(self,​ X) :
Line 63: Line 63:
         scores = np.inner(self.w,​ X)         scores = np.inner(self.w,​ X)
         return np.sign(scores)         return np.sign(scores)
 +
 +
 +if __name__=='​__main__'​ :
 +    X,y,w = generate_separable_data(40)
 +    p = Perceptron()
 +    p.fit(X,y)
  
 </​file>​ </​file>​
code/cross_validation.txt · Last modified: 2016/09/22 18:44 by asa