Ejemplo n.º 1
0
 def cal_membership(self, X, y):
     if self.membership == 'SVDD':
         W = membership.SVDD_membership(X,
                                        y,
                                        g=self.gamma,
                                        C=self.nu,
                                        proj=self.proj)
     elif self.membership == 'None':
         W = []
     return W
Ejemplo n.º 2
0
 def cal_membership(self, X, y):
     n_samples = np.shape(X)[0]
     if self.membership == 'SVDD':
         W = membership.SVDD_membership(X,
                                        y,
                                        g=self.gamma,
                                        C=self.nu,
                                        proj=self.proj)
     elif self.membership == 'None':
         W = np.ones((n_samples, 1))
     elif self.membership == 'OCSVM':
         W = membership.OCSVM_membership(X, y, self.gamma)
     elif self.membership == 'IFN_SVDD':
         W = membership.IFN_membership(X, y, self.gamma, self.C, self.alpha)
     return W
Ejemplo n.º 3
0
 def cal_membership(self, X, y):
     n_samples = np.shape(X)[0]
     if self.membership == 'SVDD':
         W = membership.SVDD_membership(X,
                                        y,
                                        g=self.gamma,
                                        C=self.nu,
                                        proj=self.proj)
     elif self.membership == 'SVDD_linear':
         W = membership.SVDD_linear_kernel(X, y, C=self.nu, proj=self.proj)
     elif self.membership == 'None':
         W = np.ones((n_samples, 1))
     elif self.membership == 'OCSVM':
         W = membership.OCSVM_membership(X, y, self.gamma)
     elif self.membership == 'IFN_SVDD':
         W = membership.IFN_membership(X, y, self.gamma, self.C, self.alpha)
     elif self.membership == 'center':
         W = membership.class_center_membership(X, y)
     elif self.membership == 'FSVM_2':
         W = membership.FSVM_2_membership(X, y, self.gamma)
     return W
Ejemplo n.º 4
0
Archivo: test.py Proyecto: hzhou256/py
            X_pos[k] = X[i]
            k = k + 1
    y = np.zeros(n_neg + n_pos)
    for i in range(n_neg):
        y[i] = -1
    for i in range(n_neg, n_neg + n_pos):
        y[i] = 1
    X = np.row_stack((X_neg, X_pos))
    return X, y


dataset = ['australian', 'heart', 'sonar']
name = dataset[2]

f1 = np.loadtxt('E:/Study/Bioinformatics/UCI/' + name + '/data.csv',
                delimiter=',')
X = f1[:, 0:-1]
y = f1[:, -1]

X_train, X_test, y_train, y_test = train_test_split(X,
                                                    y,
                                                    test_size=0.2,
                                                    random_state=0)

X_train, y_train = split(X_train, y_train)

g = 0.5
nu = 0.1
s = membership.SVDD_membership(X_train, y_train, g=g, C=nu)

print(s)