Skip to content

DecisionTreeClassifier serialization/deserialization  #254

@Baael

Description

@Baael
  • I'm submitting a ...
  • question about how to use this project
  • Summary
    I am trying to serialize and deserialize DecisionTreeClassifier, however it throws an error. What is a valid way to save tree to file and restore it later?

Source:

const decision = new DecisionTreeClassifier({ featureLabels: ['a','b'] });
const deserialized = new DecisionTreeClassifier({ featureLabels: ['a','b'] });

const X = [[0, 0], [1, 1]];
const y = [0, 1];
decision.fit( X, y );
const serialized = JSON.stringify(decision.toJSON())
deserialized.fromJSON(JSON.parse(serialized))

Stacktrace:

TypeError: node.question.match is not a function
    at DecisionTreeClassifier._predict (C:\apps\ml\src\lib\tree\tree.ts:434:23)
    at DecisionTreeClassifier.predict (C:\apps\ml\src\lib\tree\tree.ts:202:24)
    at Object.predict (C:\apps\ml/dttest.js:12:27)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions