n_hidden = 50
max_iter = 1000

train_index, test_index = p.get_tr_tx_index(y, test_size=0.4)
results = []
X_proj = []
for rho in np.arange(0.1, 1, 0.1):
    start = time.clock()
    instance_emo_elm = EMO_AE_ELM(n_hidden,
                                  sparse_degree=rho,
                                  max_iter=max_iter,
                                  n_pop=100)
    X_projection_emo_elm = instance_emo_elm.fit(X, X).predict(X)
    # instance_emo_elm.save_evo_result('./experimental_results/EMO-ELM-AE-results-KSC-50hidden.npz')
    time_emo_elmae = round(time.clock() - start, 3)
    X_proj.append(X_projection_emo_elm)
    # TODO: calculate accuracy
    X_train, X_test = X_projection_emo_elm[train_index], X_projection_emo_elm[
        test_index]  # [index]
    y_train, y_test = y[train_index], y[test_index]
    elm = BaseELM(500, C=1e8)
    y_predicted = elm.fit(X_train, y_train).predict(X_test)
    acc = accuracy_score(y_test, y_predicted)
    acc_ = round(acc * 100, 2)
    results.append(acc_)
    print('rho:', rho, ' acc:', acc_)
np.savez(
    'F:\Python\EMO_ELM\demo\experimental_results\SalinasA-1000iter-50hidden-sparsity_acc_X_proj_differ-rho.npz',
    X=np.asarray(X_proj),
    acc=np.asarray(results))
Beispiel #2
0
    time_elmae,
    time_selmae,
    # time_ae,
    time_sae,
    # time_emo_elmae
]
# NMSE_list = [Helper.calculate_NMSE(X, X_) for X_ in X_projection_list]
print('------------------------------------')
print('time:', time_list)
print('------------------------------------')
classifiers = [
    KNeighborsClassifier(3),
    #SVC(kernel="linear", C=1e4),
    LinearSVC(),
    DecisionTreeClassifier(max_depth=5),
    BaseELM(500, C=1e5),
    GaussianNB()
]

# baseline_names = ['RP', 'PCA', 'SPCA', 'NMF', 'ELM-AE', 'SELM-AE', 'AE', 'SAE', 'EMO-ELM-AE']
baseline_names = [
    'RP', 'SPCA', 'ELM-AE', 'SELM-AE', 'AE', 'SAE', 'EMO_ELM_f1', 'EMO_ELM_f2',
    'EMO_ELM_best'
]
classifier_names = ['KNN', 'SVM', 'DT', 'ELM', 'NB']
# results = {}
results = []
for i in range(X_projection_list.__len__()):
    print('---------------------------------')
    # print('baseline: ', baseline_names[i])
    X_ = X_projection_list[i]