predict not implemented
Opened this issue · 2 comments
Predict is not implemented in class treefarms yet. Is there a suggested workaround?
TODO: implement this
def predict(self, X):
"""
Parameters
---
X : matrix-like, shape = [n_samples by m_features]
a matrix where each row is a sample to be predicted and each column is a feature to be used for prediction
Returns
---
array-like, shape = [n_sampels by 1] : a column where each element is the prediction associated with each row
"""
raise NotImplementedError
Hi there! I'm also interested in the predict. Did you find a workaround?
Hi there! I took a dive and wanted to offer some insight.
There is a predict and classify function in TreeClassifier. So for each model in the Rashomon Set, you can get easily get the prediction. In the tutorial, for instance, you can write first_tree.predict(df)
to get the prediction labels from the first tree.
To get it for all models in the Rashomon Set, you can easily loop it:
PredictedValues = [model[i].predict(df) for i in range(model.get_tree_count())]
Note that the predict function in TreeClassifier uses a for loop, but it might be more efficient in large datasets to replace the loop by vectorizing as such:
predictions = X.apply(lambda row: self.classify(row.values)[0], axis=1)
I plan on submitting a pull request on this soon (it would be my first ever pull request :) ).