Skip to content

Commit c87f2a7

Browse files
committed
Clean run
1 parent e3333ac commit c87f2a7

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

notebooks/unit3/lesson_21/Lesson_21_demo.ipynb

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@
99
"\n",
1010
"This notebook demonstrates key concepts and tools for training ensemble models.\n",
1111
"\n",
12+
"1. Baseline models\n",
13+
" - Logistic regression\n",
14+
" - Decision tree\n",
15+
"2. Parallel ensembles\n",
16+
" - Voting ensemble\n",
17+
" - Bagging ensemble\n",
18+
" - Random forest\n",
19+
"3. Serial (sequential) ensembles\n",
20+
" - AdaBoost\n",
21+
" - Gradient boosting\n",
22+
" - Stacking ensemble\n",
23+
"4. Model comparison\n",
24+
" - Score comparison\n",
25+
" - Confusion matrix comparison\n",
26+
"5. Model metric optimization\n",
27+
" - ROC_AUC optimized thresholds\n",
28+
" - F1 optimized thresholds\n",
29+
"\n",
1230
"## Notebook set up\n",
1331
"\n",
1432
"### Imports"
@@ -21,28 +39,24 @@
2139
"metadata": {},
2240
"outputs": [],
2341
"source": [
24-
"import pandas as pd\n",
25-
"# import numpy as np\n",
2642
"import matplotlib.pyplot as plt\n",
43+
"import pandas as pd\n",
2744
"\n",
2845
"from sklearn.datasets import make_classification\n",
29-
"from sklearn.model_selection import train_test_split, cross_validate, TunedThresholdClassifierCV\n",
3046
"from sklearn.linear_model import LogisticRegression\n",
31-
"from sklearn.tree import DecisionTreeClassifier\n",
47+
"from sklearn.metrics import ConfusionMatrixDisplay\n",
48+
"from sklearn.model_selection import train_test_split, cross_validate, TunedThresholdClassifierCV\n",
3249
"from sklearn.svm import SVC\n",
50+
"from sklearn.tree import DecisionTreeClassifier\n",
51+
"\n",
52+
"# Ensemble models\n",
3353
"from sklearn.ensemble import (\n",
34-
" VotingClassifier,\n",
35-
" BaggingClassifier,\n",
36-
" RandomForestClassifier,\n",
3754
" AdaBoostClassifier,\n",
55+
" BaggingClassifier,\n",
3856
" GradientBoostingClassifier,\n",
39-
" StackingClassifier\n",
40-
")\n",
41-
"from sklearn.metrics import (\n",
42-
" # roc_auc_score,\n",
43-
" # f1_score,\n",
44-
" # confusion_matrix,\n",
45-
" ConfusionMatrixDisplay\n",
57+
" RandomForestClassifier,\n",
58+
" StackingClassifier,\n",
59+
" VotingClassifier,\n",
4660
")"
4761
]
4862
},
@@ -602,7 +616,7 @@
602616
"id": "78cb3b9b",
603617
"metadata": {},
604618
"source": [
605-
"### 3.2. Gradient Boosting\n",
619+
"### 3.2. Gradient boosting\n",
606620
"\n",
607621
"Builds models sequentially where each new model is trained to predict the residual errors of the previous ensemble, using gradient descent to minimize a loss function.\n",
608622
"\n",
@@ -1016,7 +1030,7 @@
10161030
"id": "5e23b03a",
10171031
"metadata": {},
10181032
"source": [
1019-
"## 5. Model Metric Optimization"
1033+
"## 5. Model metric optimization"
10201034
]
10211035
},
10221036
{
@@ -1034,7 +1048,7 @@
10341048
"id": "fa9ee276",
10351049
"metadata": {},
10361050
"source": [
1037-
"### 5.1. ROC_AUC Optimized Thresholds"
1051+
"### 5.1. ROC_AUC optimized thresholds"
10381052
]
10391053
},
10401054
{
@@ -1196,7 +1210,7 @@
11961210
"id": "783e5fef",
11971211
"metadata": {},
11981212
"source": [
1199-
"### 5.2. F1 Optimized Thresholds"
1213+
"### 5.2. F1 optimized thresholds"
12001214
]
12011215
},
12021216
{

0 commit comments

Comments
 (0)