Skip to content

Commit 840f40b

Browse files
committed
Refactoring
1 parent 0ad2b22 commit 840f40b

File tree

15 files changed

+1543
-1570
lines changed

15 files changed

+1543
-1570
lines changed

Module 5 - MLOPs/3. Experiment Tracking and Model Management/experiment_tracking_with_mlflow.ipynb

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"\n",
1111
"## **Key Features:**\n",
1212
"1. Experiment Tracking\n",
13-
"2. Model Registry"
13+
"2. Model Registry\n",
14+
"\n",
15+
"<img src=\"img/tracking_experiments.PNG\">\n"
1416
]
1517
},
1618
{
@@ -222,7 +224,7 @@
222224
},
223225
{
224226
"cell_type": "code",
225-
"execution_count": 5,
227+
"execution_count": 7,
226228
"metadata": {},
227229
"outputs": [],
228230
"source": [
@@ -244,7 +246,7 @@
244246
},
245247
{
246248
"cell_type": "code",
247-
"execution_count": 6,
249+
"execution_count": 8,
248250
"metadata": {},
249251
"outputs": [],
250252
"source": [
@@ -255,7 +257,7 @@
255257
},
256258
{
257259
"cell_type": "code",
258-
"execution_count": 7,
260+
"execution_count": 9,
259261
"metadata": {},
260262
"outputs": [],
261263
"source": [
@@ -266,7 +268,7 @@
266268
},
267269
{
268270
"cell_type": "code",
269-
"execution_count": 8,
271+
"execution_count": 10,
270272
"metadata": {},
271273
"outputs": [
272274
{
@@ -303,21 +305,30 @@
303305
"# Initialize the auto logger\n",
304306
"# max_tuning_runs=None will make sure that all the runs are recorded.\n",
305307
"# By default top 5 runs will be recorded for each experiment\n",
306-
"```"
308+
"```\n",
309+
"**Step 3 - Start the experiment run**\n",
310+
"```python\n",
311+
"with mlflow.start_run() as run:\n",
312+
" clf.fit(X_train, y_train)\n",
313+
"```\n",
314+
"\n",
315+
"\n",
316+
"\n",
317+
"<img src=\"img/tracking_experiments_hyperparameters.JPG\">"
307318
]
308319
},
309320
{
310321
"cell_type": "code",
311-
"execution_count": 9,
322+
"execution_count": 11,
312323
"metadata": {},
313324
"outputs": [
314325
{
315326
"data": {
316327
"text/plain": [
317-
"<Experiment: artifact_location='file:///C:/Users/DELL/Desktop/github/bansalkanav/Machine_Learning_and_Deep_Learning/Module%205%20-%20MLOPs/3.%20Experiment%20Tracking%20and%20Model%20Management/mlruns/947285828145926172', creation_time=1710911744020, experiment_id='947285828145926172', last_update_time=1710911744020, lifecycle_stage='active', name='iris_species_prediction', tags={}>"
328+
"<Experiment: artifact_location='file:///C:/Users/DELL/Desktop/github/bansalkanav/Machine_Learning_and_Deep_Learning/Module%205%20-%20MLOPs/3.%20Experiment%20Tracking%20and%20Model%20Management/mlruns/315136114113215422', creation_time=1710940361468, experiment_id='315136114113215422', last_update_time=1710940361468, lifecycle_stage='active', name='iris_species_prediction', tags={}>"
318329
]
319330
},
320-
"execution_count": 9,
331+
"execution_count": 11,
321332
"metadata": {},
322333
"output_type": "execute_result"
323334
}
@@ -330,7 +341,7 @@
330341
},
331342
{
332343
"cell_type": "code",
333-
"execution_count": 10,
344+
"execution_count": 12,
334345
"metadata": {},
335346
"outputs": [],
336347
"source": [
@@ -355,14 +366,14 @@
355366
},
356367
{
357368
"cell_type": "code",
358-
"execution_count": 11,
369+
"execution_count": 13,
359370
"metadata": {},
360371
"outputs": [
361372
{
362373
"name": "stderr",
363374
"output_type": "stream",
364375
"text": [
365-
"2024/03/20 12:59:41 WARNING mlflow.utils.git_utils: Failed to import Git (the Git executable is probably not on your PATH), so Git SHA is not available. Error: Failed to initialize: Bad git executable.\n",
376+
"2024/03/20 18:47:40 WARNING mlflow.utils.git_utils: Failed to import Git (the Git executable is probably not on your PATH), so Git SHA is not available. Error: Failed to initialize: Bad git executable.\n",
366377
"The git executable must be specified in one of the following ways:\n",
367378
" - be included in your $PATH\n",
368379
" - be set via $GIT_PYTHON_GIT_EXECUTABLE\n",
@@ -386,8 +397,8 @@
386397
"output_type": "stream",
387398
"text": [
388399
"Fitting 5 folds for each of 54 candidates, totalling 270 fits\n",
389-
"CPU times: total: 20.2 s\n",
390-
"Wall time: 26.2 s\n"
400+
"CPU times: total: 31 s\n",
401+
"Wall time: 40.8 s\n"
391402
]
392403
}
393404
],
@@ -419,7 +430,7 @@
419430
},
420431
{
421432
"cell_type": "code",
422-
"execution_count": 12,
433+
"execution_count": 14,
423434
"metadata": {},
424435
"outputs": [],
425436
"source": [
@@ -454,16 +465,16 @@
454465
},
455466
{
456467
"cell_type": "code",
457-
"execution_count": 13,
468+
"execution_count": 15,
458469
"metadata": {},
459470
"outputs": [
460471
{
461472
"name": "stdout",
462473
"output_type": "stream",
463474
"text": [
464475
"Fitting 5 folds for each of 60 candidates, totalling 300 fits\n",
465-
"CPU times: total: 19 s\n",
466-
"Wall time: 18.3 s\n"
476+
"CPU times: total: 22.3 s\n",
477+
"Wall time: 31.5 s\n"
467478
]
468479
}
469480
],
@@ -495,7 +506,7 @@
495506
},
496507
{
497508
"cell_type": "code",
498-
"execution_count": 14,
509+
"execution_count": 16,
499510
"metadata": {},
500511
"outputs": [],
501512
"source": [
@@ -595,7 +606,7 @@
595606
},
596607
{
597608
"cell_type": "code",
598-
"execution_count": 15,
609+
"execution_count": 17,
599610
"metadata": {},
600611
"outputs": [
601612
{
@@ -604,43 +615,43 @@
604615
"text": [
605616
"********** knn **********\n",
606617
"Fitting 5 folds for each of 54 candidates, totalling 270 fits\n",
607-
"CPU times: total: 18.4 s\n",
608-
"Wall time: 18.3 s\n",
618+
"CPU times: total: 27 s\n",
619+
"Wall time: 36.8 s\n",
609620
"Train Score: 0.9644268774703558\n",
610621
"Test Score: 0.9736842105263158\n",
611622
"\n",
612623
"********** svc **********\n",
613624
"Fitting 5 folds for each of 60 candidates, totalling 300 fits\n",
614-
"CPU times: total: 18.3 s\n",
615-
"Wall time: 17 s\n",
625+
"CPU times: total: 24 s\n",
626+
"Wall time: 26.6 s\n",
616627
"Train Score: 0.9644268774703558\n",
617628
"Test Score: 0.9736842105263158\n",
618629
"\n",
619630
"********** logistic_regression **********\n",
620631
"Fitting 5 folds for each of 30 candidates, totalling 150 fits\n",
621-
"CPU times: total: 10.9 s\n",
622-
"Wall time: 12.4 s\n",
632+
"CPU times: total: 14.6 s\n",
633+
"Wall time: 23.2 s\n",
623634
"Train Score: 0.9640316205533598\n",
624635
"Test Score: 0.9736842105263158\n",
625636
"\n",
626637
"********** random_forest **********\n",
627638
"Fitting 5 folds for each of 6 candidates, totalling 30 fits\n",
628-
"CPU times: total: 11.2 s\n",
629-
"Wall time: 16.8 s\n",
639+
"CPU times: total: 24.9 s\n",
640+
"Wall time: 36.5 s\n",
630641
"Train Score: 0.9553359683794467\n",
631642
"Test Score: 0.9736842105263158\n",
632643
"\n",
633644
"********** decision_tree **********\n",
634645
"Fitting 5 folds for each of 6 candidates, totalling 30 fits\n",
635-
"CPU times: total: 2.3 s\n",
636-
"Wall time: 8.02 s\n",
646+
"CPU times: total: 3.66 s\n",
647+
"Wall time: 15.2 s\n",
637648
"Train Score: 0.9640316205533598\n",
638649
"Test Score: 0.9736842105263158\n",
639650
"\n",
640651
"********** naive_bayes **********\n",
641652
"Fitting 5 folds for each of 2 candidates, totalling 10 fits\n",
642-
"CPU times: total: 969 ms\n",
643-
"Wall time: 6.9 s\n",
653+
"CPU times: total: 1.97 s\n",
654+
"Wall time: 15.2 s\n",
644655
"Train Score: 0.9557312252964426\n",
645656
"Test Score: 1.0\n",
646657
"\n"
@@ -894,7 +905,10 @@
894905
"3. **Production**: These versions are actively serving users in live environments.\n",
895906
" - The \"Production\" tag refers to versions of software or code that are actively running in a live environment and serving end-users or customers.\n",
896907
" - Production versions are expected to be stable, performant, and reliable, as they are handling real-world traffic and interactions.\n",
897-
" - Changes to production versions often follow strict release procedures and may involve deployment strategies such as blue-green deployment or canary releases to minimize disruptions."
908+
" - Changes to production versions often follow strict release procedures and may involve deployment strategies such as blue-green deployment or canary releases to minimize disruptions.\n",
909+
" \n",
910+
"\n",
911+
"<img src=\"img/model_management.PNG\">\n"
898912
]
899913
}
900914
],
181 KB
Loading

Module 5 - MLOPs/4. Orchestrate ML Pipeline/README.md

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# Managing Machine Learning Workflows using Prefect 2.0
22

3-
### In this repository, you will find three versions of app
4-
5-
> `version_1` - Breaking the Jupyter Notebook to Python Script (Basic Code without workflow management)
6-
> `version_2` - Code with Prefect Workflow - Defining the workflow and running them
7-
> `version_3` - Deployment and Scheduling tasks
8-
93

104
### Why Prefect?
115
- Python based open source tool
@@ -41,21 +35,25 @@ Check the prefect version:
4135

4236
### Running Prefect Dashboard
4337

44-
> `$ prefect orion start`
38+
> `$ prefect server start`
4539
4640
```
47-
___ ___ ___ ___ ___ ___ _____ ___ ___ ___ ___ _ _
48-
| _ \ _ \ __| __| __/ __|_ _| / _ \| _ \_ _/ _ \| \| |
49-
| _/ / _|| _|| _| (__ | | | (_) | /| | (_) | .` |
50-
|_| |_|_\___|_| |___\___| |_| \___/|_|_\___\___/|_|\_|
41+
___ ___ ___ ___ ___ ___ _____
42+
| _ \ _ \ __| __| __/ __|_ _|
43+
| _/ / _|| _|| _| (__ | |
44+
|_| |_|_\___|_| |___\___| |_|
45+
5146
Configure Prefect to communicate with the server with:
47+
5248
prefect config set PREFECT_API_URL=http://127.0.0.1:4200/api
49+
5350
View the API reference documentation at http://127.0.0.1:4200/docs
54-
Check out the dashboard at http://127.0.0.1:4200/
5551
52+
Check out the dashboard at http://127.0.0.1:4200
5653
```
54+
***
5755

58-
**Note - In Windows OS, if your path contains spaces, it will generate error (as mentioned below) when you try to run prefect orion.**
56+
**Note - In one of the earliest update of Prefect Orion, in Windows OS, if your path contains spaces, it will generate error (as mentioned below) when you try to run prefect orion. Sharing this so that you know what it is if you see it.**
5957

6058
```
6159
___ ___ ___ ___ ___ ___ _____ ___ ___ ___ ___ _ _
@@ -74,28 +72,7 @@ Error: Got unexpected extra argument (prefect.orion.api.server:create_app)
7472
Orion stopped!
7573
```
7674

77-
### Deployment of Prefect Flow
78-
79-
- `work_queue_name` is used to submit the deployment to the a specific work queue.
80-
- You don't need to create a work queue before using the work queue. A work queue will be created if it doesn't exist.
81-
82-
```python
83-
from prefect.deployments import Deployment
84-
from prefect.orion.schemas.schedules import IntervalSchedule
85-
from datetime import timedelta
8675

87-
deployment = Deployment.build_from_flow(
88-
flow=main,
89-
name="model_training",
90-
schedule=IntervalSchedule(interval=timedelta(minutes=5)),
91-
work_queue_name="ml"
92-
)
76+
### Make your code schedulable
9377

94-
deployment.apply()
95-
```
96-
97-
### Running an Agent
98-
99-
```
100-
$ prefect agent start --work-queue "ml"
101-
```
78+
Check the .ipynb file for details.
89 KB
Loading
90.5 KB
Loading

0 commit comments

Comments
 (0)