<jupyter_start><jupyter_text>**The goal of our model building is we want to see which functional group or fingerprints are essential for designing a good drug or a potent one.**<jupyter_code>import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from google.colab import drive
drive.mount('/content/gdrive/', force_remount = True)
df = pd.read_csv("/content/gdrive/MyDrive/Colab Notebooks/data/acetylcholinesterase_dataset_for_model.csv")
df<jupyter_output><empty_output><jupyter_text>**Features**<jupyter_code># Input Feature
X = df.drop('pIC50', axis=1)
X
# Output Feature
Y = df["pIC50"]
Y<jupyter_output><empty_output><jupyter_text>**Removing Features with low variance**<jupyter_code>from sklearn.feature_selection import VarianceThreshold
selection = VarianceThreshold(threshold=(.85 * (1 - .85)))    
x = selection.fit_transform(X)
x.shape<jupyter_output><empty_output><jupyter_text>**Test Train Split 70/30**<jupyter_code>X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.3)
X_train.shape, Y_train.shape, X_test.shape, Y_test.shape
x_train, x_test, y_train, y_test = train_test_split(x, Y, test_size=0.3)
x_train.shape, y_train.shape, x_test.shape, y_test.shape<jupyter_output><empty_output><jupyter_text>**Random Forest Regression model**<jupyter_code># Low variance features not removed
model = RandomForestRegressor(n_estimators=100)
model.fit(X_train, Y_train)
S = model.score(X_test, Y_test)
S
# Low varinace features removed
model2 = RandomForestRegressor(n_estimators=150)
model2.fit(x_train, y_train)
s = model2.score(x_test, y_test)
s
Y_pred = model.predict(X_test)
y_pred = model2.predict(x_test)<jupyter_output><empty_output><jupyter_text>**Scatter Plot of Experimental vs Predicted pIC50 Values** **Without reomoving low variance features**<jupyter_code>sns.set(color_codes=True)
sns.set_style("white")

ax = sns.regplot(Y_test, Y_pred, scatter_kws={'alpha':0.4})
ax.set_xlabel('Experimental pIC50', fontsize='large', fontweight='bold')
ax.set_ylabel('Predicted pIC50', fontsize='large', fontweight='bold')
ax.set_xlim(0, 12)
ax.set_ylim(0, 12)
ax.figure.set_size_inches(5.5, 5.5)
plt.show<jupyter_output>/usr/local/lib/python3.6/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning<jupyter_text>**After reomoving low variance features**<jupyter_code>sns.set(color_codes=True)
sns.set_style("white")

ax = sns.regplot(y_test, y_pred, scatter_kws={'alpha':0.4})
ax.set_xlabel('Experimental pIC50', fontsize='large', fontweight='bold')
ax.set_ylabel('Predicted pIC50', fontsize='large', fontweight='bold')
ax.set_xlim(0, 12)
ax.set_ylim(0, 12)
ax.figure.set_size_inches(6, 6)
plt.show<jupyter_output>/usr/local/lib/python3.6/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
{'fraction_non_alphanumeric': 0.11540749553837001, 'fraction_numerical': 0.022010707911957167, 'mean_word_length': 6.875878220140515, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '667124', 'license': 'MIT', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1208, 'n_words': 268, 'path': 'Acetylcholinesterase_RandomForest.ipynb', 'repo_name': 'kaustubhadixit/BioInformatics', 'size': '3362'}