<jupyter_start><jupyter_text>Exploration 01<jupyter_code>import pandas as pd 
import numpy as np

df = pd.read_csv('data/train_features.csv')
df_label_n = pd.read_csv('data/train_targets_nonscored.csv')
df_label = pd.read_csv('data/train_targets_scored.csv')
df_test = pd.read_csv('data/test_features.csv')
df.isna().sum().sum()
all(df_label['sig_id'] == df['sig_id'])
from sklearn.linear_model import LogisticRegression

reg = LogisticRegression(C=0.001)
df = df.infer_objects()
df.dtypes.value_counts()
df = df.drop(['sig_id'], axis=1)
# df = pd.get_dummies(df)
df_label = df_label.drop('sig_id', axis=1)
from sklearn.model_selection import cross_val_score
from sklearn.metrics import log_loss
df = df.drop(['cp_type', 'cp_dose'], axis=1)
scores = []
for target in df_label.columns[0:5]:
    scores.append(np.mean(np.abs(cross_val_score(reg, df, df_label[target], scoring='neg_log_loss', n_jobs=-1))))
    print(scores[-1])

print(np.mean(scores))
df_test = df_test.drop(['sig_id', 'cp_type', 'cp_dose'], axis=1)
predict_df = pd.DataFrame()

for target in df_label.columns: 
    reg = LogisticRegression(C=0.001).fit(df, df_label[target].ravel())
    predict_df[target] = reg.predict(df_test)
    print('Predicted {}, {} out of {}'.format(target, list(df_label.columns).index(target), len(df_label.columns)))<jupyter_output>Predicted 5-alpha_reductase_inhibitor, 0 out of 206
Predicted 11-beta-hsd1_inhibitor, 1 out of 206
Predicted acat_inhibitor, 2 out of 206
Predicted acetylcholine_receptor_agonist, 3 out of 206
Predicted acetylcholine_receptor_antagonist, 4 out of 206
Predicted acetylcholinesterase_inhibitor, 5 out of 206
Predicted adenosine_receptor_agonist, 6 out of 206
Predicted adenosine_receptor_antagonist, 7 out of 206
Predicted adenylyl_cyclase_activator, 8 out of 206
Predicted adrenergic_receptor_agonist, 9 out of 206
Predicted adrenergic_receptor_antagonist, 10 out of 206
Predicted akt_inhibitor, 11 out of 206
Predicted aldehyde_dehydrogenase_inhibitor, 12 out of 206
Predicted alk_inhibitor, 13 out of 206
Predicted ampk_activator, 14 out of 206
Predicted analgesic, 15 out of 206
Predicted androgen_receptor_agonist, 16 out of 206
Predicted androgen_receptor_antagonist, 17 out of 206
Predicted anesthetic_-_local, 18 out of 206
Predicted angiogenesis_inhibitor, 19 out of 206
Predicted angiotensin_[...]
{'fraction_non_alphanumeric': 0.10682110682110682, 'fraction_numerical': 0.04804804804804805, 'mean_word_length': 6.74750830564784, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '290859', 'license': 'MIT', 'n_tokens_mistral': 967, 'n_tokens_neox': 802, 'n_words': 204, 'path': 'src/notebooks/jlehrer_exploration_01.ipynb', 'repo_name': 'datascienceucsc/kaggle-moa-prediction', 'size': '2331'}