Pipeline Components: Learners

BiLSTM-CRF Learner

class medacy.pipeline_components.BiLstmCrfLearner[source]

Bases: object

BiLSTM-CRF model class for using the network. Currently handles all vectorization as well.

Variables:
  • device – PyTorch device to use.
  • model – Instance of BiLstmCrfNetwork to use.
  • word_embeddings_file – File to load word embeddings from.
  • word_vectors – Gensim word vectors object for use in configuring word embeddings.
fit(x_data, y_data)[source]

Fully train model based on x and y data. self.model is set to trained model.

Parameters:
  • x_data – List of list of tokens.
  • y_data – List of list of correct labels for the tokens.
load(path)[source]

Load model and other required values from given path.

Parameters:path – Path of saved model.
predict(sequences)[source]

Use model to make predictions over a given dataset.

Parameters:sequences – Sequences to predict labels for.
Returns:List of list of predicted labels.
save(path)[source]

Save model and other required values.

Parameters:path – Path to save model to.