covartech / PRT

Pattern Recognition Toolbox for MATLAB
http://covartech.github.io/
MIT License
145 stars 70 forks source link

Is it possible to set one data set as a training set and another data set as a testing set in classification? #56

Closed Laylan closed 7 years ago

Laylan commented 7 years ago

Hi, I was wondering if it is possible to set one data set as a training set and another data set as a testing set. It is important for me to have this data sets as a separate sets for my project. Anyone could help me? And sorry for my bad English....

patrickkwang commented 7 years ago

Yes. Simply construct two datasets:

dsTrain = prtDataSetClass(X1,y1); % size(X1)=[N,D], size(y1)=[N,1]
dsTest = prtDataSetClass(X2,y2);

Then train and test your classifier as follows:

cls = prtClassFld; % or your favorite classifier
cls_trained = cls.train(dsTrain);
results = cls_trained.run(dsTest);
prtScoreRoc(results)