<jupyter_start><jupyter_text>Evaluating on Texts with LabelsYou can run the following two cells to get a random example from the dataset and compare the model prediction with the true labels.<jupyter_code>from mimic_data import load_dummy
import random

#get the data for an example evaluation. 
In_Text,labels=load_dummy()
#take a random text
example=random.randint(0,len(In_Text))
pred_text=In_Text[example]
true_labels=labels[example]<jupyter_output><empty_output><jupyter_text>Evaluating on a new TextYou can type a new text for prediction here, for final prediction.<jupyter_code>pred_text= '''DIMESSO CON DIASGNOSI di Anasarca. IRC 4 stadio in terapia conservativa (GFR 29 ml/min), nefropatia
    tubulointerstiziale cronica, proteinuria nefrosica secondaria (probabile paraneoplastica) in terapia steroidea.
    Infezione urinaria da Klebsiella Oxytoca ed <NAME>. Cardiopatia sclerotica scompensata; FA permanente in
    terapia con EBPM, portatore di protesi vascolare aortica per aneurisma dell aorta ascendente e bioprotesi valvolare
    aortica. Diabete mellito insulino-trattato, BPCO severa.
    Uropatia ostruttiva e verosimile neoplasia vescicale infiltrante, portatore di Foley a dimora.
    Eritrodermia (Amoxicillina-Clavulanico?).Vasculopatia pluridistrettuale. Invalidamento motorio.'''
#clean the text, the input has to be in a list
pred_text_clean=[clean_note(pred_text)]
#code it correctly with the tokenizer
#important this has to be wrapped in a list again
In_code=[word_tokenizer.texts_to_sequences(pred_text_clean)]
#run a predict of the model 
p=model.predict(In_code)[0]
#get predictions larger than a threshhold. alternatively top n predictions
#top n prediction function
thresh=0.9
pred_codes=np.where(p>thresh)[1]
p_val=p[p>thresh]
#decode the predictions
pred_codes_decode=[reverse_label_tokenizer[j] for j in pred_codes ]
#predicted labels with confidence 
pd.DataFrame(np.transpose(np.vstack([pred_codes_decode,p_val]))).sort_values(by=1,ascending=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06835066864784546, 'fraction_numerical': 0.004457652303120356, 'mean_word_length': 6.769230769230769, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, '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': '248225', 'license': 'Apache-2.0', 'n_tokens_mistral': 694, 'n_tokens_neox': 663, 'n_words': 206, 'path': 'Inference_demo.ipynb', 'repo_name': 'PiSchool/icd9-labelling', 'size': '2029'}