Thank you guys it makes more sense now.

I slightly changed the code to fit my data ( I have 6 features)

I got then an error message saying :

File "plot_rbf_parameters.py", line 109, in <module>
    Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
  File 
"/Library/Python/2.7/site-packages/scikit_learn-0.13.1-py2.7-macosx-10.8-intel.egg/sklearn/svm/base.py",
 line 365, in decision_function
    X = self._validate_for_predict(X)
  File 
"/Library/Python/2.7/site-packages/scikit_learn-0.13.1-py2.7-macosx-10.8-intel.egg/sklearn/svm/base.py",
 line 412, in _validate_for_predict
    (n_features, self.shape_fit_[1]))
ValueError: X.shape[1] = 2 should be equal to 6, the number of features at 
training time


around that line :

Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])

How can I make X.shape[1]=6 instead of 2

Sorry if that sounds a newbie request

Thanks

Rad

On Mar 8, 2013, at 2:54 PM, Flavio Vinicius <flavio...@gmail.com> wrote:

> Suppose you have
> 
> x = np.array([1, 2, 3, 4])
> 
> Then
> 
> x > 2 = [False, False, True, True]
> 
> Using boolean indexing
> 
> x[x > 2] = [3, 4]
> --
> Flavio
> 
> 
> On Fri, Mar 8, 2013 at 4:41 PM, Ronnie Ghose <ronnie.gh...@gmail.com> wrote:
>> That uses the Boolean indexing function of numpy arrays iirc
>> 
>> On Mar 8, 2013 1:28 PM, "Mohamed Radhouane Aniba" <arad...@gmail.com> wrote:
>>> 
>>> Simply because I am new to both python and scikit (Coming from R world)
>>> 
>>> The problem is that I tried using load_svmlight_file with in particular
>>> RBF parameters example
>>> http://scikit-learn.org/stable/auto_examples/svm/plot_rbf_parameters.html#example-svm-plot-rbf-parameters-py
>>> 
>>> and I get a lot of problems / errors/ so I thought it is easier to use
>>> native format which preserve the structure of the variables used.
>>> 
>>> What I tested in this script in particular is something like :
>>> 
>>> #iris = load_iris()
>>> #X = iris.data
>>> #Y = iris.target
>>> X,Y = load_svmlight_file("toto")
>>> X = X.toarray()
>>> 
>>> # dataset for decision function visualization
>>> 
>>> X_2d = X[:, :2]
>>> X_2d = X_2d[Y > 0]
>>> Y_2d = Y[Y > 0]
>>> Y_2d -= 1
>>> 
>>> What does the section _2d means ? not vey clear
>>> 
>>> Rad
>>> 
>>> On Mar 8, 2013, at 1:21 PM, Philipp Singer <kill...@gmail.com> wrote:
>>> 
>>>> Why do you want to convert libsvm to another structure?
>>>> 
>>>> I don't quite get it.
>>>> 
>>>> If you want to use examples: scikit learn has included datasets that can
>>>> be directly loaded. I think this section should help:
>>>> http://scikit-learn.org/stable/datasets/index.html
>>>> 
>>>> Am 08.03.2013 18:44, schrieb Mohamed Radhouane Aniba:
>>>>> Hello !
>>>>> 
>>>>> I am wondering if someone has developed a snippet or a script that
>>>>> converts libsvm format into a format directly usable by scikit without the
>>>>> need to use of load_svmlight_file.
>>>>> 
>>>>> The reason is that I am trying to use the examples provided on the
>>>>> website, but all of them are written in a format that is not a libsvm one.
>>>>> 
>>>>> Thanks
>>>>> 
>>>>> Rad
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>>>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>>>>> endpoint security space. For insight on selecting the right partner to
>>>>> tackle endpoint security challenges, access the full report.
>>>>> http://p.sf.net/sfu/symantec-dev2dev
>>>>> _______________________________________________
>>>>> Scikit-learn-general mailing list
>>>>> Scikit-learn-general@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>>> 
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>>>> endpoint security space. For insight on selecting the right partner to
>>>> tackle endpoint security challenges, access the full report.
>>>> http://p.sf.net/sfu/symantec-dev2dev
>>>> _______________________________________________
>>>> Scikit-learn-general mailing list
>>>> Scikit-learn-general@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>> 
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>>> endpoint security space. For insight on selecting the right partner to
>>> tackle endpoint security challenges, access the full report.
>>> http://p.sf.net/sfu/symantec-dev2dev
>>> _______________________________________________
>>> Scikit-learn-general mailing list
>>> Scikit-learn-general@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>> 
>> 
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, access the full report.
>> http://p.sf.net/sfu/symantec-dev2dev
>> _______________________________________________
>> Scikit-learn-general mailing list
>> Scikit-learn-general@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>> 
> 
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
> endpoint security space. For insight on selecting the right partner to 
> tackle endpoint security challenges, access the full report. 
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to