WEBVTT

NOTE
Subtitles for the Python and AI walkthrough. They match the captions drawn on the video,
and there is no spoken narration. The music is an original score. Cue times follow
the film timeline in seconds.

1
00:00:00.400 --> 00:00:04.250
Why is Python the default language for working with data and AI?

2
00:00:04.450 --> 00:00:08.440
The promise: short, readable scripts that run on your own computer.

3
00:00:08.640 --> 00:00:13.300
Our job: clean a messy dataset, then let a local agent answer questions about it.

4
00:00:14.400 --> 00:00:18.630
Why Python for AI? Your script is readable code that says what you want.

5
00:00:18.830 --> 00:00:23.490
It calls libraries such as pandas, NumPy, scikit-learn, PyTorch and Transformers.

6
00:00:23.690 --> 00:00:28.770
And those libraries run compiled code in C, C++ and on the GPU, which does the heavy math.

7
00:00:28.970 --> 00:00:33.530
Python is the glue. Local-model tools, including Ollama, ship Python libraries.

8
00:00:34.900 --> 00:00:39.270
From raw data to answers is five steps. Load the file, with the csv module.

9
00:00:39.470 --> 00:00:44.080
Clean it: fix the names, remove commas from numbers, drop duplicates and blanks.

10
00:00:44.280 --> 00:00:48.560
Transform values into numbers, then summarize: total the loans by branch.

11
00:00:48.760 --> 00:00:52.130
Finally, ask a local model questions about the result.

12
00:00:52.330 --> 00:00:56.990
And never change the raw file. Write a clean copy, so you can always start again.

13
00:00:58.400 --> 00:01:03.720
In the lab, watch the Python ideas first: functions, lists and dictionaries, and reading a CSV.

14
00:01:03.920 --> 00:01:09.100
Then the agent ideas: an agent is a model, tools and a loop, and your script runs the tools.

15
00:01:09.300 --> 00:01:14.390
Predict: when an agent calls a tool, who actually runs the code, the model or your script?

16
00:01:15.400 --> 00:01:20.770
Here is the wrangling script. It reads the CSV, cleans the rows, and totals the loans by branch.

17
00:01:20.970 --> 00:01:27.010
The cleaning report: 125 rows read, 5 duplicates removed, 4 dropped for missing loans, leaving 116 clean rows.

18
00:01:27.210 --> 00:01:32.300
The totals by branch: Central 15,749, Riverside 13,239, Harbor 11,950, and Hillside 9,322.

19
00:01:32.500 --> 00:01:36.300
The same numbers come out of the pandas version in fewer lines.

20
00:01:37.400 --> 00:01:41.530
So who actually runs the code when an agent calls a tool? Your script.

21
00:01:41.730 --> 00:01:47.490
The model only asks for the tool. Your script checks the arguments, runs it, and passes the result back.

22
00:01:48.900 --> 00:01:55.600
Talking to a local model takes a few lines. Import chat from the ollama library, and call it with a model name and messages.

23
00:01:55.800 --> 00:01:59.600
Set it up once: pip install ollama, then ollama pull the model.

24
00:01:59.800 --> 00:02:03.180
Messages have roles: system, user, assistant and tool.

25
00:02:03.380 --> 00:02:08.460
The model runs on your machine through the Ollama server, so nothing leaves your computer.

26
00:02:09.900 --> 00:02:14.030
An agent is a model, tools and a loop. You ask, and the model replies.

27
00:02:14.230 --> 00:02:19.270
If the reply asks for a tool, your script runs it, and the result goes back to the model.

28
00:02:19.470 --> 00:02:22.650
Then the model answers. The loop has a step limit.

29
00:02:22.850 --> 00:02:27.890
Safe by design: narrow, read-only tools, every argument checked, and a log of every call.

30
00:02:28.900 --> 00:02:31.900
Here is the checklist for scripts and agents.

31
00:02:32.100 --> 00:02:38.420
Is the raw data left untouched? Do I check types, blanks and duplicates? Can I run it twice and get the same result?

32
00:02:38.620 --> 00:02:42.610
Did I check a few rows by hand? Are the tools narrow and read-only?

33
00:02:42.810 --> 00:02:49.040
Do I check arguments before running anything? Is there a step limit and a log of every call? Did I verify answers?

34
00:02:50.400 --> 00:02:53.400
Two questions for the room.

35
00:02:53.600 --> 00:03:00.070
Which step of your own data work would you automate first? What could go wrong if the script silently skipped bad rows?

36
00:03:00.270 --> 00:03:05.540
An agent can only call read-only tools. What harm is still possible, and how would you notice?

37
00:03:06.900 --> 00:03:11.180
That is the lesson: Python is the glue between your data and your models.

38
00:03:11.380 --> 00:03:14.750
Short, readable scripts that run on your own computer.

39
00:03:14.950 --> 00:03:18.080
Wrangle the data, then ask a local model, safely.

