Ejemplo n.º 1
0
    X_train_features = np.column_stack((X_train_features_1_ltr_gmm,X_train_features_1_rtl_gmm,X_train_features_1_ttb_gmm,X_train_features_1_btt_gmm,X_train_features_0_ltr_gmm,X_train_features_0_rtl_gmm,X_train_features_0_btt_gmm,X_train_features_0_ttb_gmm))
    X_test_features = np.column_stack((X_test_features_1_ltr_gmm,X_test_features_1_rtl_gmm,X_test_features_1_ttb_gmm,X_test_features_1_btt_gmm,X_test_features_0_ltr_gmm,X_test_features_0_rtl_gmm,X_test_features_0_btt_gmm,X_test_features_0_ttb_gmm))

    ridge_model = RidgeClassifier().fit(X_train_features, y_train)
    gmm_train_accuracy_ridge[t] = ridge_model.score(X_train_features, y_train)
    gmm_test_accuracy_ridge[t] = ridge_model.score(X_test_features, y_test)

    c = 10
    svm_model = SVC(kernel='rbf', C=c).fit(X_train_features, y_train)
    gmm_train_accuracy_svm[t] = svm_model.score(X_train_features, y_train)
    gmm_test_accuracy_svm[t] = svm_model.score(X_test_features, y_test)

    ### Persistence images
    p = [15,15]
    s = 1
    X_train_features_0_ltr_imgs, X_test_features_0_ltr_imgs = persistence_image_features(zero_dim_ltr_train, zero_dim_ltr_test, pixels=p, spread=s)
    X_train_features_0_rtl_imgs, X_test_features_0_rtl_imgs = persistence_image_features(zero_dim_rtl_train, zero_dim_rtl_test, pixels=p, spread=s)
    X_train_features_0_ttb_imgs, X_test_features_0_ttb_imgs = persistence_image_features(zero_dim_ttb_train, zero_dim_ttb_test, pixels=p, spread=s)
    X_train_features_0_btt_imgs, X_test_features_0_btt_imgs = persistence_image_features(zero_dim_btt_train, zero_dim_btt_test, pixels=p, spread=s)

    X_train_features_1_ltr_imgs, X_test_features_1_ltr_imgs = persistence_image_features(one_dim_ltr_train, one_dim_ltr_test, pixels=p, spread=s)
    X_train_features_1_rtl_imgs, X_test_features_1_rtl_imgs = persistence_image_features(one_dim_rtl_train, one_dim_rtl_test, pixels=p, spread=s)
    X_train_features_1_ttb_imgs, X_test_features_1_ttb_imgs = persistence_image_features(one_dim_ttb_train, one_dim_ttb_test, pixels=p, spread=s)
    X_train_features_1_btt_imgs, X_test_features_1_btt_imgs = persistence_image_features(one_dim_btt_train, one_dim_btt_test, pixels=p, spread=s)
    
    X_train_features = np.column_stack((X_train_features_1_ltr_imgs,X_train_features_1_rtl_imgs,X_train_features_1_ttb_imgs,X_train_features_1_btt_imgs,X_train_features_0_ltr_imgs,X_train_features_0_rtl_imgs,X_train_features_0_btt_imgs,X_train_features_0_ttb_imgs))
    X_test_features = np.column_stack((X_test_features_1_ltr_imgs,X_test_features_1_rtl_imgs,X_test_features_1_ttb_imgs,X_test_features_1_btt_imgs,X_test_features_0_ltr_imgs,X_test_features_0_rtl_imgs,X_test_features_0_btt_imgs,X_test_features_0_ttb_imgs))

    ridge_model = RidgeClassifier().fit(X_train_features, y_train)
    images_train_accuracy_ridge[t] = ridge_model.score(X_train_features, y_train)
    images_test_accuracy_ridge[t] = ridge_model.score(X_test_features, y_test)
Ejemplo n.º 2
0
    gmm_train_accuracy_ridge[k] = ridge_model.score(X_train_features, y_train)
    gmm_test_accuracy_ridge[k] = ridge_model.score(X_test_features, y_test)

    svm_model = SVC(kernel='rbf', C=1).fit(X_train_features, y_train)

    gmm_train_accuracy_svm[k] = svm_model.score(X_train_features, y_train)
    gmm_test_accuracy_svm[k] = svm_model.score(X_test_features, y_test)

    ### Persistence Images

    pixels = [[15, 15], [20, 20]]
    spread = [.5, 1]
    i = 1
    j = 1
    X_train_features_R0_imgs, X_test_features_R0_imgs = persistence_image_features(
        R0_train_sample, R0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_G0_imgs, X_test_features_G0_imgs = persistence_image_features(
        G0_train_sample, G0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_B0_imgs, X_test_features_B0_imgs = persistence_image_features(
        B0_train_sample, B0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_X0_imgs, X_test_features_X0_imgs = persistence_image_features(
        X0_train_sample, X0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_Y0_imgs, X_test_features_Y0_imgs = persistence_image_features(
        Y0_train_sample, Y0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_Z0_imgs, X_test_features_Z0_imgs = persistence_image_features(
        Z0_train_sample, Z0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_H0_imgs, X_test_features_H0_imgs = persistence_image_features(
        H0_train_sample, H0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_S0_imgs, X_test_features_S0_imgs = persistence_image_features(
        S0_train_sample, S0_test_sample, pixels=pixels[i], spread=spread[j])
    X_train_features_V0_imgs, X_test_features_V0_imgs = persistence_image_features(
Ejemplo n.º 3
0
    X_test_features = np.column_stack(
        (X_test_features_0_gmm, X_test_features_1_gmm))

    ridge_model = RidgeClassifier().fit(X_train_features, y_train)
    gmm_train_accuracy_ridge[k] = ridge_model.score(X_train_features, y_train)
    gmm_test_accuracy_ridge[k] = ridge_model.score(X_test_features, y_test)

    c = 1
    svm_model = SVC(kernel='rbf', C=c).fit(X_train_features, y_train)
    gmm_train_accuracy_svm[k] = svm_model.score(X_train_features, y_train)
    gmm_test_accuracy_svm[k] = svm_model.score(X_test_features, y_test)

    ### Persistence images
    pixels = [20, 20]
    spread = 1
    X_train_features_1_imgs, X_test_features_1_imgs = persistence_image_features(
        X_dgm1_train, X_dgm1_test, pixels=pixels, spread=1)
    X_train_features_0_imgs, X_test_features_0_imgs = persistence_image_features(
        X_dgm0_train, X_dgm0_test, pixels=pixels, spread=1)
    X_train_features = np.column_stack(
        (X_train_features_1_imgs, X_train_features_0_imgs))
    X_test_features = np.column_stack(
        (X_test_features_1_imgs, X_test_features_0_imgs))

    ridge_model = RidgeClassifier().fit(X_train_features, y_train)
    images_train_accuracy_ridge[k] = ridge_model.score(X_train_features,
                                                       y_train)
    images_test_accuracy_ridge[k] = ridge_model.score(X_test_features, y_test)

    c = 1
    svm_model = SVC(kernel='rbf', C=c).fit(X_train_features, y_train)
    images_train_accuracy_svm[k] = svm_model.score(X_train_features, y_train)