<jupyter_start><jupyter_text>Installing DeepChem<jupyter_code>!curl -Lo conda_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import conda_installer
conda_installer.install()
!/root/miniconda/bin/conda info -e
!pip install --pre deepchem<jupyter_output>Collecting deepchem
[?25l  Downloading https://files.pythonhosted.org/packages/5a/7a/456cd8731b855d33b6db7043627a71f88d89bcf2f570110b8f7603558b06/deepchem-2.4.0rc1.dev20201110082157.tar.gz (402kB)
[K     |████████████████████████████████| 409kB 2.7MB/s 
[?25hRequirement already satisfied: joblib in /usr/local/lib/python3.6/dist-packages (from deepchem) (0.17.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from deepchem) (1.18.5)
Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from deepchem) (1.1.4)
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from deepchem) (0.22.2.post1)
Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from deepchem) (1.4.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.6/dist-packages (from pandas->deepchem) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-[...]<jupyter_text>We can now import the `deepchem` package to play with.<jupyter_code>import deepchem as dc
dc.__version__<jupyter_output><empty_output><jupyter_text>Baseline - Fingerprints + NNImplementing and recording the baseline for Tox21 dataset.<jupyter_code>tasks, datasets, transformers = dc.molnet.load_sampl(featurizer='ECFP')
train_dataset, valid_dataset, test_dataset = datasets
print(train_dataset)<jupyter_output><DiskDataset X.shape: (513, 1024), y.shape: (513, 1), w.shape: (513, 1), ids: ['CS(=O)(=O)Cl' 'CC(C)C=C' 'CCCCCCCO' ... 'C1CCC(=O)CC1'
 'C[C@@H]1CC[C@H](C(=O)C1)C(C)C' 'C[C@@H]1CC[C@H](CC1=O)C(=C)C'], task_names: ['expt']><jupyter_text>ECFP featurizer is used. Extended Connectivity Fingerprints  is a **fingerprinting** method. They are also sometimes called "circular fingerprints". The ECFP algorithm begins by classifying atoms based only on their direct properties and bonds. Each unique pattern is a feature. For example, "carbon atom bonded to two hydrogens and two heavy atoms" would be a feature, and a particular element of the fingerprint is set to 1 for any molecule that contains that feature. It then iteratively identifies new features by looking at larger circular neighborhoods. One specific feature bonded to two other specific features becomes a higher level feature, and the corresponding element is set for any molecule that contains it. This continues for a fixed number of iterations, most often two.<jupyter_code>tasks<jupyter_output><empty_output><jupyter_text>Above are the tasks in the Tox21 dataset - there are 12 tasks, each corresponding to different biotoxicity targets, such as cell receptors and stress response pathways.<jupyter_code>datasets<jupyter_output><empty_output><jupyter_text>There are three dataset objects - train split, val split and test split. Each split consists of X and y - X is the features and y is the output label. Froe example the train split has X.shape (513, 1024)and y.shape (513, 1). This implies that there are 513 samples in the train split - and each sample is represented by an ECFP vector of size 1024.  Training a Model on Fingerprints<jupyter_code>model = dc.models.MultitaskRegressor(n_tasks=1, n_features=1024, layer_sizes=[1000])<jupyter_output><empty_output><jupyter_text>`MultitaskClassifier` is a simple stack of fully connected layers. A single hidden layer of width 1000 is used. Each input will have 1024 features, and it should produce predictions for 12 different tasks.Note that the above network is performing multitask learning - a single network is used for all 12 tasks. This is because inter task correlations exist in the data, and to take if advantage of this single neural network is used for multiple tasks.<jupyter_code>import numpy as np

model.fit(train_dataset, nb_epoch=10)
metric = dc.metrics.Metric(dc.metrics.pearson_r2_score)
print('training set score:', model.evaluate(train_dataset, [metric], transformers))
print('test set score:', model.evaluate(test_dataset, [metric], transformers))<jupyter_output>training set score: {'pearson_r2_score': 0.849167746922176}
test set score: {'pearson_r2_score': 0.16165382288093907}
{'fraction_non_alphanumeric': 0.10539325842696629, 'fraction_numerical': 0.05056179775280899, 'mean_word_length': 6.065079365079365, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 30, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '134706', 'license': 'MIT', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1405, 'n_words': 450, 'path': 'baselines/FREESOLV_Overview.ipynb', 'repo_name': 'nihal-rao/deepchem', 'size': '4450'}