Beispiel #1
0
from pyxvis.io.data import load_features
from pyxvis.io.plots import show_clf_results
from pyxvis.learning.classifiers import clf_model, define_classifier
from pyxvis.learning.classifiers import train_classifier, test_classifier

(X, d, Xt,
 dt) = load_features('../data/F2/F2')  # load training and testing data
ss_cl = ['nn(10,)', 'nn(12,6)']

for cl_name in ss_cl:
    (name, params) = clf_model(cl_name)  # function name and parameters
    clf = define_classifier([name, params])  # classifier definition
    clf = train_classifier(clf, X, d)  # classifier training
    d0 = test_classifier(clf, X)  # classification of training
    ds = test_classifier(clf, Xt)  # classification of testing
    show_clf_results(clf, X, d, Xt, dt, d0, ds,
                     cl_name)  # display results and decision lines
Beispiel #2
0
from pyxvis.io.data import load_features
from pyxvis.io.plots import show_confusion_matrix
from pyxvis.learning.classifiers import clf_model, define_classifier
from pyxvis.learning.classifiers import train_classifier, test_classifier

(X, d, Xt,
 dt) = load_features('../data/F2/F2')  # load training and testing data

# Classifier definition
ss_cl = ['dmin', 'svm-rbf(0.1,1)']
n = len(ss_cl)
for k in range(n):
    (name, params) = clf_model(ss_cl[k])  # function name and parameters
    clf = define_classifier([name, params])  # classifier definition
    clf = train_classifier(clf, X, d)  # classifier training
    ds = test_classifier(clf, Xt)  # classification of testing
    show_confusion_matrix(dt, ds, ss_cl[k])  # display confusion matrix
Beispiel #3
0
        (Xv, dv) = init_data(X79[0:50, :], c0)  # Gun
        (Xv, dv) = append_data(X, d, X80[0:50, :], c1)  # Shuriken
        (Xv, dv) = append_data(X, d, X81[0:50, :], c2)  # Blade
        (Xv, dv) = append_data(X, d, X82[0:200, :], c3)  # Other
        # Testing data
        (Xt, dt) = init_data(X79[50:150], c0)  # Gun
        (Xt, dt) = append_data(X, d, X80[50:150, :], c1)  # Shuriken
        (Xt, dt) = append_data(X, d, X81[50:150, :], c2)  # Blade
        (Xt, dt) = append_data(X, d, X82[200:600, :], c3)  # Other

        print('training ' + cl_name + ' for ' + st + ' using ' + model_name +
              ' ...')
        (name, params) = clf_model(cl_name)  # function name and parameters
        clf = define_classifier([name, params])  # classifier definition
        clf = train_classifier(clf, X, d)  # classifier training
        ds_v = test_classifier(clf, Xv)  # clasification of validation
        ds_t = test_classifier(clf, Xt)  # clasification of testing
        print('Results - ' + st + ' (' + cl_name + ') for the detectors:')
        if j < 3:  # detection of three treat objects
            # performance on validation subset
            (pr_v, re_v) = precision_recall(dv, ds_v)
            Q_v = Q_v + np.sqrt(pr_v * re_v)
            print(f'Pr_val   = {pr_v:.4f}')
            print(f'Re_val   = {re_v:.4f}')
            # performance on testing subset
            (pr_t, re_t) = precision_recall(dt, ds_t)
            Q_t = Q_t + np.sqrt(pr_t * re_t)
            print(f'Pr_test  = {pr_t:.4f}')
            print(f'Re_test  = {re_t:.4f}')
        else:
            # summary of three detections