Exemple #1
0
 def __call__(self, clf, t):
     alpha1 = clf.l1_ratio * clf.alpha
     alpha2 = (1 - clf.l1_ratio) * clf.alpha
     _proj_elastic_all(clf.eta, t, clf.g_sum_[0], clf.g_norms_[0],
                       alpha1, alpha2, 0, clf.coef_[0])
     score = clf.score(self.X, self.y)
     self.acc.append(score)
Exemple #2
0
 def __call__(self, clf, t):
     alpha1 = clf.l1_ratio * clf.alpha
     alpha2 = (1 - clf.l1_ratio) * clf.alpha
     _proj_elastic_all(clf.eta, t, clf.g_sum_[0], clf.g_norms_[0],
                       alpha1, alpha2, 0, clf.coef_[0])
     score = clf.score(self.X, self.y)
     self.acc.append(score)
    def __call__(self, clf, t=None):
        test_time = time.clock()

        if hasattr(clf, "_finalize_coef"):
            clf._finalize_coef()

        if t is not None:
            _proj_elastic_all(clf.eta, t, clf.g_sum_[0], clf.g_norms_[0],
                              alpha1=0, alpha2=clf.alpha, delta=0,
                              w=clf.coef_[0])


        y_pred = clf.decision_function(self.X).ravel()
        loss = (np.maximum(1 - self.y * y_pred, 0) ** 2).mean()
        coef = clf.coef_.ravel()
        regul = 0.5 * clf.alpha * np.dot(coef, coef)
        self.obj.append(loss + regul)
        self.test_time += time.clock() - test_time
        self.times.append(time.clock() -  self.start_time - self.test_time)
    def __call__(self, clf, t=None):
        test_time = time.clock()

        if hasattr(clf, "_finalize_coef"):
            clf._finalize_coef()

        if t is not None:
            _proj_elastic_all(clf.eta, t, clf.g_sum_[0], clf.g_norms_[0],
                              alpha1=0, alpha2=clf.alpha, delta=0,
                              w=clf.coef_[0])


        y_pred = clf.decision_function(self.X).ravel()
        loss = (np.maximum(1 - self.y * y_pred, 0) ** 2).mean()
        coef = clf.coef_.ravel()
        regul = 0.5 * clf.alpha * np.dot(coef, coef)
        self.obj.append(loss + regul)
        self.test_time += time.clock() - test_time
        self.times.append(time.clock() -  self.start_time - self.test_time)