def cost(X, y, beta): ''' :params: X: N x D :params: y: D x 1 :params: beta: weights D x 1 ''' return loss.hinge(X, y, beta)
def cost(self, X, y, beta, b): ''' Hinge loss function -------------------- :params: X: feature space :params: y: target :params: beta: weights parameters. ''' return 0.5 * beta.dot(beta) + self.C * np.sum(loss.hinge(X, y, beta, b))
def activation(X, y, beta): ''' :params: X: train data :params: X: weights ''' return 1 if loss.hinge(X, y, beta) > 0 else 0