machinelearning

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 8c10e4a12b13cd54a8af0a73edad20d8b8ffbf5a
parent e23879d5f5e27fbec6e1eec7a78e2a5072ccce72
Author: Andrew <andrewlaack1@gmail.com>
Date:   Wed, 17 Jul 2024 18:03:16 -0500

added polynomial feature logistic regression.

Diffstat:
Mdiabetes/DiabetesPrediction.ipynb | 47+++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+), 0 deletions(-)

diff --git a/diabetes/DiabetesPrediction.ipynb b/diabetes/DiabetesPrediction.ipynb @@ -8,6 +8,13 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Logistic regression was almost 80% accurate followed closely at 77% by a neural network. Adaboost, Random Forest, and Polynomial feature logistic regression were in the low 70s." + ] + }, + { "cell_type": "code", "execution_count": 374, "metadata": {}, @@ -4714,6 +4721,46 @@ "accuracies.append(\"Neural Network: \" + str(accuracy_score(y_true=y_test,y_pred=y_pred)))\n", "accuracies" ] + }, + { + "cell_type": "code", + "execution_count": 414, + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.preprocessing import PolynomialFeatures\n", + "\n", + "poly = PolynomialFeatures(degree=2)\n", + "X_train_poly = poly.fit_transform(X_train)\n", + "X_val_poly = poly.transform(X_val)\n", + "X_test_poly = poly.transform(X_test)\n", + "\n", + "\n", + "log_reg = LogisticRegression()\n", + "log_reg = log_reg.fit(X_train_poly,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 415, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.7604166666666666" + ] + }, + "execution_count": 415, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = log_reg.predict(X_test_poly)\n", + "\n", + "accuracy_score(y_true=y_test,y_pred=y_pred)" + ] } ], "metadata": {