Thanks for your responses. I've been using a workaround similar to Joel's
suggestion in the meantime, and it sounds like I just have to stick with
that for now. Essentially I'm doing a hyperparameter grid search, but in a
context that doesn't support GridSearchCV, so I'm dealing with multiple
independent models and had been appending them to a list and then
converting them to a numpy array for sorting with an argsort derived from
the scores.


On Mon, May 26, 2014 at 4:21 AM, Joel Nothman <[email protected]>wrote:

> It's possible to put a sequence as an object into an array, but you cannot
> do it with asarray or array directly. Use, for example:
>
> a = np.empty(1)
> a[0] = estimator
> # alternatively:
> a[:] = [estimator]
>
>
> On 26 May 2014 21:17, Gilles Louppe <[email protected]> wrote:
>
>> Why do you want to put a random forest in a numpy array in the first
>> place?
>>
>> Best,
>> Gilles
>>
>>
>> On 26 May 2014 13:11, Lars Buitinck <[email protected]> wrote:
>>
>>> 2014-05-24 0:28 GMT+02:00 Steven Kearnes <[email protected]>:
>>> > a is a list of the individual DecisionTreeClassifier objects belonging
>>> to
>>> > the model, instead of a list containing the model itself. The same
>>> result
>>> > occurs if I add dtype=object to np.asarray.
>>> >
>>> > Why is this happening? Is there a way to prevent it?
>>>
>>> It's because a random forest is an ensemble model and ensemble models
>>> behave like lists:
>>>
>>> >>> len(estimator)
>>> 10
>>> >>> estimator[0]
>>> DecisionTreeClassifier(compute_importances=None, criterion='gini',
>>>             max_depth=None, max_features='auto', max_leaf_nodes=None,
>>>             min_density=None, min_samples_leaf=1, min_samples_split=2,
>>>             random_state=1854205873, splitter='best')
>>>
>>> NumPy picks this up and acts accordingly: asarray, when given a
>>> sequence of things, makes an array of the elements of the sequence.
>>>
>>> This behavior was introduced in
>>> https://github.com/scikit-learn/scikit-learn/commit/7bd3f88f. I don't
>>> see an easy way to turn this off with modifying the library code.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The best possible search technologies are now affordable for all
>>> companies.
>>> Download your FREE open source Enterprise Search Engine today!
>>> Our experts will assist you in its installation for $59/mo, no
>>> commitment.
>>> Test it for FREE on our Cloud platform anytime!
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Scikit-learn-general mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> The best possible search technologies are now affordable for all
>> companies.
>> Download your FREE open source Enterprise Search Engine today!
>> Our experts will assist you in its installation for $59/mo, no commitment.
>> Test it for FREE on our Cloud platform anytime!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Scikit-learn-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>
>>
>
>
> ------------------------------------------------------------------------------
> The best possible search technologies are now affordable for all companies.
> Download your FREE open source Enterprise Search Engine today!
> Our experts will assist you in its installation for $59/mo, no commitment.
> Test it for FREE on our Cloud platform anytime!
>
> http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to