Spaces:
Runtime error
Runtime error
File size: 2,963 Bytes
119802d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | {
"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
} |