LabeledTriples

class LabeledTriples(data)[source]

Bases: object

Labeled triples for drug pair scoring.

Attributes Summary

columns

dtype

Methods Summary

drop_duplicates()

Drop the duplicated entries.

get_combination_count()

Get the number of unique drug pairs in the labeled triples dataset.

get_context_count()

Get the number of unique contexts in the labeled triples dataset.

get_drug_count()

Get the number of drugs in the labeled triples dataset.

get_labeled_triple_count()

Get the number of triples in the labeled triples dataset.

get_negative_count()

Get the number of negative triples in the dataset.

get_negative_rate()

Get the ratio of positive triples in the dataset.

get_positive_count()

Get the number of positive triples in the dataset.

get_positive_rate()

Get the ratio of positive triples in the dataset.

train_test_split([train_size, random_state])

Split the LabeledTriples object for training and testing.

Attributes Documentation

columns: ClassVar[Sequence[str]] = ('drug_1', 'drug_2', 'context', 'label')
dtype: ClassVar[Mapping[str, type]] = {'context': <class 'str'>, 'drug_1': <class 'str'>, 'drug_2': <class 'str'>, 'label': <class 'float'>}

Methods Documentation

drop_duplicates()[source]

Drop the duplicated entries.

get_combination_count()[source]

Get the number of unique drug pairs in the labeled triples dataset.

Return type

int

get_context_count()[source]

Get the number of unique contexts in the labeled triples dataset.

Return type

int

get_drug_count()[source]

Get the number of drugs in the labeled triples dataset.

Return type

int

get_labeled_triple_count()[source]

Get the number of triples in the labeled triples dataset.

Return type

int

get_negative_count()[source]

Get the number of negative triples in the dataset.

Return type

int

get_negative_rate()[source]

Get the ratio of positive triples in the dataset.

Return type

float

get_positive_count()[source]

Get the number of positive triples in the dataset.

Return type

int

get_positive_rate()[source]

Get the ratio of positive triples in the dataset.

Return type

float

train_test_split(train_size=None, random_state=42)[source]

Split the LabeledTriples object for training and testing.

Parameters
  • train_size (Optional[float]) – The ratio of training triples. Default is 0.8 if None is passed.

  • random_state (Optional[int]) – The random seed. Default is 42. Set to none for no fixed seed.

Return type

Tuple[LabeledTriples, LabeledTriples]

Returns

A pair of training triples and testing triples