<jupyter_start><jupyter_text>Testing classification results<jupyter_code>from astropy.table import Table
from astropy.table import join
import numpy as np
def test_results(results_table_path,truth_table_path):
    results_table = Table.read(results_table_path)
    truth_table = Table.read(truth_table_path)
    joint_table = join(results_table,truth_table,'TARGETID')
    detected_qso = joint_table['OBJTYPE']=='QSO'
    detected_star = joint_table['OBJTYPE']=='STAR'
    real_qso = joint_table['TRUE_OBJTYPE']=='QSO'
    real_star = joint_table['TRUE_OBJTYPE']=='STAR'
    good_qso = np.logical_and(detected_qso,real_qso)
    good_star = np.logical_and(detected_star,real_star)
    bad_qso = np.logical_and(detected_qso,real_star)
    bad_star = np.logical_and(detected_star,real_qso)
    nqso_good = np.count_nonzero(good_qso)
    nstar_good = np.count_nonzero(good_star)
    nqso_bad = np.count_nonzero(bad_qso)
    nstar_bad = np.count_nonzero(bad_star)
    rqso_qso =nqso_good/(1.0*len(real_qso))
    rqso_star = nstar_bad/(1.0*len(real_qso))
    rstar_qso = nqso_bad/(1.0*len(real_star))
    rstar_star = nstar_good/(1.0*len(real_star))
    print 'Ratio of QSO detected as QSO %.3f' %(rqso_qso)
    print 'Ratio of QSO detected as STAR %.3f'%(rqso_star)
    print 'Ratio of STARS detected as QSO %.3f'%(rstar_qso)
    print 'Ratio of STARS detected as STARS %.3f' %(rstar_star)<jupyter_output><empty_output><jupyter_text>The output table should contain at least the `'TARGETID'` and `'OBJTYPE'` columns and be in<jupyter_code>fake_ids = np.array([['QSO']*1000,['STAR']*1000])
fake_ids = fake_ids.flatten()
tab = Table.read()
targetid = tab['TARGETID'].data
np.random.shuffle(fake_ids)
test_table = Table([targetid,fake_ids],names=('TARGETID','OBJTYPE'))
test_table.write()
test_results()<jupyter_output>Ratio of QSO detected as QSO 0.259
Ratio of QSO detected as STAR 0.241
Ratio of STARS detected as QSO 0.241
Ratio of STARS detected as STARS 0.259
{'fraction_non_alphanumeric': 0.12065439672801637, 'fraction_numerical': 0.018404907975460124, 'mean_word_length': 5.725085910652921, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '637006', 'license': 'MIT', 'n_tokens_mistral': 792, 'n_tokens_neox': 748, 'n_words': 141, 'path': 'TestQSOClassification.ipynb', 'repo_name': 'fjaviersanchez/OSULymanAlpha', 'size': '1956'}