I am a new user of PyML in Python. Using the tutorial, I did the following:
from PyML import *
data = SparseDataSet("heart")
s = SVM()
s.train(data)
r = s.cv(data,5)
I got the resultset r
, but I don't understand how to use this resultset to classify a totally new instance with Python. Can anyone more experienced help me? Any suggestions will be appreciated.
Thanks.
In r = s.sv(data,5)
you are doing crossvalidation, which is used to measure classifier performance by training and testing 5 times on different parts of the dataset. This is not necessary when your objective is to classify new instances.
To classify new instances, you should preferably have these in a different dataset and use the test method of the SVM object after training:
s = SVM()
s.train(trainingDataset)
r = s.test(testDataset)
You will then have the results from classifying new instances in testDataset.
An option to using s.test()
is to use s.classify(data, i)
and s.decisionFunc(data, i)
for classifying individual data points after training, but this is not recommended in the tutorial documentation as you will not get the extra result information contained in a result object (like you get from s.test
, s.cv
or s.stratifiedCV
methods).