covartech / PRT

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

prtClassLibSVM doesn't like Singles as the input #42

Closed samkeene closed 8 years ago

samkeene commented 9 years ago

It looks like LibSVM doesn't handle singles as its input, and displays an error, but then the PRT wigs out.

TestDataSet = prtDataGenUnimodal; % Create some test and TrainingDataSet = prtDataGenUnimodal; % training data classifier = prtClassLibSvm; % Create a classifier classifier = classifier.train(TrainingDataSet); % Train classified = run(classifier, TestDataSet); % Test

Gives this error:

Error: label vector and instance matrix must be double Error: label vector and instance matrix must be double Index exceeds matrix dimensions.

Error in prtDataSetInMem/retainObservationData (line 612) self.data = self.data(indices,:);

Error in prtDataSetInMem/retainObservations (line 195) self = self.retainObservationData(indices);

Error in prtDataInterfaceCategoricalTargets/retainLabeled (line 392) obj = obj.retainObservations(retainInd);

Error in prtClassLibSvm/trainAction (line 274) auc = prtScoreAuc(yOut.retainLabeled);

Error in prtAction/train (line 221) self = trainAction(self, ds);

peterTorrione commented 9 years ago

I can't recreate?

TestDataSet = prtDataGenUnimodal; % Create some test and
TrainingDataSet = prtDataGenUnimodal; % training data
classifier = prtClassLibSvm; % Create a classifier
classifier = classifier.train(TrainingDataSet); % Train
classified = run(classifier, TestDataSet); % Test
ghost commented 9 years ago

I tried this, too, and it ran fine. (I'm using an older version of Matlab, and a version of PRT from December of 2014.)

From my Matlab session:

TestDataSet = prtDataGenUnimodal; % Create some test and TrainingDataSet = prtDataGenUnimodal; % training data classifier = prtClassLibSvm; % Create a classifier classifier = classifier.train(TrainingDataSet); % Train classified = run(classifier, TestDataSet); % Test

classified

classified =

prtDataSetClass

Properties: nFeatures: 1 featureInfo: [] data: [400x1 double] targets: [400x1 double] observationInfo: [] nObservations: 400 nTargetDimensions: 1 isLabeled: 1 isEmpty: 0 name: 'prtDataGenUnimodal' description: '' userData: [1x1 struct] nClasses: 2 uniqueClasses: [2x1 double] nObservationsByClass: [2x1 double] classNames: {2x1 cell} isUnary: 0 isBinary: 1 isMary: 0 isZeroOne: 1 hasUnlabeled: 0 nUnlabeled: 0 isFullyUnlabeled: 0

Methods, Superclasses

On Wed, Dec 2, 2015 at 7:50 AM, Peter Torrione notifications@github.com wrote:

I can't recreate?

TestDataSet = prtDataGenUnimodal; % Create some test and TrainingDataSet = prtDataGenUnimodal; % training data classifier = prtClassLibSvm; % Create a classifier classifier = classifier.train(TrainingDataSet); % Train classified = run(classifier, TestDataSet); % Test

— Reply to this email directly or view it on GitHub https://github.com/covartech/PRT/issues/42#issuecomment-161296577.

patrickkwang commented 8 years ago

I too have been unable to recreate this problem. @samkeene Does this still give you an issue? Looking at it, I'm not sure where the singles would have come from since prtDataGenUnimodal produces doubles.