Create SFrame from Feature Matrix X and Target Vector Y

User 2962 | 1/5/2016, 6:32:57 PM

I have two files with Numpy format I have loaded them using

x=numpy.load("Xname") y=numpy.load("Yname")

x is an array holding the features samples n rows samples and m number of features y is a vector holding the target samples

How can i create SFrame of the data so i can create model e.g. model = gl.classifier.create(data...



User 940 | 1/5/2016, 9:06:59 PM

Hi @didist ,

You can do this simply with the following code

python sf = graphlab.SFrame({'x':x,'y':y})

I hope this helps!

Cheers! -Piotr

User 2962 | 1/6/2016, 4:10:05 PM

It doesn't as far as i see the x is the first feature vector but i have x1 x2 x3...

User 940 | 1/6/2016, 5:56:09 PM


In this case, the 'x' column should be column of array type, which is m wide. You can provide this format directly to the classifier, or if you would like you can go ahead and unpack it.

python sf = sf.unpack('x')

This should result in m feature columns in the SFrame.

Let me know if you have any other questions.

Cheers! -Piotr