Issues (942)

skchem/metrics.py (4 issues)

1
#! /usr/bin/env python
0 ignored issues
show
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
#
3
# Copyright (C) 2015-2016 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6 1
import numpy as np
0 ignored issues
show
The import numpy could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
7
8
9 1
def bedroc_score(y_true, y_pred, decreasing=True, alpha=20.0):
10
11
    """BEDROC metric implemented according to Truchon and Bayley.
12
13
    The Boltzmann Enhanced Descrimination of the Receiver Operator
14
    Characteristic (BEDROC) score is a modification of the Receiver Operator
15
    Characteristic (ROC) score that allows for a factor of *early recognition*.
16
17
    References:
18
        The original paper by Truchon et al. is located at `10.1021/ci600426e
19
        <http://dx.doi.org/10.1021/ci600426e>`_.
20
21
    Args:
22
        y_true (array_like):
23
            Binary class labels. 1 for positive class, 0 otherwise.
24
        y_pred (array_like):
25
            Prediction values.
26
        decreasing (bool):
27
            True if high values of ``y_pred`` correlates to positive class.
28
        alpha (float):
29
            Early recognition parameter.
30
31
    Returns:
32
        float:
33
            Value in interval [0, 1] indicating degree to which the predictive
34
            technique employed detects (early) the positive class.
35
     """
36
37
    assert len(y_true) == len(y_pred), \
38
        'The number of scores must be equal to the number of labels'
39
40
    big_n = len(y_true)
41
    n = sum(y_true == 1)
0 ignored issues
show
Coding Style Naming introduced by
The name n does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
42
43
    if decreasing:
44
        order = np.argsort(-y_pred)
45
    else:
46
        order = np.argsort(y_pred)
47
48
    m_rank = (y_true[order] == 1).nonzero()[0]
49
50
    s = np.sum(np.exp(-alpha * m_rank / big_n))
0 ignored issues
show
Coding Style Naming introduced by
The name s does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
51
52
    r_a = n / big_n
53
54
    rand_sum = r_a * (1 - np.exp(-alpha))/(np.exp(alpha/big_n) - 1)
55
56
    fac = r_a * np.sinh(alpha / 2) / (np.cosh(alpha / 2) -
57
                                      np.cosh(alpha/2 - alpha * r_a))
58
59
    cte = 1 / (1 - np.exp(alpha * (1 - r_a)))
60
61
    return s * fac / rand_sum + cte
62