Completed
Push — master ( 2bc047...202252 )
by Rich
01:16
created

TargetPredictionAlgorithm.predict_proba()   A

Complexity

Conditions 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 4
dl 0
loc 9
rs 9.2
1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2007-2009 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6
"""
7
skchem.target_prediction.target_prediction
8
9
Target prediction base class
10
"""
11
12
import pandas as pd
0 ignored issues
show
Configuration introduced by
The import pandas 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...
13
from skchem import Mol
14
15
class AbstractTargetPredictionAlgorithm(object):
0 ignored issues
show
Complexity introduced by
This abstract class seems to be used only once.

Abstract classes which are used only once can usually be inlined into the class which already uses this abstract class.

Loading history...
16
17
    """abstract target prediction class, inherit from this for a target prediction algorithm"""
18
19
    def predict(self, obj):
20
21
        """ Predict the targets for a compound or compound DataFrame """
22
23
        if isinstance(obj, Mol):
24
            return self._m_predict(obj)
25
26
        if isinstance(obj, pd.Series) or isinstance(obj, pd.DataFrame):
27
            return self._df_predict(obj)
28
29
    def predict_proba(self, obj):
30
31
        """ Predict the probability of hitting targets for a compound or compound DataFrame """
32
33
        if isinstance(obj, Mol):
34
            return self._m_predict_proba(obj)
35
36
        if isinstance(obj, pd.Series) or isinstance(obj, pd.DataFrame):
37
            return self._df_predict_proba(obj)
38
39
    def predict_log_proba(self, obj):
40
41
        """ Predict the log probability of hitting target for a compound or compound DataFrame """
42
43
        if isinstance(obj, Mol):
44
            return self._m_predict_log_proba(obj)
45
46
        if isinstance(obj, pd.Series) or isinstance(obj, pd.DataFrame):
47
            return self._df_predict_log_proba(obj)
48
49
    def _m_predict(self, m):
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the argument 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...
50
51
        """ Overload """
52
53
        raise NotImplementedError
54
55
    def _m_predict_proba(self, m):
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the argument 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...
56
57
        """ Overload """
58
59
        raise NotImplementedError
60
61
    def _m_predict_log_proba(self, m):
0 ignored issues
show
Coding Style Naming introduced by
The name m does not conform to the argument 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...
62
63
        """ Overload """
64
65
        raise NotImplementedError
66
67
    def _df_predict(self, df):
0 ignored issues
show
Coding Style Naming introduced by
The name df does not conform to the argument 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...
68
69
        """ Overload for prediction """
70
71
        raise NotImplementedError
72
73
    def _df_predict_proba(self, df):
0 ignored issues
show
Coding Style Naming introduced by
The name df does not conform to the argument 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...
74
75
        """ Overload for prediction """
76
77
        raise NotImplementedError
78
79
    def _df_predict_log_proba(self, df):
0 ignored issues
show
Coding Style Naming introduced by
The name df does not conform to the argument 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...
80
81
        """ Overload for prediction """
82
83
        raise NotImplementedError
84
85
    def __call__(self, obj):
86
87
        """ Predict the targets for a compound or compound DataFrame """
88
89
        self.predict(obj)
90