{ "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", " | test | \n", "year | \n", "theme | \n", "match_spanish | \n", "match_tagalog | \n", "match_portuguese | \n", "match_english | \n", "Total | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "Teórica I | \n", "2022 | \n", "anatomy | \n", "7 | \n", "3 | \n", "8 | \n", "12 | \n", "21 | \n", "
1 | \n", "Teórica I | \n", "2022 | \n", "cornea | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "
2 | \n", "Teórica I | \n", "2022 | \n", "embryology | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "2 | \n", "
3 | \n", "Teórica I | \n", "2022 | \n", "genetics | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "2 | \n", "
4 | \n", "Teórica I | \n", "2022 | \n", "glaucoma | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "
5 | \n", "Teórica I | \n", "2022 | \n", "oncology | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "
6 | \n", "Teórica I | \n", "2022 | \n", "pharmacology | \n", "3 | \n", "2 | \n", "3 | \n", "2 | \n", "3 | \n", "
7 | \n", "Teórica I | \n", "2022 | \n", "refraction | \n", "5 | \n", "4 | \n", "6 | \n", "3 | \n", "12 | \n", "
8 | \n", "Teórica I | \n", "2022 | \n", "retina | \n", "1 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "
9 | \n", "Teórica II | \n", "2022 | \n", "contact lenses | \n", "2 | \n", "2 | \n", "0 | \n", "3 | \n", "3 | \n", "
10 | \n", "Teórica II | \n", "2022 | \n", "cornea | \n", "3 | \n", "1 | \n", "2 | \n", "2 | \n", "9 | \n", "
11 | \n", "Teórica II | \n", "2022 | \n", "cornea/lens | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "
12 | \n", "Teórica II | \n", "2022 | \n", "glaucoma | \n", "4 | \n", "3 | \n", "4 | \n", "4 | \n", "8 | \n", "
13 | \n", "Teórica II | \n", "2022 | \n", "glaucoma/uveitis | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "
14 | \n", "Teórica II | \n", "2022 | \n", "lens/cataract | \n", "4 | \n", "3 | \n", "5 | \n", "4 | \n", "8 | \n", "
15 | \n", "Teórica II | \n", "2022 | \n", "low vision | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "
16 | \n", "Teórica II | \n", "2022 | \n", "neuro-ophthalmology | \n", "5 | \n", "4 | \n", "3 | \n", "4 | \n", "7 | \n", "
17 | \n", "Teórica II | \n", "2022 | \n", "ocular plastic surgery | \n", "6 | \n", "6 | \n", "11 | \n", "9 | \n", "16 | \n", "
18 | \n", "Teórica II | \n", "2022 | \n", "oncology/ocular plastic surgery | \n", "2 | \n", "2 | \n", "2 | \n", "3 | \n", "3 | \n", "
19 | \n", "Teórica II | \n", "2022 | \n", "optics | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "
20 | \n", "Teórica II | \n", "2022 | \n", "optics/refraction | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "1 | \n", "
21 | \n", "Teórica II | \n", "2022 | \n", "pharmacology | \n", "3 | \n", "3 | \n", "2 | \n", "3 | \n", "6 | \n", "
22 | \n", "Teórica II | \n", "2022 | \n", "pharmacology/glaucoma | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "
23 | \n", "Teórica II | \n", "2022 | \n", "refraction | \n", "9 | \n", "8 | \n", "7 | \n", "8 | \n", "19 | \n", "
24 | \n", "Teórica II | \n", "2022 | \n", "refraction/low vision | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "2 | \n", "
25 | \n", "Teórica II | \n", "2022 | \n", "refractive surgery | \n", "2 | \n", "1 | \n", "2 | \n", "2 | \n", "2 | \n", "
26 | \n", "Teórica II | \n", "2022 | \n", "retina | \n", "5 | \n", "4 | \n", "4 | \n", "6 | \n", "11 | \n", "
27 | \n", "Teórica II | \n", "2022 | \n", "retina/oncology | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "
28 | \n", "Teórica II | \n", "2022 | \n", "strabismus | \n", "8 | \n", "4 | \n", "6 | \n", "7 | \n", "11 | \n", "
29 | \n", "Teórica II | \n", "2022 | \n", "uveitis | \n", "3 | \n", "2 | \n", "3 | \n", "4 | \n", "8 | \n", "