|
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 |
|
|
|
|
|
|
13
|
|
|
from skchem import Mol |
|
14
|
|
|
|
|
15
|
|
|
class AbstractTargetPredictionAlgorithm(object): |
|
|
|
|
|
|
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): |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
""" Overload """ |
|
52
|
|
|
|
|
53
|
|
|
raise NotImplementedError |
|
54
|
|
|
|
|
55
|
|
|
def _m_predict_proba(self, m): |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
""" Overload """ |
|
58
|
|
|
|
|
59
|
|
|
raise NotImplementedError |
|
60
|
|
|
|
|
61
|
|
|
def _m_predict_log_proba(self, m): |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
""" Overload """ |
|
64
|
|
|
|
|
65
|
|
|
raise NotImplementedError |
|
66
|
|
|
|
|
67
|
|
|
def _df_predict(self, df): |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
""" Overload for prediction """ |
|
70
|
|
|
|
|
71
|
|
|
raise NotImplementedError |
|
72
|
|
|
|
|
73
|
|
|
def _df_predict_proba(self, df): |
|
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
""" Overload for prediction """ |
|
76
|
|
|
|
|
77
|
|
|
raise NotImplementedError |
|
78
|
|
|
|
|
79
|
|
|
def _df_predict_log_proba(self, df): |
|
|
|
|
|
|
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
|
|
|
|
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.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.