Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gabby hills patch 42 #422

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
a3bd83b
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 4, 2023
9947719
Merge pull request #1 from GabbyHills/GabbyHills-patch-1-1
GabbyHills Aug 4, 2023
c3b6e0a
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f2ff0b6
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
465393c
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
304587e
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
7e07ff5
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
380d272
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
e5b3d21
Merge pull request #2 from GabbyHills/GabbyHills-patch-1-1
GabbyHills Aug 5, 2023
f3aec3c
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
77c01c2
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
82209b8
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f0f7d8d
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f7c5a83
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
6affa5b
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
553b6ee
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
9bee5a7
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
a793e9b
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
7ddc60f
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
9945fae
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
79ae7f5
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
2b98bb3
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
7b2e7f0
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
b265273
Merge pull request #3 from GabbyHills/GabbyHills-patch-2
GabbyHills Aug 5, 2023
c8ce232
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
15c7bb6
Merge pull request #4 from GabbyHills/GabbyHills-patch-3
GabbyHills Aug 5, 2023
3f6a416
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
4b1f042
Merge pull request #6 from GabbyHills/GabbyHills-patch-6
GabbyHills Aug 5, 2023
4c87240
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
0c14873
Merge pull request #7 from GabbyHills/GabbyHills-patch-8
GabbyHills Aug 5, 2023
f1a6076
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
b507e4d
Merge pull request #8 from GabbyHills/GabbyHills-patch-9
GabbyHills Aug 5, 2023
97b419b
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
89bfe7a
Merge pull request #9 from GabbyHills/GabbyHills-patch-11
GabbyHills Aug 5, 2023
028831b
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
08c2eb6
Merge pull request #10 from GabbyHills/GabbyHills-patch-12
GabbyHills Aug 5, 2023
6c05f9c
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
ecb6fd9
Merge pull request #11 from GabbyHills/GabbyHills-patch-13
GabbyHills Aug 5, 2023
74958ed
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
e04c7a3
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
b30c4b2
Merge pull request #12 from GabbyHills/GabbyHills-patch-14
GabbyHills Aug 5, 2023
777bb9e
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
72ffd2c
Merge pull request #13 from GabbyHills/GabbyHills-patch-15
GabbyHills Aug 5, 2023
e2f21ca
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
09792b0
Merge pull request #14 from GabbyHills/GabbyHills-patch-16
GabbyHills Aug 5, 2023
88275f3
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
e38e8f0
Merge pull request #15 from GabbyHills/GabbyHills-patch-17
GabbyHills Aug 5, 2023
9672229
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f11b2af
Merge pull request #16 from GabbyHills/GabbyHills-patch-18
GabbyHills Aug 5, 2023
c2f5ed1
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
a7070a1
Merge pull request #17 from GabbyHills/GabbyHills-patch-19
GabbyHills Aug 5, 2023
10854e6
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
1e89833
Merge pull request #18 from GabbyHills/GabbyHills-patch-21
GabbyHills Aug 5, 2023
50926f0
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
d7e8360
Merge pull request #19 from GabbyHills/GabbyHills-patch-22
GabbyHills Aug 5, 2023
97fdfeb
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
66d1572
Merge pull request #20 from GabbyHills/GabbyHills-patch-23
GabbyHills Aug 5, 2023
baa6f58
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
c082884
Merge pull request #21 from GabbyHills/GabbyHills-patch-24
GabbyHills Aug 5, 2023
7975558
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f2980bb
Merge pull request #22 from GabbyHills/GabbyHills-patch-25
GabbyHills Aug 5, 2023
dfc0313
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
96aaac2
Merge pull request #23 from GabbyHills/GabbyHills-patch-26
GabbyHills Aug 5, 2023
f373bfa
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
7e38b2d
Merge pull request #24 from GabbyHills/GabbyHills-patch-27
GabbyHills Aug 5, 2023
18fe5d1
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
4d9ac08
Merge pull request #25 from GabbyHills/GabbyHills-patch-28
GabbyHills Aug 5, 2023
9f7b864
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
5d1e0d8
Merge pull request #26 from GabbyHills/GabbyHills-patch-30
GabbyHills Aug 5, 2023
171860a
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f038224
Merge pull request #27 from GabbyHills/GabbyHills-patch-31
GabbyHills Aug 5, 2023
f9c5ea1
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
a15a084
Merge pull request #29 from GabbyHills/GabbyHills-patch-33
GabbyHills Aug 5, 2023
cb8860b
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
b359f61
Merge pull request #30 from GabbyHills/GabbyHills-patch-34
GabbyHills Aug 5, 2023
dcb630e
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
58f1974
Merge pull request #31 from GabbyHills/GabbyHills-patch-35
GabbyHills Aug 5, 2023
fbcdef0
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
abf6d33
Merge pull request #32 from GabbyHills/GabbyHills-patch-36
GabbyHills Aug 5, 2023
1d765fb
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f009f23
Merge pull request #33 from GabbyHills/GabbyHills-patch-37
GabbyHills Aug 5, 2023
fe808a2
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
8c7541c
Merge pull request #34 from GabbyHills/GabbyHills-patch-38
GabbyHills Aug 5, 2023
230efc5
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
f46e4cc
Merge pull request #35 from GabbyHills/GabbyHills-patch-40
GabbyHills Aug 5, 2023
6d20a43
Update Diabetes Ridge Regression Training.ipynb
GabbyHills Aug 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 69 additions & 236 deletions experimentation/Diabetes Ridge Regression Training.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,264 +28,80 @@
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"sample_data = load_diabetes()\n",
"# Split the dataframe into test and train data\n",
"def = split_data(df):\n",
"X = df.drop('Y', axis=1).values\n",
"y = df['Y'].values\n",
"\n",
"df = pd.DataFrame(\n",
" data=sample_data.data,\n",
" columns=sample_data.feature_names)\n",
"df['Y'] = sample_data.target"
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X, y, test_size=0.2, random_state=0)\n",
"data = {\"train\": {\"X\": X_train, \"y\": y_train},\n",
" \"test\": {\"X\": X_test, \"y\": y_test}}\n",
" return data"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(442, 10)\n"
]
}
],
"outputs": [],
"source": [
"print(df.shape)"
"# Train the model, return the model\n",
"def train_model(data, args):\n",
"reg_model = Ridge(**args)\n",
"reg_model.fit(data[\"train\"][\"X\"], data[\"train\"][\"y\"])\n",
" return reg_model"
]
},
{
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>age</th>\n",
" <th>sex</th>\n",
" <th>bmi</th>\n",
" <th>bp</th>\n",
" <th>s1</th>\n",
" <th>s2</th>\n",
" <th>s3</th>\n",
" <th>s4</th>\n",
" <th>s5</th>\n",
" <th>s6</th>\n",
" <th>Y</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>count</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>4.420000e+02</td>\n",
" <td>442.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <td>mean</td>\n",
" <td>-3.634285e-16</td>\n",
" <td>1.308343e-16</td>\n",
" <td>-8.045349e-16</td>\n",
" <td>1.281655e-16</td>\n",
" <td>-8.835316e-17</td>\n",
" <td>1.327024e-16</td>\n",
" <td>-4.574646e-16</td>\n",
" <td>3.777301e-16</td>\n",
" <td>-3.830854e-16</td>\n",
" <td>-3.412882e-16</td>\n",
" <td>152.133484</td>\n",
" </tr>\n",
" <tr>\n",
" <td>std</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>4.761905e-02</td>\n",
" <td>77.093005</td>\n",
" </tr>\n",
" <tr>\n",
" <td>min</td>\n",
" <td>-1.072256e-01</td>\n",
" <td>-4.464164e-02</td>\n",
" <td>-9.027530e-02</td>\n",
" <td>-1.123996e-01</td>\n",
" <td>-1.267807e-01</td>\n",
" <td>-1.156131e-01</td>\n",
" <td>-1.023071e-01</td>\n",
" <td>-7.639450e-02</td>\n",
" <td>-1.260974e-01</td>\n",
" <td>-1.377672e-01</td>\n",
" <td>25.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <td>25%</td>\n",
" <td>-3.729927e-02</td>\n",
" <td>-4.464164e-02</td>\n",
" <td>-3.422907e-02</td>\n",
" <td>-3.665645e-02</td>\n",
" <td>-3.424784e-02</td>\n",
" <td>-3.035840e-02</td>\n",
" <td>-3.511716e-02</td>\n",
" <td>-3.949338e-02</td>\n",
" <td>-3.324879e-02</td>\n",
" <td>-3.317903e-02</td>\n",
" <td>87.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <td>50%</td>\n",
" <td>5.383060e-03</td>\n",
" <td>-4.464164e-02</td>\n",
" <td>-7.283766e-03</td>\n",
" <td>-5.670611e-03</td>\n",
" <td>-4.320866e-03</td>\n",
" <td>-3.819065e-03</td>\n",
" <td>-6.584468e-03</td>\n",
" <td>-2.592262e-03</td>\n",
" <td>-1.947634e-03</td>\n",
" <td>-1.077698e-03</td>\n",
" <td>140.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <td>75%</td>\n",
" <td>3.807591e-02</td>\n",
" <td>5.068012e-02</td>\n",
" <td>3.124802e-02</td>\n",
" <td>3.564384e-02</td>\n",
" <td>2.835801e-02</td>\n",
" <td>2.984439e-02</td>\n",
" <td>2.931150e-02</td>\n",
" <td>3.430886e-02</td>\n",
" <td>3.243323e-02</td>\n",
" <td>2.791705e-02</td>\n",
" <td>211.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <td>max</td>\n",
" <td>1.107267e-01</td>\n",
" <td>5.068012e-02</td>\n",
" <td>1.705552e-01</td>\n",
" <td>1.320442e-01</td>\n",
" <td>1.539137e-01</td>\n",
" <td>1.987880e-01</td>\n",
" <td>1.811791e-01</td>\n",
" <td>1.852344e-01</td>\n",
" <td>1.335990e-01</td>\n",
" <td>1.356118e-01</td>\n",
" <td>346.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" age sex bmi bp s1 \\\n",
"count 4.420000e+02 4.420000e+02 4.420000e+02 4.420000e+02 4.420000e+02 \n",
"mean -3.634285e-16 1.308343e-16 -8.045349e-16 1.281655e-16 -8.835316e-17 \n",
"std 4.761905e-02 4.761905e-02 4.761905e-02 4.761905e-02 4.761905e-02 \n",
"min -1.072256e-01 -4.464164e-02 -9.027530e-02 -1.123996e-01 -1.267807e-01 \n",
"25% -3.729927e-02 -4.464164e-02 -3.422907e-02 -3.665645e-02 -3.424784e-02 \n",
"50% 5.383060e-03 -4.464164e-02 -7.283766e-03 -5.670611e-03 -4.320866e-03 \n",
"75% 3.807591e-02 5.068012e-02 3.124802e-02 3.564384e-02 2.835801e-02 \n",
"max 1.107267e-01 5.068012e-02 1.705552e-01 1.320442e-01 1.539137e-01 \n",
"\n",
" s2 s3 s4 s5 s6 \\\n",
"count 4.420000e+02 4.420000e+02 4.420000e+02 4.420000e+02 4.420000e+02 \n",
"mean 1.327024e-16 -4.574646e-16 3.777301e-16 -3.830854e-16 -3.412882e-16 \n",
"std 4.761905e-02 4.761905e-02 4.761905e-02 4.761905e-02 4.761905e-02 \n",
"min -1.156131e-01 -1.023071e-01 -7.639450e-02 -1.260974e-01 -1.377672e-01 \n",
"25% -3.035840e-02 -3.511716e-02 -3.949338e-02 -3.324879e-02 -3.317903e-02 \n",
"50% -3.819065e-03 -6.584468e-03 -2.592262e-03 -1.947634e-03 -1.077698e-03 \n",
"75% 2.984439e-02 2.931150e-02 3.430886e-02 3.243323e-02 2.791705e-02 \n",
"max 1.987880e-01 1.811791e-01 1.852344e-01 1.335990e-01 1.356118e-01 \n",
"\n",
" Y \n",
"count 442.000000 \n",
"mean 152.133484 \n",
"std 77.093005 \n",
"min 25.000000 \n",
"25% 87.000000 \n",
"50% 140.500000 \n",
"75% 211.500000 \n",
"max 346.000000 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# All data in a single dataframe\n",
"df.describe()"
]
},
{
"cell_type": "markdown",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"## Split Data into Training and Validation Sets"
"# Evaluate the metrics for the model\n",
"def = get_model_metrics(reg_model, data):\n",
"preds = reg_model.predict(data[\"test\"][\"X\"])\n",
"mse = mean_squared_error(preds, y_test)\n",
"metrics = {\"mse\": mse}\n",
" return metrics"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"X = df.drop('Y', axis=1).values\n",
"y = df['Y'].values\n",
"def = main():\n",
"# Load data\n",
"sample_data = load_diabetes()\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(\n",
" X, y, test_size=0.2, random_state=0)\n",
"data = {\"train\": {\"X\": X_train, \"y\": y_train},\n",
" \"test\": {\"X\": X_test, \"y\": y_test}}"
"df = pd.DataFrame(\n",
" data=sample_data.data,\n",
" columns=sample_data.feature_names)\n",
"df['Y'] = sample_data.target\n",
"\n",
"# Split Data into Training and Validation Sets\n",
" def = split_data(df):\n",
"\n",
"# Train Model on Training Set\n",
"args = {\n",
" \"alpha\": 0.5\n",
"}\n",
"\n",
"reg_model = Ridge(**args)\n",
"\n",
"# Validate Model on Validation Set\n",
"metrics = get_model_metrics(reg, data)\n"
]
},
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -310,7 +126,7 @@
"output_type": "execute_result"
}
],
"source": [
"source": [
"# experiment parameters\n",
"args = {\n",
" \"alpha\": 0.5\n",
Expand All @@ -327,6 +143,22 @@
"## Validate Model on Validation Set"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"def = get_model_metrics(reg_model, data):"
]
},
{
"cell_type": "code",
"metadata": {},
"source": [
"## Evaluate the metrics for the model"
]
},
{
"cell_type": "code",
"execution_count": 18,
Expand All @@ -341,10 +173,11 @@
}
],
"source": [
"def = get_model_metrics(reg_model, data):\n",
"preds = reg_model.predict(data[\"test\"][\"X\"])\n",
"mse = mean_squared_error(preds, y_test)\n",
"metrics = {\"mse\": mse}\n",
"print(metrics)"
" return metrics"
]
},
{
Expand Down Expand Up @@ -379,7 +212,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python ",
"language": "python",
"name": "python3"
},
Expand Down