{ "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": null, "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": null, "id": "464a2aaa", "metadata": { "height": 47, "tags": [] }, "outputs": [], "source": [ "PATH = 'data/full_dataset.csv'\n", "MODEL = \"mistralai/Mixtral-8x7B-Instruct-v0.1\"\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": null, "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": null, "id": "a58184aa", "metadata": { "height": 30, "tags": [] }, "outputs": [], "source": [ "import os\n", "MODEL = os.path.basename(MODEL)\n", "\n", "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": null, "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 I2022anatomy7381221
1Teórica I2022cornea00011
2Teórica I2022embryology01112
3Teórica I2022genetics00112
4Teórica I2022glaucoma11111
5Teórica I2022oncology11111
6Teórica I2022pharmacology32323
7Teórica I2022refraction546312
8Teórica I2022retina10111
9Teórica II2022contact lenses22033
10Teórica II2022cornea31229
11Teórica II2022cornea/lens11111
12Teórica II2022glaucoma43448
13Teórica II2022glaucoma/uveitis00011
14Teórica II2022lens/cataract43548
15Teórica II2022low vision00111
16Teórica II2022neuro-ophthalmology54347
17Teórica II2022ocular plastic surgery6611916
18Teórica II2022oncology/ocular plastic surgery22233
19Teórica II2022optics10001
20Teórica II2022optics/refraction00101
21Teórica II2022pharmacology33236
22Teórica II2022pharmacology/glaucoma11111
23Teórica II2022refraction987819
24Teórica II2022refraction/low vision00002
25Teórica II2022refractive surgery21222
26Teórica II2022retina544611
27Teórica II2022retina/oncology00001
28Teórica II2022strabismus846711
29Teórica II2022uveitis32348
\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 3 \n", "7 Teórica I 2022 refraction 5 \n", "8 Teórica I 2022 retina 1 \n", "9 Teórica II 2022 contact lenses 2 \n", "10 Teórica II 2022 cornea 3 \n", "11 Teórica II 2022 cornea/lens 1 \n", "12 Teórica II 2022 glaucoma 4 \n", "13 Teórica II 2022 glaucoma/uveitis 0 \n", "14 Teórica II 2022 lens/cataract 4 \n", "15 Teórica II 2022 low vision 0 \n", "16 Teórica II 2022 neuro-ophthalmology 5 \n", "17 Teórica II 2022 ocular plastic surgery 6 \n", "18 Teórica II 2022 oncology/ocular plastic surgery 2 \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 1 \n", "23 Teórica II 2022 refraction 9 \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 5 \n", "27 Teórica II 2022 retina/oncology 0 \n", "28 Teórica II 2022 strabismus 8 \n", "29 Teórica II 2022 uveitis 3 \n", "\n", " match_tagalog match_portuguese match_english Total \n", "0 3 8 12 21 \n", "1 0 0 1 1 \n", "2 1 1 1 2 \n", "3 0 1 1 2 \n", "4 1 1 1 1 \n", "5 1 1 1 1 \n", "6 2 3 2 3 \n", "7 4 6 3 12 \n", "8 0 1 1 1 \n", "9 2 0 3 3 \n", "10 1 2 2 9 \n", "11 1 1 1 1 \n", "12 3 4 4 8 \n", "13 0 0 1 1 \n", "14 3 5 4 8 \n", "15 0 1 1 1 \n", "16 4 3 4 7 \n", "17 6 11 9 16 \n", "18 2 2 3 3 \n", "19 0 0 0 1 \n", "20 0 1 0 1 \n", "21 3 2 3 6 \n", "22 1 1 1 1 \n", "23 8 7 8 19 \n", "24 0 0 0 2 \n", "25 1 2 2 2 \n", "26 4 4 6 11 \n", "27 0 0 0 1 \n", "28 4 6 7 11 \n", "29 2 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": null, "id": "c23866b3-c0c6-42de-968c-6994b2b8b7fa", "metadata": {}, "outputs": [], "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.18" } }, "nbformat": 4, "nbformat_minor": 5 }