Skip to content
This repository was archived by the owner on May 25, 2024. It is now read-only.
This repository was archived by the owner on May 25, 2024. It is now read-only.

Template not found for Random forest  #4

@devdattakhoche

Description

@devdattakhoche

I was trying to export random forest classifier and trying to print the code.
But it is not able to find the template , which I saw is there in the folder "randomforest/randomforest.jinja"

the code I have written

from sklearn.svm import SVC
from micromlgen import port
from glob import glob
from os.path import basename
import numpy as np
from sklearn.ensemble import RandomForestClassifier

def load_features(folder):
    dataset = None
    classmap = {}
    for class_idx, filename in enumerate(glob('%s/*.csv' % folder)):
        class_name = basename(filename)[:-4]
        classmap[class_idx] = class_name
        samples = np.loadtxt(filename, dtype=float, delimiter=',')
        labels = np.ones((len(samples), 1)) * class_idx
        samples = np.hstack((samples, labels))
        dataset = samples if dataset is None else np.vstack((dataset, samples))

    return dataset, classmap
# put your samples in the dataset folder
# one class per file
# one feature vector per line, in CSV format
features, classmap = load_features('data/')
X, y = features[:, :-1], features[:, -1]
classifier = RandomForestClassifier(random_state=0,max_depth=20).fit(X, y)
c_code = port(classifier, classmap=classmap)
print(c_code)

Given output :
Template not found

Expected Output :

should have printed c code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions