gobbli.model.mixin module

Mixins which can be applied to classes derived from BaseModel.

class gobbli.model.mixin.EmbedMixin[source]

Bases: object

Apply to a model which can be used to generate embeddings from data.

abstract data_dir()[source]
embed(embed_input, embed_dir_name=None)[source]

Generates embeddings using a model and the params in the given gobbli.io.EmbedInput.

Parameters
  • embed_input (EmbedInput) – Contains various parameters needed to determine how to generate embeddings and what data to generate embeddings for.

  • embed_dir_name (Optional[str]) – Optional name to store embedding input and output under. The directory is always created under the model’s data_dir. If a name is not given, a unique name is generated via a UUID. If a name is given, that directory must not already exist.

Return type

EmbedOutput

Returns

Output of training.

embed_dir()[source]

The directory to be used for data related to embedding (weights, embeddings, etc)

Return type

Path

Returns

Path to the embedding data directory.

abstract property logger
class gobbli.model.mixin.PredictMixin[source]

Bases: object

Apply to a model which can be used to predict on new data.

abstract data_dir()[source]
abstract property logger
predict(predict_input, predict_dir_name=None)[source]

Runs prediction on new data using params containing in the given gobbli.io.PredictInput.

Parameters
  • predict_input (PredictInput) – Contains various parameters needed to determine how to run prediction and what data to predict for.

  • predict_dir_name (Optional[str]) – Optional name to store prediction input and output under. The directory is always created under the model’s data_dir. If a name is not given, a unique name is generated via a UUID. If a name is given, that directory must not already exist.

Return type

PredictOutput

predict_dir()[source]

The directory to be used for data related to prediction (weights, predictions, etc)

Return type

Path

Returns

Path to the prediction data directory.

class gobbli.model.mixin.TrainMixin[source]

Bases: object

Apply to a model which can be trained in some way.

abstract data_dir()[source]
abstract property logger
train(train_input, train_dir_name=None)[source]

Trains a model using params in the given gobbli.io.TrainInput. The training process varies depending on the model, but in general, it includes the following steps:

  • Update weights using the training dataset

  • Evaluate performance on the validation dataset.

  • Repeat for a number of epochs.

  • When finished, report loss/accuracy and return the trained weights.

Parameters
  • train_input (TrainInput) – Contains various parameters needed to determine how to train and what data to train on.

  • train_dir_name (Optional[str]) – Optional name to store training input and output under. The directory is always created under the model’s data_dir. If a name is not given, a unique name is generated via a UUID. If a name is given, that directory must not already exist.

Return type

TrainOutput

Returns

Output of training.

train_dir()[source]

The directory to be used for data related to training (data files, etc).

Return type

Path

Returns

Path to the training data directory.