{ "cells": [ { "cell_type": "markdown", "id": "dc3852ca", "metadata": {}, "source": [ "# Evaluate Classification" ] }, { "cell_type": "markdown", "id": "3a2d9fbf", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "id": "45140c6e", "metadata": {}, "source": [ "#### Load the API key and libaries." ] }, { "cell_type": "code", "execution_count": 1, "id": "e7bf1b8e", "metadata": { "height": 115, "tags": [] }, "outputs": [], "source": [ "from src.Language_Evaluation_LC import llm_language_evaluation\n", "from src.data_analysis import run_analysis\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "10e95383", "metadata": { "height": 30 }, "source": [ "#### Load the Constants" ] }, { "cell_type": "code", "execution_count": 2, "id": "464a2aaa", "metadata": { "height": 47, "tags": [] }, "outputs": [], "source": [ "PATH = 'data/full_dataset.csv'\n", "MODEL = 'gpt-3.5-turbo-0125' #\"gpt-3.5-turbo\" \"gpt-4-turbo-preview\"\n", "TEMPERATURE = 0.0\n", "N_REPETITIONS = 0\n", "REASONING = False\n", "LANGUAGES = ['spanish', 'tagalog', 'portuguese', 'english']" ] }, { "cell_type": "markdown", "id": "92663014", "metadata": {}, "source": [ "#### Run The Experiments:" ] }, { "cell_type": "code", "execution_count": 1, "id": "7c7ccfa1", "metadata": { "tags": [] }, "outputs": [], "source": [ "# Run evaluation:\n", "llm_language_evaluation(path=PATH, model=MODEL, temperature=TEMPERATURE, n_repetitions=N_REPETITIONS, reasoning=REASONING, languages=LANGUAGES)" ] }, { "cell_type": "markdown", "id": "079dcbc4", "metadata": {}, "source": [ "#### See the results" ] }, { "cell_type": "code", "execution_count": 4, "id": "a58184aa", "metadata": { "height": 30, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
IDyeartestthemesubthemeportuguesespanishenglishtagaloganswerresponses_spanishresponses_spanish_0responses_tagalogresponses_tagalog_0responses_portugueseresponses_portuguese_0responses_englishresponses_english_0
012022Teórica IAnatomiacorneaEm qual região ocular células caliciformes são...¿En qué región ocular se encuentran fisiológic...In which ocular region are caliciform cells ph...Aling bahagi ng mata ay kung saan matatagpuan ...Dbbaabbbb
122022Teórica IAnatomiaretinaAssinale a alternativa que melhor correlaciona...Marque la alternativa que mejor correlaciona l...Mark the alternative that best correlates the ...Ipagpares ang bahagi ng retina sa Hanay B sa t...BbbBBbbaa
232022Teórica IAnatomiacorneaOrdene as três denominações celulares encontra...Ordene los tres nombres de células que se encu...Order the three cell names found in the cornea...Ipagsunud-sunod ang mga cells ng corneal epith...AccDDccCC
342022Teórica IAnatomiacorneaSobre a membrana de Descemet da córnea, é corr...Con respecto a la membrana de la córnea de Des...Regarding Descemet's membrane of the cornea, i...Tama tungkol sa Descemet's membrane ng cornea:...CBBDDDDCC
452022Teórica IAnatomiacorneaSobre a camada lipídica do filme lacrimal, ass...Respecto a la capa lipídica de la película lag...About the lipidic layer of the lacrimal film, ...Piliin ang tamang sagot tungkol sa lipid layer...BBBAABBBB
.........................................................
1591612022Teórica IICristalino/CatarataNaNApós bloqueio retrobulbar para realização de c...Tras el bloqueo retrobulbar para realizar la c...After retrobulbar block for phacoemulsificatio...Matapos ang retrobulbar block para sa phacoemu...CaaddCCaa
1601622022Teórica IICristalino/CatarataNaNSobre a biometria em olhos tamponados por óleo...Respecto a la biometría en ojos tamponados con...Regarding biometrics in eyes covered with sili...Alin sa mga sumusunod na pahayag patungkol sa ...DAAAAAADD
1611632022Teórica IICristalino/CatarataNaNAssinale a alternativa que contém, respectivam...Seleccionar la alternativa que contenga, respe...Check the alternative that contains, respectiv...Alin sa mga sumusunod na tambalan patungkol sa...ADDDDDDDD
1621642022Teórica IICristalino/CatarataNaNSobre a prevenção de endoftalmite em cirurgia ...En cuanto a la prevención de endoftalmitis en ...Regarding the prevention of endophthalmitis in...Alin sa mga sumusunod na pamamaraan upang mapi...BBBCCBBbb
1631652022Teórica IICristalino/CatarataNaNApós realizar as fraturas do núcleo com a técn...Después de realizar las fracturas del núcleo c...After performing the core fractures with the d...Matapos isagawa ang core fractures gamit ang d...Cddbbaabb
\n", "

164 rows × 18 columns

\n", "
" ], "text/plain": [ " ID year test theme subtheme \\\n", "0 1 2022 Teórica I Anatomia cornea \n", "1 2 2022 Teórica I Anatomia retina \n", "2 3 2022 Teórica I Anatomia cornea \n", "3 4 2022 Teórica I Anatomia cornea \n", "4 5 2022 Teórica I Anatomia cornea \n", ".. ... ... ... ... ... \n", "159 161 2022 Teórica II Cristalino/Catarata NaN \n", "160 162 2022 Teórica II Cristalino/Catarata NaN \n", "161 163 2022 Teórica II Cristalino/Catarata NaN \n", "162 164 2022 Teórica II Cristalino/Catarata NaN \n", "163 165 2022 Teórica II Cristalino/Catarata NaN \n", "\n", " portuguese \\\n", "0 Em qual região ocular células caliciformes são... \n", "1 Assinale a alternativa que melhor correlaciona... \n", "2 Ordene as três denominações celulares encontra... \n", "3 Sobre a membrana de Descemet da córnea, é corr... \n", "4 Sobre a camada lipídica do filme lacrimal, ass... \n", ".. ... \n", "159 Após bloqueio retrobulbar para realização de c... \n", "160 Sobre a biometria em olhos tamponados por óleo... \n", "161 Assinale a alternativa que contém, respectivam... \n", "162 Sobre a prevenção de endoftalmite em cirurgia ... \n", "163 Após realizar as fraturas do núcleo com a técn... \n", "\n", " spanish \\\n", "0 ¿En qué región ocular se encuentran fisiológic... \n", "1 Marque la alternativa que mejor correlaciona l... \n", "2 Ordene los tres nombres de células que se encu... \n", "3 Con respecto a la membrana de la córnea de Des... \n", "4 Respecto a la capa lipídica de la película lag... \n", ".. ... \n", "159 Tras el bloqueo retrobulbar para realizar la c... \n", "160 Respecto a la biometría en ojos tamponados con... \n", "161 Seleccionar la alternativa que contenga, respe... \n", "162 En cuanto a la prevención de endoftalmitis en ... \n", "163 Después de realizar las fracturas del núcleo c... \n", "\n", " english \\\n", "0 In which ocular region are caliciform cells ph... \n", "1 Mark the alternative that best correlates the ... \n", "2 Order the three cell names found in the cornea... \n", "3 Regarding Descemet's membrane of the cornea, i... \n", "4 About the lipidic layer of the lacrimal film, ... \n", ".. ... \n", "159 After retrobulbar block for phacoemulsificatio... \n", "160 Regarding biometrics in eyes covered with sili... \n", "161 Check the alternative that contains, respectiv... \n", "162 Regarding the prevention of endophthalmitis in... \n", "163 After performing the core fractures with the d... \n", "\n", " tagalog answer \\\n", "0 Aling bahagi ng mata ay kung saan matatagpuan ... D \n", "1 Ipagpares ang bahagi ng retina sa Hanay B sa t... B \n", "2 Ipagsunud-sunod ang mga cells ng corneal epith... A \n", "3 Tama tungkol sa Descemet's membrane ng cornea:... C \n", "4 Piliin ang tamang sagot tungkol sa lipid layer... B \n", ".. ... ... \n", "159 Matapos ang retrobulbar block para sa phacoemu... C \n", "160 Alin sa mga sumusunod na pahayag patungkol sa ... D \n", "161 Alin sa mga sumusunod na tambalan patungkol sa... A \n", "162 Alin sa mga sumusunod na pamamaraan upang mapi... B \n", "163 Matapos isagawa ang core fractures gamit ang d... C \n", "\n", " responses_spanish responses_spanish_0 responses_tagalog \\\n", "0 b b a \n", "1 b b B \n", "2 c c D \n", "3 B B D \n", "4 B B A \n", ".. ... ... ... \n", "159 a a d \n", "160 A A A \n", "161 D D D \n", "162 B B C \n", "163 d d b \n", "\n", " responses_tagalog_0 responses_portuguese responses_portuguese_0 \\\n", "0 a b b \n", "1 B b b \n", "2 D c c \n", "3 D D D \n", "4 A B B \n", ".. ... ... ... \n", "159 d C C \n", "160 A A A \n", "161 D D D \n", "162 C B B \n", "163 b a a \n", "\n", " responses_english responses_english_0 \n", "0 b b \n", "1 a a \n", "2 C C \n", "3 C C \n", "4 B B \n", ".. ... ... \n", "159 a a \n", "160 D D \n", "161 D D \n", "162 b b \n", "163 b b \n", "\n", "[164 rows x 18 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "if N_REPETITIONS > 1:\n", " df = pd.read_csv(f\"responses/{MODEL}_Temperature{str(TEMPERATURE).replace('.', '_')}_{N_REPETITIONS}Repetitions.csv\")\n", "else:\n", " df = pd.read_csv(f\"responses/{MODEL}_Temperature{str(TEMPERATURE).replace('.', '_')}.csv\")\n", "\n", "df" ] }, { "cell_type": "markdown", "id": "041dc525", "metadata": {}, "source": [ "### Data Analysis" ] }, { "cell_type": "code", "execution_count": 2, "id": "85f6bb97", "metadata": { "tags": [] }, "outputs": [], "source": [ "TEMPERATURE = str(TEMPERATURE).replace('.', '_')\n", "\n", "run_analysis(model=MODEL, temperature=TEMPERATURE, n_repetitions=N_REPETITIONS, languages=LANGUAGES)" ] }, { "cell_type": "code", "execution_count": 6, "id": "dffeddc1", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
testyearthemematch_spanishmatch_tagalogmatch_portuguesematch_englishTotal
0Teórica I2022anatomy766721
1Teórica I2022cornea00111
2Teórica I2022embryology00002
3Teórica I2022genetics01102
4Teórica I2022glaucoma11111
5Teórica I2022oncology11111
6Teórica I2022pharmacology21223
7Teórica I2022refraction657412
8Teórica I2022retina10011
9Teórica II2022contact lenses10013
10Teórica II2022cornea41359
11Teórica II2022cornea/lens11111
12Teórica II2022glaucoma23328
13Teórica II2022glaucoma/uveitis10101
14Teórica II2022lens/cataract42548
15Teórica II2022low vision10101
16Teórica II2022neuro-ophthalmology32337
17Teórica II2022ocular plastic surgery775716
18Teórica II2022oncology/ocular plastic surgery10113
19Teórica II2022optics10001
20Teórica II2022optics/refraction00101
21Teórica II2022pharmacology32226
22Teórica II2022pharmacology/glaucoma01101
23Teórica II2022refraction121110919
24Teórica II2022refraction/low vision00002
25Teórica II2022refractive surgery21222
26Teórica II2022retina735711
27Teórica II2022retina/oncology00001
28Teórica II2022strabismus647611
29Teórica II2022uveitis33348
\n", "
" ], "text/plain": [ " test year theme match_spanish \\\n", "0 Teórica I 2022 anatomy 7 \n", "1 Teórica I 2022 cornea 0 \n", "2 Teórica I 2022 embryology 0 \n", "3 Teórica I 2022 genetics 0 \n", "4 Teórica I 2022 glaucoma 1 \n", "5 Teórica I 2022 oncology 1 \n", "6 Teórica I 2022 pharmacology 2 \n", "7 Teórica I 2022 refraction 6 \n", "8 Teórica I 2022 retina 1 \n", "9 Teórica II 2022 contact lenses 1 \n", "10 Teórica II 2022 cornea 4 \n", "11 Teórica II 2022 cornea/lens 1 \n", "12 Teórica II 2022 glaucoma 2 \n", "13 Teórica II 2022 glaucoma/uveitis 1 \n", "14 Teórica II 2022 lens/cataract 4 \n", "15 Teórica II 2022 low vision 1 \n", "16 Teórica II 2022 neuro-ophthalmology 3 \n", "17 Teórica II 2022 ocular plastic surgery 7 \n", "18 Teórica II 2022 oncology/ocular plastic surgery 1 \n", "19 Teórica II 2022 optics 1 \n", "20 Teórica II 2022 optics/refraction 0 \n", "21 Teórica II 2022 pharmacology 3 \n", "22 Teórica II 2022 pharmacology/glaucoma 0 \n", "23 Teórica II 2022 refraction 12 \n", "24 Teórica II 2022 refraction/low vision 0 \n", "25 Teórica II 2022 refractive surgery 2 \n", "26 Teórica II 2022 retina 7 \n", "27 Teórica II 2022 retina/oncology 0 \n", "28 Teórica II 2022 strabismus 6 \n", "29 Teórica II 2022 uveitis 3 \n", "\n", " match_tagalog match_portuguese match_english Total \n", "0 6 6 7 21 \n", "1 0 1 1 1 \n", "2 0 0 0 2 \n", "3 1 1 0 2 \n", "4 1 1 1 1 \n", "5 1 1 1 1 \n", "6 1 2 2 3 \n", "7 5 7 4 12 \n", "8 0 0 1 1 \n", "9 0 0 1 3 \n", "10 1 3 5 9 \n", "11 1 1 1 1 \n", "12 3 3 2 8 \n", "13 0 1 0 1 \n", "14 2 5 4 8 \n", "15 0 1 0 1 \n", "16 2 3 3 7 \n", "17 7 5 7 16 \n", "18 0 1 1 3 \n", "19 0 0 0 1 \n", "20 0 1 0 1 \n", "21 2 2 2 6 \n", "22 1 1 0 1 \n", "23 11 10 9 19 \n", "24 0 0 0 2 \n", "25 1 2 2 2 \n", "26 3 5 7 11 \n", "27 0 0 0 1 \n", "28 4 7 6 11 \n", "29 3 3 4 8 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "N_REPETITIONS = 1 if N_REPETITIONS < 1 else N_REPETITIONS\n", "pd.read_csv(f'results/results_{MODEL}_Temperature{TEMPERATURE}_Repetitions{N_REPETITIONS}/matches_results_{MODEL}.csv')" ] }, { "cell_type": "code", "execution_count": 7, "id": "c23866b3-c0c6-42de-968c-6994b2b8b7fa", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "test Teórica ITeórica ITeórica ITeórica ITeórica IT...\n", "year 60660\n", "theme anatomycorneaembryologygeneticsglaucomaoncolog...\n", "match_spanish 77\n", "match_tagalog 56\n", "match_portuguese 73\n", "match_english 71\n", "Total 164\n", "dtype: object" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.read_csv(f'results/results_{MODEL}_Temperature{TEMPERATURE}_Repetitions{N_REPETITIONS}/matches_results_{MODEL}.csv').sum()" ] }, { "cell_type": "code", "execution_count": null, "id": "1dcad7d6-7647-49c5-9804-17db4dfbc5a3", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }