Skip to content
Permalink
Browse files

Fixing all PEP8 violations and adding flake8 to the build script

  • Loading branch information...
tabacof committed Jun 10, 2019
1 parent d3ca1a9 commit 7991c2cbdc34a59f0e325ee9b30a2d62a91eb021
@@ -11,4 +11,4 @@
load_yago3_10, load_wn18rr

__all__ = ['load_from_csv', 'load_from_rdf', 'load_from_ntriples', 'load_wn18', 'load_fb15k',
'load_fb15k_237', 'load_yago3_10', 'load_wn18rr']
'load_fb15k_237', 'load_yago3_10', 'load_wn18rr']

Large diffs are not rendered by default.

@@ -13,6 +13,6 @@
generate_corruptions_for_eval, create_mappings, select_best_model_ranking, train_test_split_no_unseen, \
filter_unseen_entities

__all__ = ['mrr_score', 'hits_at_n_score', 'rank_score', 'generate_corruptions_for_fit',
__all__ = ['mrr_score', 'mr_score', 'hits_at_n_score', 'rank_score', 'generate_corruptions_for_fit',
'evaluate_performance', 'to_idx', 'generate_corruptions_for_eval', 'create_mappings',
'select_best_model_ranking', 'train_test_split_no_unseen', 'filter_unseen_entities']
@@ -15,7 +15,7 @@


def hits_at_n_score(ranks, n):
"""Hits@N
r"""Hits@N
The function computes how many elements of a vector of rankings ``ranks`` make it to the top ``n`` positions.
@@ -26,7 +26,7 @@ def hits_at_n_score(ranks, n):
.. math::
Hits@N = \sum_{i = 1}^{|Q|} 1 \, if rank_{(s, p, o)_i} \leq N
Hits@N = \sum_{i = 1}^{|Q|} 1 \, \text{if } rank_{(s, p, o)_i} \leq N
where :math:`Q` is a set of triples and :math:`(s, p, o)` is a triple :math:`\in Q`.
@@ -83,7 +83,7 @@ def hits_at_n_score(ranks, n):


def mrr_score(ranks):
"""Mean Reciprocal Rank (MRR)
r"""Mean Reciprocal Rank (MRR)
The function computes the mean of the reciprocal of elements of a vector of rankings ``ranks``.
@@ -94,7 +94,7 @@ def mrr_score(ranks):
.. math::
MRR = \\frac{1}{|Q|}\sum_{i = 1}^{|Q|}\\frac{1}{rank_{(s, p, o)_i}}
MRR = \frac{1}{|Q|}\sum_{i = 1}^{|Q|}\frac{1}{rank_{(s, p, o)_i}}
where :math:`Q` is a set of triples and :math:`(s, p, o)` is a triple :math:`\in Q`.
@@ -123,8 +123,6 @@ def mrr_score(ranks):
MRR=0.75
Parameters
----------
ranks: ndarray, shape [n]
@@ -168,15 +166,13 @@ def rank_score(y_true, y_pred, pos_lab=1):
y_pred : ndarray, shape [n]
An array of scores, for the positive element and the n-1 negatives.
pos_lab : int
The value of the positive label (default = 1)
The value of the positive label (default = 1).
Returns
-------
rank : int
The rank of the positive element against the negatives.
Examples
--------
>>> import numpy as np
@@ -196,7 +192,7 @@ def rank_score(y_true, y_pred, pos_lab=1):


def mr_score(ranks):
""" Mean Rank (MR)
r"""Mean Rank (MR)
The function computes the mean of of a vector of rankings ``ranks``.
@@ -206,7 +202,7 @@ def mr_score(ranks):
It is formally defined as follows:
.. math::
MR = \\frac{1}{|Q|}\sum_{i = 1}^{|Q|}rank_{(s, p, o)_i}
MR = \frac{1}{|Q|}\sum_{i = 1}^{|Q|}rank_{(s, p, o)_i}
where :math:`Q` is a set of triples and :math:`(s, p, o)` is a triple :math:`\in Q`.

Large diffs are not rendered by default.

@@ -5,7 +5,7 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
"""This module includes neural graph embedding models and support functions.
r"""This module includes neural graph embedding models and support functions.
Knowledge graph embedding models are neural architectures that encode concepts from a knowledge graph
(i.e. entities :math:`\mathcal{E}` and relation types :math:`\mathcal{R}`) into low-dimensional, continuous vectors
@@ -25,5 +25,3 @@
'EmbeddingModel', 'TransE', 'DistMult', 'ComplEx', 'HolE', 'RandomBaseline',
'Loss', 'AbsoluteMarginLoss', 'SelfAdversarialLoss', 'NLLLoss', 'PairwiseLoss', 'NLLMulticlass',
'Regularizer', 'LPRegularizer', 'get_entity_triples', 'save_model', 'restore_model']


0 comments on commit 7991c2c

Please sign in to comment.
You can’t perform that action at this time.