Code Monkey home page Code Monkey logo

Comments (10)

isaksamsten avatar isaksamsten commented on August 19, 2024 1

Hi,

You can find the shapelets in the tree attribute. forest.estimators_[0].tree.features give a list of the shapelets of the first tree in the ensemble. Check the _tree.py file for details. The tree has the same structure as a tree in sklearn so examples for extracting features of such trees can be adapted.

from wildboar.

lorebon avatar lorebon commented on August 19, 2024

Thanks, I've managed to retrieve shapelets.
I have another question: the forest.estimators_[0].tree.feateures list contains several values.

For example:
features[0] = (1, array([....]))
features[1] = None
features[2] = (1, array([....]))
features[3] = None
features[4] = None
etc...

It seems that some elements are None, while other are in the form (number, array). I think that maybe the array is the shapelet and the number is the target class.

Why are some elements None? Why does the number of elements in the list differ from a tree to another?

Thank you again!

from wildboar.

isaksamsten avatar isaksamsten commented on August 19, 2024

If the value is None the node index refers to a leaf node. The first element of the tuple refers to the dimension of the input data and the second is the shapelet.

from wildboar.

isaksamsten avatar isaksamsten commented on August 19, 2024

The number of features depend on the depth of the tree. Not all trees are equally deep.

from wildboar.

isaksamsten avatar isaksamsten commented on August 19, 2024

Here is an example where all branches are visited: https://github.com/isaksamsten/wildboar/blob/9348d46422bf9665b5aa67f17aa397191764e85b/src/wildboar/explain/counterfactual/_sf.py#L71

from wildboar.

madarax64 avatar madarax64 commented on August 19, 2024

Hi @isaksamsten ,
I stumbled upon this thread while looking for similar functionality...in my own usage, I found that I was able to access the shapelets as (assuming the classifier object is called clf and assuming the first tree at index 0):

clf.estimators_[0].estimator.tree_.shapelet

Rather than the way you described above. Is this way correct or am I missing something?
Thanks!

from wildboar.

isaksamsten avatar isaksamsten commented on August 19, 2024

Hi!

You are not missing anything. For version 1.1, the shapelet attribute is renamed features.

from wildboar.

madarax64 avatar madarax64 commented on August 19, 2024

Hello!
Ah, got it. v1.1 is seemingly not on pip yet, so I'll just make a note to update my code when it comes out. Thanks for the clarification and the amazing work!

from wildboar.

isaksamsten avatar isaksamsten commented on August 19, 2024

Not yet. The update is rather massive and I want to make sure that there aren’t too many regressions. (I will try to write a migration guide too 😱)

from wildboar.

madarax64 avatar madarax64 commented on August 19, 2024

Haha, that's ok. Thank you once again for the amazing work!

from wildboar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.