Spaces:
Sleeping
Sleeping
File size: 1,120 Bytes
19d70f4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | from typing import Union
from mlpipeline.automl.autogluon_trainer import AutoGluonTrainer
from mlpipeline.automl.flaml_trainer import FLAMLTrainer
from mlpipeline.automl.pycaret_trainer import PyCaretTrainer
from mlpipeline.logging.logger import get_logger
logger = get_logger(__name__)
class AutoMLFactory:
@staticmethod
def create_trainer(library: str, config: dict) -> Union[AutoGluonTrainer, FLAMLTrainer, PyCaretTrainer]:
library = library.lower()
if library == 'autogluon':
logger.info("Creating AutoGluon trainer")
return AutoGluonTrainer(config)
elif library == 'flaml':
logger.info("Creating FLAML trainer")
return FLAMLTrainer(config)
elif library == 'pycaret':
logger.info("Creating PyCaret trainer")
return PyCaretTrainer(config)
else:
raise ValueError(f"Unknown AutoML library: {library}. Choose from: autogluon, flaml, pycaret")
@staticmethod
def get_available_libraries():
return ['autogluon', 'flaml', 'pycaret'] |