Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save tradaboost model #109

Closed
971766904 opened this issue Jun 28, 2023 · 2 comments
Closed

Save tradaboost model #109

971766904 opened this issue Jun 28, 2023 · 2 comments

Comments

@971766904
Copy link

I want to know how to save a model trained by tradaboost whose estimator is LGBMClassifier and how to load a saved model when I need to deploy on real time situation.

@antoinedemathelin
Copy link
Collaborator

Hi @971766904,

Thank you for your interest in the Adapt library. To save and load the TrAdaBoost model, you can use joblib as for scikit-learn estimators.

Here is an example:

import joblib
from adapt.utils import make_classification_da
from adapt.instance_based import TrAdaBoost
from lightgbm import LGBMClassifier

Xs, ys, Xt, yt = make_classification_da()

model = TrAdaBoost(estimator=LGBMClassifier(num_leaves=20))
model.fit(Xs, ys, Xt, yt)

# Save the fitted model
joblib.dump(model, "model.pkl")

# Load the model and make predictions
loaded_model = joblib.load("model.pkl")
loaded_model.predict(Xt)

@971766904
Copy link
Author

Hi @971766904,

Thank you for your interest in the Adapt library. To save and load the TrAdaBoost model, you can use joblib as for scikit-learn estimators.

Here is an example:

import joblib
from adapt.utils import make_classification_da
from adapt.instance_based import TrAdaBoost
from lightgbm import LGBMClassifier

Xs, ys, Xt, yt = make_classification_da()

model = TrAdaBoost(estimator=LGBMClassifier(num_leaves=20))
model.fit(Xs, ys, Xt, yt)

# Save the fitted model
joblib.dump(model, "model.pkl")

# Load the model and make predictions
loaded_model = joblib.load("model.pkl")
loaded_model.predict(Xt)

thank your for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants