y_train1 = np.array([1 if i == 1 else 0
                     for i in y_train]).reshape(-1, 1)  #각각의 분류모델 데이터 전처리
y_test1 = np.array([1 if i == 1 else 0 for i in y_test]).reshape(-1, 1)

y_train2 = np.array([1 if i == 2 else 0
                     for i in y_train]).reshape(-1, 1)  #각각의 분류모델 데이터 전처리
y_test2 = np.array([1 if i == 2 else 0 for i in y_test]).reshape(-1, 1)

y_train3 = np.array([1 if i == 3 else 0
                     for i in y_train]).reshape(-1, 1)  #각각의 분류모델 데이터 전처리
y_test3 = np.array([1 if i == 3 else 0 for i in y_test]).reshape(-1, 1)

mylr0 = MyLR([[-1.32069828], [-1.02177506], [-0.64913889],
              [-0.06329356]])  # The flying cities of Venus (0)
mylr0.fit_(x_train, y_train0)
mylr0.alpha = 0.03
mylr0.fit_(x_train, y_train0)
mylr0.alpha = 0.3
mylr0.fit_(x_train, y_train0)

mylr1 = MyLR([[-1.56373886], [-0.58824757], [0.28303058],
              [2.20809316]])  #  United Nations of Earth (1)
mylr1.fit_(x_train, y_train1)
mylr1.alpha = 0.03
mylr1.fit_(x_train, y_train1)
mylr1.alpha = 0.3
mylr1.fit_(x_train, y_train1)

mylr2 = MyLR([[-2.58616195], [0.60780971], [2.8277886],
              [0.32890994]])  # Mars Republic (2)
mylr2.fit_(x_train, y_train2)
Exemplo n.º 2
0
y_test3 = np.array([1 if i == 3 else 0 for i in y_test]).reshape(-1, 1)
theta = np.array([[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]],
                 dtype=float)
mylr0 = MyLR(theta, lambda_=0)  # The flying cities of Venus (0)
mylr1 = MyLR(theta, lambda_=0)  #  United Nations of Earth (1)
mylr2 = MyLR(theta, lambda_=0)  # Mars Republic (2)
mylr3 = MyLR(theta, lambda_=0)  # The Asteroids’ Belt colonies (3).
y_n = []
y_n2 = []
for i in range(10):
    mylr0.thetas = np.array([[-0.38004857], [0.12257596], [-1.13496089],
                             [0.64144711], [0.13721429], [-0.46771826],
                             [-1.18485222], [-0.46742162], [0.03928006],
                             [-0.1718098]])
    mylr0.fit_(x_train_add_poly, y_train0)
    mylr0.alpha = 0.00003
    mylr0.fit_(x_train_add_poly, y_train0)
    mylr0.alpha = 0.00007
    mylr0.fit_(x_train_add_poly, y_train0)
    mylr0.alpha = 0.0001
    mylr0.fit_(x_train_add_poly, y_train0)
    mylr0.lambda_ += 0.1

    mylr1.thetas = np.array([
        [-0.79899142],
        [-0.3785926],
        [1.24131593],
        [1.13327427],
        [-0.73841759],
        [-0.79814797],
        [0.03383971],