Skip to content

Decision Tree regressor custom function for attribute split #7777

Closed

Description

@farzanayusuf

Description

I want to use a custom distance function instead of MSE,MAE or FriedmanMSE. Is it possible to incorporate any user defined custom cost function in my case which is Earth mover distance(EMD) to minimize the cost while selecting the best split attribute. It seems like https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_criterion.pyx is the file i need to work on. I wanted to ensure that i am getting it right so i can modify the implementation according to my need.

Steps/Code to Reproduce

cdef class RegressionCriterion(Criterion):
"""Abstract regression criterion.
This handles cases where the target is a continuous value, and is
evaluated by computing the variance of the target values left and right
of the split point. The computation takes linear time with n_samples
by using ::
var = \sum_i^n (y_i - y_bar) ** 2
= (\sum_i^n y_i ** 2) - n_samples * y_bar ** 2
"""

Shouldn't implementing a new function like this one with emd work?

Expected Results

Actual Results

Versions

Activity

  1. jnothman commented on Oct 29, 2016

    @jnothman
    Member

    This is more appropriate for the mailing list or stackoverflow than the issue tracker.

    You should be able to import the pxd files and implement your own without modifying the scikit-learn source.

  2. farzanayusuf commented on Oct 29, 2016

    @farzanayusuf
    Author

    Sorry for the inconvenience, I will keep in mind next time.Actually i looked for it in stackoverflow.The approach you have described is currently i have in my mind to follow. I guess i wanted to make a feature request. Like for KNN User custom defined distance function is already supported, isn't it possible to do the same for Decision trees rather than binding them with specific criteria only?

  3. amueller commented on Nov 1, 2016

    @amueller
    Member

    They need to be implemented in cython or they'll be to slow.

  4. Vinodhkumar-MT16062 commented on Dec 23, 2017

    @Vinodhkumar-MT16062

    @farzanayusuf Hi, Am also looking for ways to custom implement the criterion. Did you figure out any way to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions