from MDRMF import Dataset
from MDRMF.models import Modeller

class Model:
    """
    Wrapper class for a Modeller object.

    Parameters:
        model (Modeller): The Modeller object to wrap.

    Attributes:
        model (Modeller): The wrapped Modeller object.
    """

    def __init__(self, model: Modeller) -> None:
        """
        Initializes a Model object with the provided Modeller object.

        Parameters:
            model (Modeller): The Modeller object to wrap.
        """
        self.model = model


    def train(self):
        """
        Trains the wrapped Modeller object.
        """
        self.model.fit()


    def predict(self, dataset: Dataset):
        """
        Generates predictions using the wrapped Modeller object.

        Parameters:
            dataset (Dataset): The dataset object containing the data to predict on.

        Returns:
            The predictions generated by the wrapped Modeller object.
        """
        return self.model.predict(dataset)


    def get_acquired_points(self, unlabeled_dataset, labeled_dataset):
        return self.model.unlabeled_acquisition(self.model, unlabeled_dataset, labeled_dataset)

    @property
    def results(self):
        """
        Property that returns the results of the wrapped Modeller object.

        Returns:
            dict: A dictionary containing the results of the model's evaluations.
        """
        return self.model.results
    
    @property
    def model_datasets(self):
        return self.model.model_datasets


    def model_graphs(self):
        return self.model.figures


    def save(self, filename: str):
        """
        Save the wrapped Modeller object to a pickle file
        """
        self.model.save(filename)
        

    @staticmethod
    def load(filename: str):
        """
        Load a Modeller object from a pickle file and wrap it in a Model object
        """
        model = Modeller.load(filename)
        return Model(model)