Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

save_model_to_bentoml.py 649 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  1. import os
  2. import bentoml
  3. import joblib
  4. from pathlib import Path
  5. # Obtiene el nombre del modelo desde la variable de entorno o usa el predeterminado
  6. model_name = os.getenv("MODEL_NAME", "model_1")
  7. # Construye la ruta al modelo
  8. model_path = Path(f"../models/{model_name}/rf_model.pkl")
  9. # Verifica que el archivo exista
  10. if not model_path.exists():
  11. raise FileNotFoundError(f"Modelo no encontrado en {model_path}")
  12. # Carga el modelo
  13. model = joblib.load(model_path)
  14. # Guarda el modelo en BentoML
  15. bentoml.sklearn.save_model(f"credit_scoring_{model_name}", model)
  16. print(f"Modelo {model_name} registrado en BentoML como credit_scoring_{model_name}")
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...