iterative / mlem.ai

✨ Landing page for MLEM
https://mlem.ai/
BSD Zero Clause License
27 stars 12 forks source link

HookNotFound Error: No suitable ModelHook for object of type "IsolationForest" #353

Closed SivamPillai closed 1 year ago

SivamPillai commented 1 year ago

I am trying to use MLEM for saving and loading IsolationForest from sklearn.ensemble. As per the documentation, all sklearn models are supported - However, I get the below error for sklearn.ensemble.IsolationForest:

mlem.core.errors.HookNotFound: No suitable ModelHook for object of type "IsolationForest". 
Registered hooks: [<class 'mlem.contrib.callable.CallableModelType'>, <class 'mlem.contrib.sklearn.SklearnModel'>, 
<class 'mlem.contrib.sklearn.SklearnPipelineType'>, <class 'mlem.contrib.sklearn.SklearnTransformer'>]

Is there something wrong in my approach? Or is there an issue with the IsolationForest API in sklearn.

Code used:

from mlem.api import save
import pandas as pd
from sklearn.ensemble import IsolationForest, RandomForestRegressor

features = [
    "sepal length (cm)",
    "sepal width (cm)",
    "petal length (cm)",
    "petal width (cm)",
]

df = pd.DataFrame([[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]], columns=features)
y = [0, 1, 2]

iff = IsolationForest()
iff.fit(df)

save(iff, "models/iff", sample_data=df)
SivamPillai commented 1 year ago

bump, do you have any input or suggestions here, please?

aguschin commented 1 year ago

Hi @SivamPillai! Implemented this, this is going to be released in new version of MLEM (releasing it now) https://github.com/iterative/mlem/releases/tag/0.4.14