Performance Measurements: OPF Classification

This test page uses this performance test function.

Instructions to include your function

  1. Create a list in format [author, function_name, url, function, pre_function, pos_function], where:
    • author, string, is a text to identify the function author
    • function_name, string, is a text to identify which function
    • url, string, optional, is function page path
    • function, a python function, 1 argument, is the function to be tested
    • pre_function, a python function, 1 argument, optional, is a function for input data adaptation
    • pos_function, a python function, 1 argument, optional, is a function for output data adaptation
  2. Append the function_set list created in the previous step to functions list (see next section)

Functions to be tested

Put your function set in the list functions.

The input data is a tuple in the format (train_features, train_labels, test_features, distance_function).

Toolbox iaOPF

 1 import Ex09 as ex
 2 
 3 functions = []
 4 
 5 def iaclassify(train, train_labels, test, fdist):
 6     import iaOPF
 7 
 8     opf_pc, _, opf_labels = iaOPF.iafit(train, train_labels, fdist)
 9     predicted = iaOPF.iapredict(test, train, opf_pc, opf_labels, fdist)
10     return predicted
11 
12 def compareResults(params):
13     import iaOPF
14 
15     predicted = params[0]
16     expectedResult = params[1]
17     groundTruth = params[2]['labels']
18     confusionMatrix = iaOPF.iaconfmtx(groundTruth, predicted)
19     resultCorrect = (confusionMatrix==expectedResult).all()
20     return 'Result correct?%s'%(resultCorrect)
21 
22 function_set = ['iaOPF', 'iaclassity()', 'and_classification_test', lambda x: iaclassify(x[0],x[1],x[2],x[3]), None, compareResults]
23 functions.append(function_set)

André

1 import and_9 as an
2 
3 function_set = ['Andre', 'classity()', 'and_9', lambda x: an.classify(x[2],x[0],x[1],x[3]), None, compareResults]
4 functions.append(function_set)

Roberto

1 import rob_biblio2 as rob
2 
3 function_set = ['Roberto', 'iaCLASSIFY()', 'rob_biblio2', lambda x: rob.iaCLASSIFY(x[2],x[0],x[1]), None, compareResults]
4 functions.append(function_set)

Wesley

1 import wes_lib_opf as wes_opf
2 
3 function_set = ['Wesley', 'Classificador()', 'wes_9', lambda x: wes_opf.Classificador(x[0],x[1],x[2]), None, compareResults]
4 functions.append(function_set)

Fernanda

1 def ferclassify(train, train_labels, test):
2     import fer_lib as fer
3 
4     opf_pc, opf_labels = fer.fit(train, train_labels)
5     predicted = fer.predict(train, test, opf_pc, opf_labels)
6     return predicted
7 
8 function_set = ['Fernanda', 'Classificador()', 'fer_9', lambda x: ferclassify(x[0],x[1],x[2]), None, compareResults]
9 functions.append(function_set)

Tiago

1 def tiaClassify(trainData, trainLabels, testData):
2     import tia_libGraph as tia
3 
4     opfCosts = tia.tiaFit(trainData, trainLabels)
5     labelsPredicted = array([tia.tiaPredict(trainData,opfCosts,testData[i],trainLabels) for i in range(len(testData))])
6     return labelsPredicted
7 
8 function_set = ['Tiago', 'tiaClassify()', 'tia_9', lambda x: tiaClassify(x[0],x[1],x[2]), None, compareResults]
9 functions.append(function_set)

Francisco

1 def fraclassify(train_feat, train_labels, test_feat):
2     import fra_lib_opf as fra
3 
4     OPF_costs, OPF_labels = fra.fitOPF(train_feat, train_labels)
5     L = fra.predOPF(test_feat, train_feat, OPF_costs, OPF_labels)
6     return transpose(L).reshape(L.shape[0])
7 
8 function_set = ['Francisco', 'Classificador()', 'fra_9', lambda x: fraclassify(x[0],x[1],x[2]), None, compareResults]
9 functions.append(function_set)

