└── GaussianNB.ipynb
/GaussianNB.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "authorship_tag": "ABX9TyPdNvGtMa21p6GYkSd0ei45",
8 | "include_colab_link": true
9 | },
10 | "kernelspec": {
11 | "name": "python3",
12 | "display_name": "Python 3"
13 | },
14 | "language_info": {
15 | "name": "python"
16 | }
17 | },
18 | "cells": [
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {
22 | "id": "view-in-github",
23 | "colab_type": "text"
24 | },
25 | "source": [
26 | ""
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": null,
32 | "metadata": {
33 | "id": "ipKOzJxvoRby"
34 | },
35 | "outputs": [],
36 | "source": [
37 | "import pandas as pd\n",
38 | "import numpy as np\n",
39 | "from sklearn.naive_bayes import GaussianNB\n",
40 | "from sklearn.model_selection import train_test_split\n",
41 | "from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score"
42 | ]
43 | },
44 | {
45 | "cell_type": "code",
46 | "source": [
47 | "data = {\n",
48 | " \"GPA\": [3.8, 2.5, 3.2, 4.0, 2.8, 3.5, 3.9, 1.9],\n",
49 | " \"Attendance_Rate\": [0.90, 0.75, 0.82, 0.95, 0.68, 0.88, 0.92, 0.50],\n",
50 | " \"Standardized_Test_Score\": [1200, 980, 1100, 1350, 850, 1050, 1280, 700],\n",
51 | " \"At_Risk\": [0, 1, 0, 0, 1, 0, 0, 1] # 0: Not at risk, 1: At risk\n",
52 | "}"
53 | ],
54 | "metadata": {
55 | "id": "RdkhBmZmonyU"
56 | },
57 | "execution_count": null,
58 | "outputs": []
59 | },
60 | {
61 | "cell_type": "code",
62 | "source": [
63 | "df = pd.DataFrame(data)"
64 | ],
65 | "metadata": {
66 | "id": "uw2R6dCiotH3"
67 | },
68 | "execution_count": null,
69 | "outputs": []
70 | },
71 | {
72 | "cell_type": "code",
73 | "source": [
74 | "features = [\"GPA\", \"Attendance_Rate\", \"Standardized_Test_Score\"]\n",
75 | "target = \"At_Risk\""
76 | ],
77 | "metadata": {
78 | "id": "99PBg61bozjF"
79 | },
80 | "execution_count": null,
81 | "outputs": []
82 | },
83 | {
84 | "cell_type": "code",
85 | "source": [
86 | "# Split data into training and testing sets\n",
87 | "X_train, X_test, y_train, y_test = train_test_split(df[features], df[target], test_size=0.2)"
88 | ],
89 | "metadata": {
90 | "id": "8CG7Ozbko1p8"
91 | },
92 | "execution_count": null,
93 | "outputs": []
94 | },
95 | {
96 | "cell_type": "code",
97 | "source": [
98 | "clf = GaussianNB() # Choose GaussianNB for continuous features\n",
99 | "clf.fit(X_train, y_train)"
100 | ],
101 | "metadata": {
102 | "colab": {
103 | "base_uri": "https://localhost:8080/",
104 | "height": 74
105 | },
106 | "id": "tCIfvTkeo7GX",
107 | "outputId": "73f8fe81-ad5e-46af-c79b-a3b94539bcd7"
108 | },
109 | "execution_count": null,
110 | "outputs": [
111 | {
112 | "output_type": "execute_result",
113 | "data": {
114 | "text/plain": [
115 | "GaussianNB()"
116 | ],
117 | "text/html": [
118 | "
GaussianNB()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
GaussianNB()