<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"""
Evaluate using sider as TP and likelyfalse as TN
"""

import os
import sys
import MySQLdb

from namedmatrix import NamedMatrix
from pyweka import MachineLearning as ml

c = MySQLdb.connect(host="localhost", port=3307, user="root", passwd="enter_your_password",db="project_aers").cursor()

query = """
select stitch_id, umls_id, e.prr e, p.prr p, p.prr/e.prr r, gold is not null as label
from pred_drug_events_e5 e
join prop_pred_drug_events p using (stitch_id, umls_id)
left join gold_drug_ae_union using (stitch_id, umls_id)
left join likelyfalse_drug_ae_all lf using (stitch_id, umls_id)
where (gold is not null or numlf is not null)
"""
c.execute(query)

data = c.fetchall()
labels = [x[-1] for x in data]

feat = NamedMatrix(None, map(str,range(len(data))), ['e','p','r'])

for i in range(len(data)):
    feat[i,0] = data[i][2]
    feat[i,1] = data[i][3]
    feat[i,2] = data[i][4]

e = ml.Logistic(feat[:,0], labels)
e.cross_validate()

p = ml.Logistic(feat[:,1], labels)
p.cross_validate()
    </pre></body></html>