Hi Peter,

thanks for your answer. I have tried this before also, and the problem is
that in this case I get
ValueError: operands could not be broadcast together with shapes (74)
(148), because the y array is raveled and it has shape (74,2).

Do you need a self containing testcase which reproduces this error?

Cheers;
Attila


On Tue, Oct 22, 2013 at 1:16 PM, Peter Prettenhofer <
peter.prettenho...@gmail.com> wrote:

> Hi Attila,
>
> please use the following adaptor::
>
>     def __init__(self, est):
>         self.est = est
>     def predict(self, X):
>         return self.est.predict_proba(X)
>     def fit(self, X, y):
>         self.est.fit(X, y)
>
> The one in the stackoverflow question returns an array of shape
> (n_samples,) but it should rather be (n_samples, n_classes).
>
> PS: I still need to fix the init issue but any solution will most likely
> make the GBRT slower at prediction time (especially for single instance
> prediction).
>
> best,
>  Peter
>
>
> 2013/10/22 Attila Balogh <attila.bal...@gmail.com>
>
>>  Hi all,
>>
>> first of all thanks for all the developers for working on scikit-learn,
>> it is a wonderful library.
>> I am struggling for a while now with the following problem:
>> Trying to use GBR with LR as a BaseEstimator, and I'm getting the
>> following error:
>>
>>  File "main.py", line 110, in main
>>     score = np.mean(cross_validation.cross_val_score(rd, X, y, cv=4,
>> scoring='roc_auc'))
>>   File "C:\Python27\lib\site-packages\sklearn\cross_validation.py", line
>> 1152, in cross_val_score
>>     for train, test in cv)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\externals\joblib\parallel.py", line
>> 517, in __call__
>>     self.dispatch(function, args, kwargs)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\externals\joblib\parallel.py", line
>> 312, in dispatch
>>     job = ImmediateApply(func, args, kwargs)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\externals\joblib\parallel.py", line
>> 136, in __init__
>>     self.results = func(*args, **kwargs)
>>   File "C:\Python27\lib\site-packages\sklearn\cross_validation.py", line
>> 1060, in _cross_val_score
>>     estimator.fit(X_train, y_train, **fit_params)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\ensemble\gradient_boosting.py", line
>> 890, in fit
>>     return super(GradientBoostingClassifier, self).fit(X, y)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\ensemble\gradient_boosting.py", line
>> 613, in fit
>>     random_state)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\ensemble\gradient_boosting.py", line
>> 486, in _fit_stage
>>     sample_mask, self.learning_rate, k=k)
>>   File
>> "C:\Python27\lib\site-packages\sklearn\ensemble\gradient_boosting.py", line
>> 172, in update_terminal_regions
>>     y_pred[:, k])
>> IndexError: too many indices
>>
>> I have found a similar problem on stackoverflow (
>> http://stackoverflow.com/questions/17454139/gradientboostingclassifier-with-a-baseestimator-in-scikit-learn)
>> and tried to implement the adaptor but it didn't help, the error remained
>> the same.
>>
>> Does anyone have any ideas how to resolve this?
>>
>> Cheers;
>> Attila
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register >
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Scikit-learn-general mailing list
>> Scikit-learn-general@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>
>>
>
>
> --
> Peter Prettenhofer
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to