Eval_Task
confidence_prediction
- unKR.eval_task.confidence_prediction.conf_predict(batch, model)[source]
The goal of evaluate task is to predict the confidence of triples.
- Parameters:
batch – The batch of the triples for validation or test.
model – The UKG model for training.
- Returns:
Mean absolute error. MSE: Mean Square error.
- Return type:
MAE
link_predition
- unKR.eval_task.link_prediction.calc_ranks(idx, label, pred_score)[source]
Calculating triples score ranks.
- unKR.eval_task.link_prediction.calc_ranks_raw(idx, label, pred_score)[source]
Calculating triples score ranks. Different from calc_ranks, calc_ranks_raw will not exclude samples that are already in the knowledge graph when get the ranks.
- unKR.eval_task.link_prediction.head_predict(batch, model)[source]
Getting head entity ranks.
- Parameters:
batch – The batch of the triples for validation or test
model – The UKG model for training.
- Returns:
The rank of the head entity to be predicted, dim [batch_size]
- Return type:
tensor
- unKR.eval_task.link_prediction.head_predict_filter(batch, model, confidence)[source]
Getting head entity ranks (high confidence).
- Parameters:
batch – The batch of the triples for validation or test
model – The UKG model for training.
- Returns:
The rank of the head entity to be predicted, dim [batch_size]
- Return type:
tensor
- unKR.eval_task.link_prediction.head_predict_raw(batch, model, confidence)[source]
Getting head entity ranks. (high confidence + no filter)
- Parameters:
batch – The batch of the triples for validation or test
model – The UKG model for training.
- Returns:
The rank of the head entity to be predicted, dim [batch_size]
- Return type:
tensor
- unKR.eval_task.link_prediction.link_predict(batch, model, prediction='all')[source]
The evaluate task is predicting the head entity or tail entity in incomplete triples.
- Parameters:
batch – The batch of the triples for validation or test.
model – The UKG model for training.
predicion – mode of link prediction.
- Returns:
The rank of the triple to be predicted.
- Return type:
ranks
- unKR.eval_task.link_prediction.link_predict_filter(batch, model, confidence, prediction='all')[source]
The evaluate task is predicting the head entity or tail entity in incomplete triples. link_predict_filter is for high confidence test samples, only samples higher than the set confidence will participate in link prediction tasks. When confidence is set to 0, this function is the same as link_predict.
- Parameters:
batch – The batch of the triples for validation or test.
model – The UKG model for training.
predicion – mode of link prediction.
- Returns:
The rank of the triple to be predicted.
- Return type:
ranks
- unKR.eval_task.link_prediction.link_predict_raw(batch, model, confidence, prediction='all')[source]
The evaluate task is predicting the head entity or tail entity in incomplete triples. Only samples higher than the set confidence will participate in link prediction tasks. Different from link_predict_filter, this function does not filter samples that already exist in the knowledge graph when calculating the ranking of samples
- Parameters:
batch – The batch of the triples for validation or test.
model – The KG model for training.
predicion – mode of link prediction.
- Returns:
The rank of the triple to be predicted.
- Return type:
ranks
- unKR.eval_task.link_prediction.tail_predict(batch, model)[source]
Getting tail entity ranks.
- Parameters:
batch – The batch of the triples for validation or test
model – The UKG model for training.
- Returns:
The rank of the tail entity to be predicted, dim [batch_size]
- Return type:
tensor
- unKR.eval_task.link_prediction.tail_predict_filter(batch, model, confidence)[source]
Getting tail entity ranks.(high confidence)
- Parameters:
batch – The batch of the triples for validation or test
model – The UKG model for training.
- Returns:
The rank of the tail entity to be predicted, dim [batch_size]
- Return type:
tensor
- unKR.eval_task.link_prediction.tail_predict_raw(batch, model, confidence)[source]
Getting tail entity ranks. (high confidence + no filter)
- Parameters:
batch – The batch of the triples for validation or test
model – The UKG model for training.
- Returns:
The rank of the tail entity to be predicted, dim [batch_size]
- Return type:
tensor