From adddd4680604740a6e5949938e616e5f52e9db76 Mon Sep 17 00:00:00 2001 From: Andrea Cantu Date: Mon, 14 Oct 2024 15:08:45 -0600 Subject: [PATCH] Se agregaron parametros al modelo --- notebooks/BoneMarrow_EDA.ipynb | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/notebooks/BoneMarrow_EDA.ipynb b/notebooks/BoneMarrow_EDA.ipynb index 6a28098..16de88a 100644 --- a/notebooks/BoneMarrow_EDA.ipynb +++ b/notebooks/BoneMarrow_EDA.ipynb @@ -1251,6 +1251,84 @@ "metadata": {}, "outputs": [], "source": [] + }, + { + "cell_type": "markdown", + "id": "a78103c8", + "metadata": {}, + "source": [ + "## Fase 2" + ] + }, + { + "cell_type": "markdown", + "id": "7e303b3e", + "metadata": {}, + "source": [ + "## Seguimiento de Experimentos" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "24946793", + "metadata": {}, + "outputs": [], + "source": [ + "model = RandomForestClassifier(n_estimators=90, max_depth=7, max_features=3)\n", + "model.fit(X_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d40ab43c", + "metadata": {}, + "outputs": [], + "source": [ + "y_pred = model.predict(X_test)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b5ee6301", + "metadata": {}, + "outputs": [], + "source": [ + "# Confusion matrix\n", + "cm = confusion_matrix(y_test, y_pred)\n", + "plt.figure(figsize=(10,7))\n", + "sns.heatmap(cm, annot=True, fmt='d', cmap='Blues', xticklabels=np.unique(y), yticklabels=np.unique(y))\n", + "plt.xlabel('Predicted')\n", + "plt.ylabel('True')\n", + "plt.title('Confusion Matrix')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6fa64ab0", + "metadata": {}, + "outputs": [], + "source": [ + "# Report\n", + "report = classification_report(y_test, y_pred, output_dict=True)\n", + "report_df = pd.DataFrame(report).transpose()\n", + "print(report_df)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "007141ab", + "metadata": {}, + "outputs": [], + "source": [ + "scores = cross_val_score(model, X, y, cv=5)\n", + "print(\"Average accuracy with CV:\", np.mean(scores))" + ] } ], "metadata": {