예제 #1
0
파일: elm.py 프로젝트: ryukinix/ai-ufc
def eval_classification(X, y, q=20):
    X_train, X_test, y_train, y_test = testing.hold_out(X, y)
    W, M = train(X_train, y_train, q=q, activation=processing.sigmoid)
    D_teste = predict(X_test, W, M, activation=processing.sigmoid)
    y_test = processing.encode_label(y_test)
    y_pred = processing.encode_label(D_teste)
    acc = round(testing.accuracy(y_test, y_pred), ndigits=2)
    return acc
예제 #2
0
def eval_classification(X, y, q=Q):
    X_train, X_test, y_train, y_test = testing.hold_out(X,
                                                        y,
                                                        test_size=TEST_SIZE)
    T, G = train(X_train, y_train, q=q, activation=processing.sigmoid)
    D_teste = predict(X_test, T, G, activation=processing.sigmoid)
    y_test = processing.encode_label(y_test)
    y_pred = processing.encode_label(D_teste)
    acc = round(testing.accuracy(y_test, y_pred), ndigits=2)
    return acc
예제 #3
0
def main():
    X, y = load.iris()
    X_train, X_test, y_train, y_test = testing.hold_out(X, y)
    W = train(X_train, y_train)
    y_pred = predict(X_test, W)
    y_test = processing.encode_label(y_test)
    acc = testing.accuracy(y_test, y_pred)

    print("ACC: {:.2f} %".format(acc * 100))
예제 #4
0
def predict(X, W):
    """Função de predição baseado na memória W da Rede Neural Perceptron.

    X é a matriz de features e não deve conter o bias, pois é
    adicionado nessa função.
    """
    X = processing.add_bias(X)
    u = W.T @ X.T
    return processing.encode_label(u.T)
예제 #5
0
 def score(self, X, y):
     y_pred = self.predict(X)
     y_encoded = processing.encode_label(y_pred)
     return testing.accuracy(y, y_encoded)
예제 #6
0
 def predict(self, X):
     y_pred = predict(X, self.T, self.G, activation=self.activation)
     encoded = processing.encode_label(y_pred).astype(int)
     return encoded