Thiago

1 def thiclassify(train, train_labels, test):
2     import thi_lib as thi
3 
4     opf_pc, opf_labels,_,_ = thi.fit(train, train_labels)
5     predicted = thi.predict(opf_pc, opf_labels, train, test)
6     return predicted
7 
8 function_set = ['Thiago', 'Classificador()', 'thi_lib_5', lambda x: thiclassify(x[0],x[1],x[2]), None, compareResults]
9 functions.append(function_set)

Eric

1 import eri_lib as eri
2 
3 function_set = ['Eric', 'classify()', 'eri_9', lambda x: eri.classify(x[2],x[0],x[1]), None, compareResults]
4 functions.append(function_set)

Wendell

 1 import wen_lib as w
 2 
 3 def wenClassify(train, train_labels, test):
 4     print train
 5     print train_labels
 6     print test
 7     opf, opf_labels = w.fit(train, train_labels)
 8     print opf
 9     print opf_labels
10     predicted = w.predict(test, train, opf, opf_labels)
11     return predicted
12 function_set = ['Wendell', 'wenClassify', 'wen_9', lambda x: wenClassify(x[0],x[1],x[2]), None, compareResults]
13 functions.append(function_set)

List of tests

 1 import iaOPF
 2 from multiprocessing import Queue
 3 
 4 tests = []
 5 
 6 predicted = iaclassify(ex.iris_feats_train, ex.iris_labels_train, ex.iris_feats_test, ex.euclidean)
 7 expectedResult = iaOPF.iaconfmtx(ex.iris_labels_test, predicted)
 8 print 'Expected confusion matrix for Iris dataset:\n\n', expectedResult, '\n\n\n'
 9 
10 test_set = ['Iris', (ex.iris_feats_train, ex.iris_labels_train, ex.iris_feats_test, ex.euclidean), \
11     expectedResult, None, {'labels': ex.iris_labels_test}]
12 tests.append(test_set)
13 
14 predicted = iaclassify(ex.digi_feats_train, ex.digi_labels_train, ex.digi_feats_test, ex.euclidean)
15 expectedResult = iaOPF.iaconfmtx(ex.digi_labels_test, predicted)
16 print 'Expected confusion matrix for Digits dataset:\n\n', expectedResult
17 
18 test_set = ['Digits', (ex.digi_feats_train, ex.digi_labels_train, ex.digi_feats_test, ex.euclidean), \
19     expectedResult, None, {'labels': ex.digi_labels_test}]
20 tests.append(test_set)
Expected confusion matrix for Iris dataset:

[[ 25.   0.   0.]
 [  0.  23.   1.]
 [  0.   2.  24.]] 



Expected confusion matrix for Digits dataset:

[[ 84.   0.   0.   0.   0.   0.]
 [  0.  95.   0.   0.   0.   0.]
 [  0.   0.  95.   1.   0.   0.]
 [  0.   0.   0.  87.   0.   0.]
 [  0.   3.   0.   0.  87.   0.]
 [  0.   0.   0.   0.   0.  90.]]

Test results

Author Function Iris Digits
time(s) result time(s) result
iaOPF iaclassity() 0.874671 Result correct?True 56.548395 Result correct?True
Andre classity() 1.795808 Result correct?True 73.754136 Result correct?True
Roberto iaCLASSIFY() 3.380503 Result correct?True TIMEOUT None
Wesley Classificador() 0.540570 Result correct?True 71.404860 Result correct?True
Fernanda Classificador() 1.540456 Result correct?True TIMEOUT None
Tiago tiaClassify() 7.114401 Result correct?True TIMEOUT None
Francisco Classificador() 7.260956 Result correct?True TIMEOUT None
Thiago Classificador() ERROR None TIMEOUT None
Eric classify() 1.503997 Result correct?True 93.402194 Result correct?True
Wendell wenClassify ERROR None ERROR None