Sheila, ``load_svmlight_file`` gives you a sparse matrix (CSR format) and a numpy array.
You can convert the CSR matrix to a numpy array using:: X_train = X_train.toarray() Please check if X_train.shape == iris.data.shape. Hope this helps! best, Peter 2012/5/30 Sheila the angel <[email protected]>: > Hi all, > I am trying to read libsvm format data 'iris.scale' > (from http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/iris.scale > ) as > > from sklearn.datasets import load_svmlight_file > X_train, y_train = load_svmlight_file('iris.scale') > > I thought this will give same format as > > from sklearn import datasets > iris = datasets.load_iris() > > Though y_train is same format as iris.target but X_train is not in same > format as iris.data !!! > > How can I read a libsvm format file same as datasets.load_iris() > > Thanks > -- > Sheila > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Scikit-learn-general mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/scikit-learn-general > -- Peter Prettenhofer ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Scikit-learn-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
