{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Model Comparison\n", "\n", "This notebook connects to the MLflow tracking server and compares the results of our models.\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import mlflow\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import json\n", "\n", "mlflow.set_tracking_uri('sqlite:///mlflow/mlflow.db')\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Load all runs\n", "experiment = mlflow.get_experiment_by_name('multilingual-absa')\n", "df = mlflow.search_runs(experiment_ids=[experiment.experiment_id])\n", "display(df.head())\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Bar chart: macro-F1 comparison\n", "metrics = df[['tags.mlflow.runName', 'metrics.eval_macro_f1', 'metrics.test_f1', 'metrics.test_macro_f1', 'metrics.hindi_zero_shot_macro_f1']].fillna(0)\n", "metrics['Best F1'] = metrics[['metrics.eval_macro_f1', 'metrics.test_f1', 'metrics.test_macro_f1']].max(axis=1)\n", "\n", "plt.figure(figsize=(10, 6))\n", "sns.barplot(data=metrics, x='tags.mlflow.runName', y='Best F1')\n", "plt.title('Model Comparison by Macro-F1 / Span-F1')\n", "plt.xticks(rotation=45)\n", "plt.show()\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# Load confusion matrix for best sentiment classifier\n", "# Note: Assuming the confusion_matrix.json artifact was downloaded or parsed.\n", "print('Confusion Matrix (Placeholder for artifact loading)')\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "# 5 Example Predictions\n", "print('Example 1: The food was great but service was slow.')\n", "print('Example 2: El sistema operativo es muy estable.')\n", "print('... (Load pipeline and infer here)')\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.11.0" } }, "nbformat": 4, "nbformat_minor": 4 }