Пример #1
0
def get_shaped_data(boxer="Virginia"):
    lX, lY, tX, tY = load_testsplit_dataset(boxer,
                                            as_onehot=True,
                                            optimalish=True)
    # print(f"X shape: {lX.shape[1:]}")
    # print(f"Y shape: {lY.shape[1:]}")
    # print(f"N learning:", len(lX))
    # print(f"N testing ({boxer}):", len(tX))
    return lX, lY, tX, tY
Пример #2
0
def load(boxer):
    def resplit(x):
        ax, ay, az = x.T
        return as_matrix(np.concatenate((ax.T + az.T, np.abs(ay.T)), axis=-1))

    lX, lY, tX, tY = load_testsplit_dataset(boxer,
                                            as_matrix=False,
                                            as_string=True)
    lX, tX = map(resplit, (lX, tX))
    return lX, lY, tX, tY
Пример #3
0
def advanced_testing():
    for name in boxer_names:
        print("-" * 50)
        print("Split evaluation on excluded sample:", name)
        lX, lY, tX, tY = load_testsplit_dataset(name,
                                                as_onehot=True,
                                                as_matrix=True,
                                                optimalish=True)
        bycat_acc = split_experiment((lX, lY), (tX, tY), plot=False, verbose=0)
        for cat in range(3):
            print(f"{labels[cat]}: {bycat_acc[cat]:.2%}")
        print(f"ALL: {bycat_acc['ALL']:.2%}")
Пример #4
0
def basic_testing(boxer="Bela"):
    lX, lY, tX, tY = load_testsplit_dataset(boxer,
                                            as_matrix=True,
                                            as_onehot=True,
                                            optimalish=True)
    split_experiment(learn_on_me=(lX, lY), test_on_me=(tX, tY))
Пример #5
0
import numpy as np
from matplotlib import pyplot as plt
from sklearn.neighbors import KNeighborsClassifier as KNN

from EBH.utility.operation import load_testsplit_dataset, shuffle


def salt_data(X1, Y1, X2, Y2, ratio):
    salt = int(len(X2) * ratio)
    X2, Y2 = shuffle(X2, Y2)
    return np.r_[X1, X2[:salt]], np.r_[Y1, Y2[:salt]], X2[salt:], Y2[salt:]


data = load_testsplit_dataset("Virginia", as_matrix=True, as_string=True)
curveX, curveY = [], []
for r in np.arange(0.00, 1., 0.01):
    lX, lY, tX, tY = salt_data(*data, ratio=r)
    knn = KNN().fit(lX, lY)
    curveX.append(len(data[2]) - len(tY))
    curveY.append((knn.predict(tX) == tY).mean())
    print(f"KNN vs {curveX[-1]:>4} salted data: {curveY[-1]:.2%}")

plt.plot(curveX, curveY)
plt.grid()
plt.show()