Source code for immuneML.ml_methods.generative_models.GenerativeModel

import abc
from pathlib import Path

import numpy as np

from immuneML.data_model.SequenceParams import RegionType
from immuneML.data_model.datasets.Dataset import Dataset
from immuneML.environment.SequenceType import SequenceType


[docs] class GenerativeModel: """ Generative models are algorithms which can be trained to learn patterns in existing datasets, and then be used to generate new synthetic datasets. These methods can be used in the :ref:`TrainGenModel` instruction, and previously trained models can be used to generate data using the :ref:`ApplyGenModel` instruction. """ DOCS_TITLE = "Generative models" OUTPUT_COLUMNS = [] def __init__(self, locus, name: str = None, region_type: RegionType = None): self.locus = locus self.name = name self.region_type = region_type
[docs] @abc.abstractmethod def fit(self, data, path: Path = None): pass
[docs] @abc.abstractmethod def is_same(self, model) -> bool: raise NotImplementedError
[docs] @abc.abstractmethod def generate_sequences(self, count: int, seed: int, path: Path, sequence_type: SequenceType, compute_p_gen: bool) \ -> Dataset: pass
[docs] @abc.abstractmethod def compute_p_gens(self, sequences, sequence_type: SequenceType) -> np.ndarray: pass
[docs] @abc.abstractmethod def compute_p_gen(self, sequence: dict, sequence_type: SequenceType) -> float: pass
[docs] @abc.abstractmethod def can_compute_p_gens(self) -> bool: pass
[docs] @abc.abstractmethod def can_generate_from_skewed_gene_models(self) -> bool: pass
[docs] @abc.abstractmethod def generate_from_skewed_gene_models(self, v_genes: list, j_genes: list, seed: int, path: Path, sequence_type: SequenceType, batch_size: int, compute_p_gen: bool): pass
[docs] @abc.abstractmethod def save_model(self, path: Path) -> Path: pass
[docs] @classmethod @abc.abstractmethod def load_model(cls, path: Path): pass