Changing 'double' to 'dataset'

16 views (last 30 days)
Mads
Mads on 11 Jan 2013
Hello guys, I'm up for a Multivariate Statistics and Pattern Recognition exam on Monday, and I am in trouble. I'm supposed to start off by doing Leave-one-out cross validation on a dataset I have acquired (<http://archive.ics.uci.edu/ml/datasets/seeds> that one), but I can't even seem to get started.
I believe LOOCV builds a test and a trainingset, and so far I have looked at the 'crossval' and 'cvpartition' classes, but I can't figure out what to feed them.
Additionally, as I've been going through our notes for this class, it seems the simplest code wont work on my dataset, because it is a 'double' instead of a 'dataset' - can someone tell me how to change that?
Thank you for your time.

Answers (4)

Azzi Abdelmalek
Azzi Abdelmalek on 11 Jan 2013
Edited: Azzi Abdelmalek on 11 Jan 2013
x=1:20
out=dataset(x)

Mads
Mads on 11 Jan 2013
Thank you for your time, but I don't understand the answer - don't you just create an empty dataset here?

Peter Perkins
Peter Perkins on 11 Jan 2013
Mads, "doing Leave-one-out cross validation on a dataset" is way too vague to understand what statistical model or method you're trying to cross-validate, but as far as creating a dataset array from a text file, it's a simple call to the constructor:
ds = dataset('File','seeds_dataset.txt','ReadVarNames',false, ...
'VarNames',{'Area' 'Perimeter' 'Compactness' 'Length' 'Width' 'Asymmetry' 'Groove','Variety'})
Of course, it turns out that the file is tab-delimited but has some double tabs in it, which you'll have to clean up in a text editor.
Actually, I can't tell from your description if your problem is that you want to create a dataset array, or if you already have one and want to create a double matrix from it. If the latter is what you need to do, then it's just
x = double(ds)
Hope this helps.

Mads
Mads on 11 Jan 2013
I apologize for the crudeness of my question - it should convey a sense of my current grasp of the subject.
At the moment, I wish to turn my loaded data, which comes up as a double in the Workspace, into a 'dataset', as right now I can't apply stuff like 'struct' or 'seldat', to view the data.
I hadn't noticed the double tabs, I will look into it, thank you.
I have tried the exact method you mention, and get the following error; Error using dataset (line 258) Illegal datatype
And that is where I am stuck now. Thank you for your reply though, I appreciate all the help I can get.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!