-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3f877f
commit d2ff580
Showing
9 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"Mean Squared Error": 0.462, | ||
"Root Mean Squared Error": 0.6797, | ||
"Mean Absolute Error": 0.4891, | ||
"R-squared Score": 0.6514, | ||
"Explained Variance Score": 0.6521 | ||
"Mean Squared Error": 0.3952, | ||
"Root Mean Squared Error": 0.6287, | ||
"Mean Absolute Error": 0.4569, | ||
"R-squared Score": 0.7018, | ||
"Explained Variance Score": 0.7018 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import numpy as np | ||
import pandas as pd | ||
from rdkit.Chem import rdFingerprintGenerator | ||
from sklearn.feature_selection import VarianceThreshold | ||
|
||
from rdkit.Chem import rdMolDescriptors as rd | ||
from rdkit import Chem | ||
|
||
RADIUS = 3 | ||
NBITS = 2048 | ||
DTYPE = np.uint8 | ||
|
||
def clip_sparse(vect, nbits): | ||
l = [0]*nbits | ||
for i,v in vect.GetNonzeroElements().items(): | ||
l[i] = v if v < 255 else 255 | ||
return l | ||
|
||
|
||
class _Fingerprinter(object): | ||
|
||
def __init__(self): | ||
self.nbits = NBITS | ||
self.radius = RADIUS | ||
|
||
def calc(self, mol): | ||
v = rd.GetHashedMorganFingerprint(mol, radius=self.radius, nBits=self.nbits) | ||
return clip_sparse(v, self.nbits) | ||
|
||
|
||
def morgan_featurizer(smiles): | ||
d = _Fingerprinter() | ||
X = np.zeros((len(smiles), NBITS)) | ||
for i, smi in enumerate(smiles): | ||
mol = Chem.MolFromSmiles(smi) | ||
X[i,:] = d.calc(mol) | ||
return X | ||
|
||
|
||
class MorganFingerprint(object): | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def fit(self, smiles): | ||
X = morgan_featurizer(smiles) | ||
self.features = ["fp-{0}".format(i+1) for i in range(X.shape[1])] | ||
return pd.DataFrame(X, columns=self.features) | ||
|
||
def transform(self, smiles): | ||
X = morgan_featurizer(smiles) | ||
return pd.DataFrame(X, columns=self.features) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters