def test_dim(): # Get Data data_getter = TestDataGetter(10, 9) X = data_getter.get_x_data() y = data_getter.get_y_data() # Shuffle the data and split it spliter = DataSpliter(X, y, 0.5, 0, 0.5) X_train, y_train = spliter.get_training_set() X_test, y_test = spliter.get_testing_set() # Dimensionality Reduction print("LDA") for i in range(1,3): dimred = DimensionReduction(X_train, y_train, X_test, i) X_reduced_train, X_reduced_test = dimred.lda_data() test_GNB(X_reduced_train, y_train, X_reduced_test, y_test, i) print("PCA") for i in range(1,30): dimred = DimensionReduction(X_train, y_train, X_test, i) X_reduced_train, X_reduced_test = dimred.pca_data() test_GNB(X_reduced_train, y_train, X_reduced_test, y_test, i) print("FA") for i in range(1,30): dimred = DimensionReduction(X_train, y_train, X_test, i) X_reduced_train, X_reduced_test = dimred.fa_2D_data() test_GNB(X_reduced_train, y_train, X_reduced_test, y_test, i)
def test_explained_variance_LDA(): # Get Data data_getter = TestDataGetter(5, 4) X = data_getter.get_x_data() y = data_getter.get_y_data() # Shuffle the data and split it spliter = DataSpliter(X, y, 1, 0, 0) X_train, y_train = spliter.get_training_set() # Dimensionality Reduction for i in range(1, 31): reductor = LinearDiscriminantAnalysis(n_components=i).fit(X_train, y_train) print("Dim = %2d: explained variance ratio:" % i, sum(reductor.explained_variance_ratio_))
def main(): # Get Data data_getter = TestDataGetter(5, 4) X = data_getter.get_x_data() y = data_getter.get_y_data() # Shuffle the data and split it spliter = DataSpliter(X, y, 1, 0, 0) X_train, y_train = spliter.get_training_set() # Dimensionality Reduction dimred = DimensionReduction(X_train, y_train, X_train) # Draw LDA Graphs X_lda_2d, _ = dimred.lda_data() plot_gst_clf_scatter_2D(X_lda_2d, y_train, '32-LDA of Three Basic Gestures')
def main(): # Get Data data_getter = TestDataGetter(5, 4) X = data_getter.get_x_data() y = data_getter.get_y_data() # Shuffle the data and split it spliter = DataSpliter(X, y, 0.6, 0, 0.4) X_train, y_train = spliter.get_training_set() X_test, y_test = spliter.get_testing_set() # Dimensionality Reduction dimred = DimensionReduction(X_train, y_train, X_test) X_reduced_train, X_reduced_test = dimred.lda_data() test_GNB(X_reduced_train, y_train, X_reduced_test, y_test)
def main(): # Get Data data_getter = TestDataGetter(10, 9) X = data_getter.get_x_data(used_for="switch") y = data_getter.get_y_data(used_for="switch") # Data Spliter spliter = DataSpliter(X, y, 0.7, 0, 0.3) X_train, y_train = spliter.get_training_set() X_test, y_test = spliter.get_testing_set() # Dimensionality Reduction dimred = DimensionReduction(X_train, y_train, X_test) X_reduced_train, X_reduced_test = dimred.lda_data() # Gaussian Naive Bayes Classifier switch_detector(X_reduced_train, y_train, X_reduced_test, y_test)
def main(): # Get Data data_getter = TestDataGetter(5, 4) X = data_getter.get_x_data() y = data_getter.get_y_data() # Shuffle the data and split it spliter = DataSpliter(X, y, 0.6, 0, 0.4) X_train, y_train = spliter.get_training_set() X_test, y_test = spliter.get_testing_set() # Dimensionality Reduction dimred = DimensionReduction(X_train, y_train, X_test) X_reduced_trian, X_reduced_test = dimred.lda_data() # K-NN Tester # X_test, y_test = spliter.get_testing_set() # test_err = test_kNN(X_reduced_trian, y_train, X_reduced_test, y_test, 13) # print("Final Test Error: ", test_err) # K-NN Ploter plot_kNN(X_reduced_trian, y_train)