def fit_allele_specific_predictors(<EOL>self,<EOL>n_models,<EOL>architecture_hyperparameters_list,<EOL>allele,<EOL>peptides,<EOL>affinities,<EOL>inequalities=None,<EOL>train_rounds=None,<EOL>models_dir_for_save=None,<EOL>verbose=<NUM_LIT:0>,<EOL>progress_preamble="<STR_LIT>",<EOL>progress_print_interval=<NUM_LIT>):
allele = mhcnames.normalize_allele_name(allele)<EOL>if allele not in self.allele_to_allele_specific_models:<EOL><INDENT>self.allele_to_allele_specific_models[allele] = []<EOL><DEDENT>encodable_peptides = EncodableSequences.create(peptides)<EOL>peptides_affinities_inequalities_per_round = [<EOL>(encodable_peptides, affinities, inequalities)<EOL>]<EOL>if train_rounds is not None:<EOL><INDENT>for round in sorted(set(train_rounds)):<EOL><INDENT>round_mask = train_rounds > round<EOL>if round_mask.any():<EOL><INDENT>sub_encodable_peptides = EncodableSequences.create(<EOL>encodable_peptides.sequences[round_mask])<EOL>peptides_affinities_inequalities_per_round.append((<EOL>sub_encodable_peptides,<EOL>affinities[round_mask],<EOL>None if inequalities is None else inequalities[round_mask]))<EOL><DEDENT><DEDENT><DEDENT>n_rounds = len(peptides_affinities_inequalities_per_round)<EOL>n_architectures = len(architecture_hyperparameters_list)<EOL>pieces = []<EOL>if n_models > <NUM_LIT:1>:<EOL><INDENT>pieces.append("<STR_LIT>")<EOL><DEDENT>if n_architectures > <NUM_LIT:1>:<EOL><INDENT>pieces.append(<EOL>"<STR_LIT>")<EOL><DEDENT>if len(peptides_affinities_inequalities_per_round) > <NUM_LIT:1>:<EOL><INDENT>pieces.append("<STR_LIT>")<EOL><DEDENT>pieces.append("<STR_LIT>")<EOL>progress_preamble_template = "<STR_LIT>" % (<EOL>"<STR_LIT:U+002CU+0020>".join(pieces))<EOL>models = []<EOL>for model_num in range(n_models):<EOL><INDENT>for (architecture_num, architecture_hyperparameters) in enumerate(<EOL>architecture_hyperparameters_list):<EOL><INDENT>model = Class1NeuralNetwork(**architecture_hyperparameters)<EOL>for round_num in range(n_rounds):<EOL><INDENT>(round_peptides, round_affinities, round_inequalities) = (<EOL>peptides_affinities_inequalities_per_round[round_num]<EOL>)<EOL>model.fit(<EOL>round_peptides,<EOL>round_affinities,<EOL>inequalities=round_inequalities,<EOL>verbose=verbose,<EOL>progress_preamble=progress_preamble_template.format(<EOL>n_peptides=len(round_peptides),<EOL>round=round_num,<EOL>n_rounds=n_rounds,<EOL>user_progress_preamble=progress_preamble,<EOL>model_num=model_num + <NUM_LIT:1>,<EOL>n_models=n_models,<EOL>architecture_num=architecture_num + <NUM_LIT:1>,<EOL>n_architectures=n_architectures),<EOL>progress_print_interval=progress_print_interval)<EOL><DEDENT>model_name = self.model_name(allele, model_num)<EOL>row = pandas.Series(collections.OrderedDict([<EOL>("<STR_LIT>", model_name),<EOL>("<STR_LIT>", allele),<EOL>("<STR_LIT>", json.dumps(model.get_config())),<EOL>("<STR_LIT>", model),<EOL>])).to_frame().T<EOL>self._manifest_df = pandas.concat(<EOL>[self.manifest_df, row], ignore_index=True)<EOL>self.allele_to_allele_specific_models[allele].append(model)<EOL>if models_dir_for_save:<EOL><INDENT>self.save(<EOL>models_dir_for_save, model_names_to_write=[model_name])<EOL><DEDENT>models.append(model)<EOL><DEDENT><DEDENT>self.clear_cache()<EOL>return models<EOL>
Fit one or more allele specific predictors for a single allele using one
or more neural network architectures.

The new predictors are saved in the Class1AffinityPredictor instance
and will be used on subsequent calls to `predict`.

Parameters
----------
n_models : int
    Number of neural networks to fit

architecture_hyperparameters_list : list of dict
    List of hyperparameter sets.

allele : string

peptides : `EncodableSequences` or list of string

affinities : list of float
    nM affinities

inequalities : list of string, each element one of ">", "<", or "="
    See Class1NeuralNetwork.fit for details.

train_rounds : sequence of int
    Each training point i will be used on training rounds r for which
    train_rounds[i] > r, r >= 0.

models_dir_for_save : string, optional
    If specified, the Class1AffinityPredictor is (incrementally) written
    to the given models dir after each neural network is fit.

verbose : int
    Keras verbosity

progress_preamble : string
    Optional string of information to include in each progress update

progress_print_interval : float
    How often (in seconds) to print progress. Set to None to disable.

Returns
-------
list of `Class1NeuralNetwork`