<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oscar Alateras on Medium]]></title>
        <description><![CDATA[Stories by Oscar Alateras on Medium]]></description>
        <link>https://medium.com/@oscaralateras70?source=rss-5ffb2f07d8de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wYRiza9ylAYfekKy1IPz2Q.jpeg</url>
            <title>Stories by Oscar Alateras on Medium</title>
            <link>https://medium.com/@oscaralateras70?source=rss-5ffb2f07d8de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 12:44:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oscaralateras70/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[7 AI Coding Concepts I Didn’t Understand Until I Went to a Cursor Event in Melbourne]]></title>
            <link>https://medium.com/@oscaralateras70/7-ai-coding-concepts-i-didnt-understand-until-i-went-to-a-cursor-event-in-melbourne-4ad971cf7e6b?source=rss-5ffb2f07d8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ad971cf7e6b</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Oscar Alateras]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 03:37:19 GMT</pubDate>
            <atom:updated>2026-02-17T03:37:19.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C0iMUC5P1xHrT8U7EtFn-Q.png" /></figure><p>I recently attended a Cursor event in Melbourne and it was one of those experiences where a bunch of terms I’d been hearing — but never properly understood — finally clicked. I’ve since gone down a rabbit hole on each of them and I wanted to share what I learned in plain language for anyone else who has been nodding along in conversations about “MCP servers” and “hooks” without really knowing what they mean — as before this, that was certainly me.</p><p>These seven concepts — rules, commands, MCP servers, subagents, modes, hooks and skills — are the building blocks of how modern AI coding tools like Cursor and Claude Code actually work. Here is what each one is, why it matters, and what it looks like in practice.</p><h4>Rules</h4><p>Rules are written instructions that tell an AI coding assistant how to behave within a specific project. Think of them as a style guide that the AI reads before it writes a single line of code — covering things like naming conventions, preferred frameworks, architectural patterns and what not to do. Cursor popularised the concept in 2024 with the .cursorrules file, which sat in the root of your project and shaped how the AI generated suggestions. By early 2025, Cursor evolved this into .mdc rule files stored in a .cursor/rules/ directory, allowing more granular control per file type or folder. Claude Code takes a similar approach with its CLAUDE.md file and .claude/rules/ directory. In a real workflow, you might have a rule that says “always use React hooks instead of class components” and “follow our internal API naming convention” — and the AI will respect that across every suggestion it makes, so your whole team gets consistent output without having to correct the AI every time.</p><h4>Commands</h4><p>Commands are user-triggered shortcuts — saved prompts you can fire off with a /slash — that kick off a repeatable workflow. In Claude Code, they live as markdown files in .claude/commands/ and were introduced as part of Claude Code’s core feature set when it launched in February 2025. The idea is simple: if you find yourself typing the same complex prompt over and over, save it as a command. For example, you might create a /review command that tells Claude to scan the current file for security vulnerabilities, check test coverage and suggest improvements, all in one go. Instead of writing the prompt from scratch each session, you just type /review and the full workflow runs. Commands are especially powerful when they orchestrate other features — a single command can spin up a subagent, reference a skill, and pipeline work through multiple stages, turning a two-minute prompt into a two-second shortcut.</p><h4>MCP Servers</h4><p>MCP stands for Model Context Protocol, an open standard introduced by Anthropic in November 2024 that standardised how AI models connect to external tools and data sources. An MCP Server acts as a bridge between your AI assistant and some outside system — GitHub, a database, Notion, Chrome DevTools, or really anything with an API. Before MCP, every integration was bespoke; now there’s a universal protocol, a bit like how USB-C standardised device connections. By mid-2025 MCP had become one of the hottest topics in the AI development space, with hundreds of community built servers appearing for everything from Figma to PostgreSQL. In practice, you’re debugging a frontend issue in Cursor — a Chrome DevTools MCP server lets the AI see your actual console logs, network requests, and page state in real time, so it’s working from live data rather than guessing. The AI doesn’t generate code in isolation anymore; it can read from and write to the tools already in use.</p><h4>Subagents</h4><p>Subagents are separate, isolated instances of an AI agent that can be spawned to handle specific tasks in parallel with the main conversation. They were introduced as part of Claude Code’s evolution through 2025, becoming a core feature with Claude Code 2.0 in September 2025. It’s worth distinguishing subagents from agents more broadly. An “agent” in the AI sense is any autonomous system that can take actions, make decisions and use tools to accomplish goals — Claude Code itself is an agent. Subagents are child instances spawned by that parent agent to handle a specific scoped task, running in their own isolated context and reporting results back. Think of the agent as the project lead and subagents as team members it delegates to. The key idea is context isolation — each subagent gets its own fresh context window, so it can do deep research or heavy processing without bloating your main conversation’s memory. You might be working on implementing a new feature while simultaneously spawning a subagent to research OAuth 2.0 best practices, another to document the current auth flow, and a third to write tests — all running at the same time and reporting back their findings. Claude Code can even spawn subagents autonomously when it decides it needs to explore a codebase before making a plan. Custom subagents can be created with the /agents command, each with their own specialised prompt, tool access, and permission settings.</p><h4>Modes</h4><p>Modes are different operating states that an AI coding tool can switch between, controlling what the AI is and isn’t allowed to do. Claude Code has three main modes: normal mode (where the AI suggests changes and asks for approval), auto-accept mode (where it just makes changes without asking — sometimes called “YOLO mode”), and plan mode (where the AI can only read, research and plan but cannot touch files). Plan mode, which you activate by pressing Shift+Tab twice, was introduced in mid-2025 and has become one of Claude Code’s most valued features. It formalises what experienced engineers do naturally — understand the problem fully before writing any code. In a typical workflow, you’d enter plan mode and ask Claude to analyse your codebase, understand the architecture, and propose a detailed implementation strategy. You review and refine the plan together. Only once you’re satisfied do you switch to auto-accept mode and let Claude execute the plan at full speed. This “plan first, build second” approach dramatically reduces wasted effort and produces code that fits your existing architecture rather than fighting against it.</p><h4>Hooks</h4><p>Hooks are event-driven automations that run automatically before or after specific AI actions — essentially callbacks that let you enforce deterministic rules on what is otherwise a non-deterministic system. They were introduced with Claude Code 2.0 in September 2025 and are configured in your .claude/settings.json file. There are several hook types: PreToolUse fires before the AI uses a tool (like running a bash command), PostToolUse fires after, and there are hooks for notifications, subagent lifecycle events, and more. The power is in making certain behaviours guaranteed rather than hoped for. For example, you could set up a PostToolUse hook that automatically runs your code formatter every time Claude edits a file, so the output is always clean regardless of what the AI produces. Or a commit-time hook that blocks any commit unless all tests pass, forcing Claude into a “fix and retry” loop until the build is green. Unlike rules (which are suggestions the AI interprets), hooks are deterministic — meaning they produce the exact same outcome every time, with no AI judgement involved. They execute real scripts with real consequences, giving you hard guardrails around the AI’s behaviour.</p><h4>Skills</h4><p>Skills are portable, reusable capability modules that teach an AI how to do something specific — packaged as a folder containing a SKILL.md description file plus any supporting scripts, templates, or resources. Anthropic introduced skills as a beta feature in October 2025, and Claude Code gained full SKILL.md support in January 2026. The clever design is progressive disclosure: Claude only sees each skill’s name and description by default (to save context space), and when it encounters a task that matches a skill’s description, it dynamically loads the full instructions. Unlike rules, which are always in context, skills load on demand. Unlike commands, which require the user to trigger them, skills can activate automatically when Claude recognises they’re relevant. In a workflow, you might have a skill for “creating professional PowerPoint decks” that contains detailed formatting instructions, template code, and examples. When you ask Claude to make a presentation, it automatically loads that skill and follows the best-practice approach it contains — producing significantly better output than if you were just winging it from general knowledge. Skills also follow an open standard called Agent Skills, meaning they can work across multiple AI tools, not just Claude Code.</p><p>These seven concepts aren’t just academic — they’re the practical toolkit for getting serious work done with AI coding assistants. Rules set the boundaries, commands save you time, MCP servers connect the AI to the real world, subagents let you multitask, modes give you control over risk, hooks enforce your non-negotiables, and skills package expert knowledge for reuse. Once you understand how they fit together, you stop using AI tools as fancy autocomplete and start building genuine AI-powered workflows. To make this concrete, imagine you’re building a new payments feature for an e-commerce app. You start in plan <strong>mode</strong>, asking Claude to analyse your codebase and propose an implementation strategy. Once you’re happy with the plan, you type /build-feature — a <strong>command</strong> that kicks off the whole pipeline. Claude loads your Stripe integration <strong>skill</strong> for best-practice payment handling, spawns a <strong>subagent</strong> to research PCI compliance requirements, and connects to your project management tool through an <strong>MCP server</strong> to pull in the acceptance criteria from the ticket. Meanwhile, your <strong>rules</strong> ensure every file follows your team&#39;s TypeScript conventions, and a <strong>hook</strong> automatically runs your test suite after every code change, blocking any commit until the build is green. Seven concepts, one workflow, zero context switching. That&#39;s the shift.</p><p>If you’re in Melbourne and haven’t been to one of these events, I’d highly recommend it. Sometimes the best way to understand a new paradigm is to be in a room full of people who are already building it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ad971cf7e6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 2: Designing a Queryable Participant Inventory for Multi-Site Research Data]]></title>
            <link>https://medium.com/@oscaralateras70/week-1-designing-a-queryable-participant-inventory-for-multi-site-research-data-fba3321e1606?source=rss-5ffb2f07d8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/fba3321e1606</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Oscar Alateras]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 20:31:00 GMT</pubDate>
            <atom:updated>2026-02-05T22:57:22.641Z</atom:updated>
            <content:encoded><![CDATA[<p>This week I shipped ~90% of an MVP for a participant inventory system used by a neuroscience / psychiatry lab. On the surface, it’s a dashboard that lets you filter participants and get counts. In practice, it solves a problem that used to quietly burn weeks of researcher time.</p><h3>Context</h3><p>Before this role, I worked in this lab as a <strong>research assistant</strong>, contributing to first-author papers. A recurring bottleneck was deceptively simple:</p><p>“How many participants do we actually have that meet X, Y, and Z criteria?”</p><p>Answering that question usually meant:</p><ul><li>Digging through multiple messy spreadsheets from different sites</li><li>Writing one-off scripts to join datasets that were never designed to talk to each other</li><li>Coming back days later with an answer that triggered <em>another</em> meeting</li></ul><p>At some point it clicked: this wasn’t a coding problem, it was an <strong>inventory problem</strong>.</p><p>I pitched the idea of an end-to-end system that lets researchers answer these questions <strong>live, in the meeting</strong>, in seconds instead of days. That pitch turned into my current role as an <strong>AI engineer at the lab</strong>, building this system as a production tool rather than a one-off analysis.</p><h3>The Real Problem</h3><p>At first glance, this looked like a filtering problem. Once I started building it, it became clear the real challenge was making those filters produce reliable results across messy, multi-site datasets.</p><p>Data came from multiple sites, each with different column names, formats, and assumptions. Researchers needed to trust that the number on screen was correct, and the system had to support queries nobody had thought of yet.</p><p>This wasn’t about a pretty dashboard — it was about designing a system that senior researchers would actually rely on to make decisions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l--zkQfQjXii2sEv94nLGw.png" /></figure><h3>My Initial Mental Model (and Why It Broke)</h3><p>I initially assumed the hardest part would be the UI or the SQL queries.</p><p>It wasn’t.</p><p>The hardest part was <strong>schema standardisation across heterogeneous datasets</strong>.</p><p>The MVP starts with:</p><ul><li>6 datasets</li><li>383 variables</li><li>Multiple modalities (clinical, symptoms, structural MRI, DTI)</li></ul><p>This number will grow substantially once vertex-level MRI metrics and large functional connectivity matrices are added. For MVP simplicity, we deliberately scoped it to six datasets — but the system is designed with that future growth in mind.</p><p>Once the schema problem was solved properly, everything downstream became much easier to reason about.</p><h3>Options I Considered (and Rejected)</h3><p><strong>Single wide table</strong></p><ul><li>Simple to query</li><li>Quickly becomes brittle and hard to evolve</li><li>Painful once new datasets or modalities are added</li></ul><p><strong>Fully normalised relational schema</strong></p><ul><li>Clean and academic</li><li>Overkill for the access patterns</li><li>Slows down iteration and adoption</li></ul><p><strong>What I chose instead</strong></p><ul><li>One table per dataset</li><li>A canonical variable registry</li><li>Materialized views for common query paths</li></ul><p>This struck a balance between structure and flexibility.</p><h3>The Core Decision</h3><p>The system is built around three layers:</p><ol><li><strong>Ingestion &amp; schema management</strong></li></ol><ul><li>Automatic column standardisation</li><li>Validation of required variables</li><li>Cleaned data cached as Parquet</li></ul><p><strong>2. Persistence &amp; views:</strong></p><ul><li>PostgreSQL with upsert semantics</li><li>One table per dataset</li><li>A lightweight inventory view for fast counts</li><li>A full view for detailed export</li></ul><p><strong>3. Query + UI:</strong></p><ul><li>Dynamic filtering via **kwargs</li><li>Streamlit dashboard with live updates</li><li>CSV export of IDs or full data</li></ul><p>Everything remains <strong>queryable under the hood</strong>, and once the LLM interface is added, users will be able to access <em>all</em> variables via natural language rather than manual filters.</p><h3>What Broke My Mental Model</h3><p>I underestimated how quickly performance bottlenecks appear once multiple system components start interacting.</p><p>Individually, each part worked well. But once I combined:</p><ul><li>multiple joins</li><li>dynamic filters</li><li>interactive UI updates</li></ul><p>latency crept in.</p><p>The fix was introducing materialized views earlier than I initially planned. Performance bottlenecks tend to emerge <strong>where parts of a system connect</strong>, not within the parts themselves — and this was a concrete reminder of that.</p><h3>The UI Trade-off I Struggled With</h3><p>I had to decide how many filters to expose in the MVP.</p><p>The final version will use an LLM (“Show me females aged 25–40 with DTI and moderate depression”). The MVP, however, needed explicit controls.</p><p>Too many filters → overwhelming UI</p><p>Too few → researchers can’t answer real questions</p><p>I ended up exposing:</p><ul><li>Core demographics</li><li>Total scores for the symptom scales most commonly used in the lab</li><li>Dataset availability flags for key MRI modalities</li></ul><p>Everything else stays queryable under the hood and will become accessible once the LLM layer is added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d4t5P8Ob-_9jpnocngXzHw.png" /><figcaption>MVP dashboard built on synthetic data, showing real-time participant counts driven by dynamic filters over standardised, multi-site datasets.</figcaption></figure><h3>Who This Was For (and Why It Mattered)</h3><p>The primary users of this MVP are the <strong>heads of the lab at the University of Melbourne</strong>.</p><p>They’ll use it early in projects to decide:</p><ul><li>Whether a research question is feasible</li><li>Whether the available sample matches the hypothesis</li><li>Which modalities can realistically be included</li></ul><p>If this tool were slow, confusing, or untrustworthy, it simply wouldn’t be used. That constraint shaped every design decision.</p><h3>What I’d Do Differently Next Time</h3><p>Right now, datasets are ingested locally on my machine and then persisted to PostgreSQL before appearing in the dashboard.</p><p>This works for an MVP, but post-deployment the ingestion step should happen <strong>inside the product itself</strong>, allowing users to upload datasets directly into the inventory.</p><p>I was always going to build this step eventually. In hindsight, it would have been cleaner to include it from the start — but scoping it out allowed me to validate the core system faster. That trade-off was worth it, and it’s a lesson I’ll carry forward.</p><h3>One Transferable Insight</h3><p>The real value in data work isn’t the analysis itself — it’s making it easy for people to explore what they <em>don’t know yet</em>.</p><p>When answers take seconds instead of days, people explore more possibilities — and that leads to better study designs.</p><h3>Wrapping Up</h3><p>Thanks for reading this week’s progress update. This project is still evolving, but getting the MVP to ~95% complete has already validated the core idea: making participant exploration fast, reliable, and usable in real research settings.</p><h3>Focus for Next Week</h3><p>The main goals for next week are:</p><ul><li>Writing comprehensive unit tests across the ingestion, database, and query layers</li><li>Dockerising the system for reproducible deployment</li><li>Deploying the dashboard with basic access control so it can be shared with stakeholders</li></ul><p>You can view the code on <a href="https://github.com/oscaralateras/participant-inventory">GitHub</a>, and if you’re interested in the project or want to chat about similar problems, feel free to reach out at <strong>oscaralateras70@gmail.com</strong>.</p><p>I’ll be back next week with another update — stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fba3321e1606" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Docker Basics to Cloud Infrastructure]]></title>
            <link>https://medium.com/@oscaralateras70/week-1-from-docker-basics-to-cloud-infrastructure-a9acb5785f35?source=rss-5ffb2f07d8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9acb5785f35</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Oscar Alateras]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 04:24:45 GMT</pubDate>
            <atom:updated>2025-12-31T00:50:52.590Z</atom:updated>
            <content:encoded><![CDATA[<h3>Docker</h3><p>Docker is a containerisation platform that packages your application and all its dependencies into isolated, portable containers. Think of it like a shipping container for code — everything you need travels together.</p><p>Docker works with <strong>images</strong> and <strong>containers</strong>. An image is a template (like a blueprint) and a container is a running instance of that image. For example, say you need Python 3.13 with various packages. Instead of installing it all on your computer, you pull a Python image (the template with Python already configured) and run it as a container. The basic code looks like this:</p><pre>docker run -it python:3.13</pre><p>The -it flag makes the container interactive, letting you run commands directly inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mF7LbF_FnMcChNKHONrWeg.png" /><figcaption>A Docker container running Python 3.13 with data packages (pandas, pyarrow, sqlalchemy) in complete isolation from the host machine.</figcaption></figure><p>Docker main advantages are:</p><ul><li><strong>Reproducibility — </strong>creates the same environment on any machine</li><li><strong>Isolation — </strong>keeps applications separate from your system and each other</li><li><strong>Portability — </strong>runs anywhere docker is installed — laptop, server or cloud</li></ul><h3>Building a Data Pipeline with Docker and PostgreSQL:</h3><p>A more powerful example of Docker in action is running PostgreSQL — a full SQL database — without any installation. In Module 1, I started by initialising a Python virtual environment project with uv init --python=3.13, which creates a pyproject.toml file to manage dependencies. Then, instead of installing PostgreSQL on my computer, I ran a containerised version that required zero installation steps.</p><h4>Setting Up the PostgreSQL Container</h4><p>I used the following command to spin up PostgreSQL:</p><pre>docker run -it --rm \<br>  -e POSTGRES_USER=&quot;root&quot; \<br>  -e POSTGRES_PASSWORD=&quot;root&quot; \<br>  -e POSTGRES_DB=&quot;ny_taxi&quot; \<br>  -v ny_taxi_postgres_data:/var/lib/postgresql/data \<br>  -p 5432:5432 \<br>  postgres:18</pre><p>The -e flags set environment variables like the database username, password, and database name. The -v ny_taxi_postgres_data:/var/lib/postgresql/data creates a named volume—this is Docker&#39;s way of persisting data. Unlike the container itself which disappears when stopped, the volume stores the database data permanently in Docker&#39;s internal storage. This means I can stop and restart the container without losing my data. The -p 5432:5432 maps the container&#39;s port 5432 to my computer&#39;s port 5432, allowing me to connect to the database as if it were installed locally. Finally, postgres:18 specifies PostgreSQL version 18.</p><h4>Creating the Data Ingestion Script</h4><p>With the database running, I needed a way to load data into it. I created an ingest_data.py script that downloads NYC taxi trip data from a URL and loads it into PostgreSQL in chunks. The script uses pandas to read large CSV files piece by piece (100,000 rows at a time) to avoid memory issues, then uses SQLAlchemy to write each chunk to the database. It also uses Click to create a command-line interface with configurable parameters like database credentials, year, month, and table name. This creates a reusable pipeline format for getting data into PostgreSQL—just change the parameters to load different months or years of data.</p><h4>Containerising the Ingestion Script</h4><p>To make this pipeline reproducible and portable I containerised it with a Dockerfile. The Dockerfile starts with a slim Python 3.13 image, copies the uv package manager, sets up the working directory, installs all dependencies from the locked pyproject.toml file (ensuring reproducible builds), copies the ingestion script, and sets it as the entry point. Now anyone can run this exact pipeline with the same dependencies, regardless of their local setup.</p><h4>Adding pgAdmin for Database Management</h4><p>While PostgreSQL stores and manages the data, I needed a way to visualise and interact with it. That’s where pgAdmin comes in — it’s a web-based graphical interface for PostgreSQL that makes it easy to explore tables, write SQL queries, and manage the database through a browser instead of the command line. PostgreSQL is the database engine itself, while pgAdmin is just a convenient tool to interact with it.</p><p>To run both containers and allow them to communicate, I created a Docker network called pg-network. First, I restarted PostgreSQL on this network:</p><pre>docker run -it \<br>  -e POSTGRES_USER=&quot;root&quot; \<br>  -e POSTGRES_PASSWORD=&quot;root&quot; \<br>  -e POSTGRES_DB=&quot;ny_taxi&quot; \<br>  -v ny_taxi_postgres_data:/var/lib/postgresql/data \<br>  -p 5432:5432 \<br>  --network=pg-network \<br>  --name pgdatabase \<br>  postgres:18</pre><p>Then in another terminal, I ran pgAdmin on the same network:</p><pre>docker run -it \<br>  -e PGADMIN_DEFAULT_EMAIL=&quot;admin@admin.com&quot; \<br>  -e PGADMIN_DEFAULT_PASSWORD=&quot;root&quot; \<br>  -v pgadmin_data:/var/lib/pgadmin \<br>  -p 8085:80 \<br>  --network=pg-network \<br>  --name pgadmin \<br>  dpage/pgadmin4</pre><p>The --network=pg-network flag on both containers allows them to find each other by name. I could then access pgAdmin in my browser at localhost:8085, connect it to the PostgreSQL container using the host name pgdatabase, and explore the database through a graphical interface. At this point, the connection was established but no data had been loaded yet—just an empty database ready to receive data.</p><h4>Loading Data into PostgreSQL</h4><p>To actually populate the database, I ran the containerised ingestion script, also on the same network:</p><pre>docker run -it \<br>  --network=pg-network \<br>  taxi_ingest:v001 \<br>    --pg-user=root \<br>    --pg-pass=root \<br>    --pg-host=pgdatabase \<br>    --pg-port=5432 \<br>    --pg-db=ny_taxi \<br>    --target-table=yellow_taxi_trips_2021_2 \<br>    --year=2021 \<br>    --month=2 \<br>    --chunksize=100000</pre><p>Notice the --pg-host=pgdatabase—this is the name of the PostgreSQL container on the network. The ingestion container downloaded the February 2021 taxi data, processed it in chunks, and loaded it into the yellow_taxi_trips_2021_2 table. I could then query and explore this data through pgAdmin.</p><h4>Docker Compose</h4><p>Running three separate docker run commands every time was tedious, so I used Docker Compose—a tool that lets you define and run multiple containers using a single YAML configuration file. Instead of typing out long docker run commands, I created a docker-compose.yaml file that defined all three services (PostgreSQL, pgAdmin, and the ingestion script) with their configurations, networks, and volumes. Then I could start everything with a single command docker-compose up. And everything can stop just as easily with docker-compose down.</p><h4>How Docker Helped</h4><p>Docker transformed what would have been a complex, error-prone setup into a simple, reproducible pipeline. Without Docker, I would have needed to install PostgreSQL directly on my computer — downloading installers, configuring system services, and dealing with potential version conflicts if different projects needed different PostgreSQL versions. pgAdmin would require a separate installation, and coordinating the Python environment for the ingestion script would mean ensuring everyone on the team had identical package versions. With Docker, the entire setup became a few docker commands or a single docker-compose up with a YAML file. Anyone with Docker installed gets the exact same PostgreSQL version, pgAdmin interface, and Python environment — no installation complexity, no dependency conflicts, perfect isolation from the host system. The same configuration runs identically on my laptop, a teammate&#39;s Windows machine, or a cloud server. What would have been hours of installation and configuration became minutes of running containers, with the added benefit of being able to tear down and rebuild the entire environment instantly for testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wL-HMs0B3oeQiqD3BJAmA.png" /><figcaption>This diagram shows three Docker containers running on a local machine within a shared network (pg-network). The pgAdmin container provides a web interface accessible via port 8085, the Ingest Data container downloads CSV files and loads them into the database, and both connect to the PostgreSQL container which stores the data in the ny_taxi database with persistent storage through a Docker volume.</figcaption></figure><h3>Google Cloud Platform (GCP)</h3><p>Google Cloud Platform (GCP) is Google’s cloud computing service that lets you rent computing resources — like virtual machines, storage, and databases — instead of buying physical servers. You pay only for what you use and can scale up or down as needed. In this zoomcamp, I will be using GCP for deployment, primiarly due to the $300 in free credits a new user gets.</p><h3>Terraform</h3><p>Terraform is tool that lets you define and manage cloud resources using configuration files instead of clicking through web interfaces. Rather than manually creating virtual machines, storage buckets, or databases through GCP’s console, you write code that describes what you want and Terraform builds it for you. This makes infrastructure reproducible, version-controlled, and easy to replicate across environments.</p><p>The core of a Terraform project is the main.tf file, which defines the resources you want to create—like GCP storage buckets, compute instances, or databases. You specify what you need (e.g., &quot;a storage bucket named &#39;my-data-bucket&#39;&quot;), and Terraform handles the API calls to actually create it.</p><p>Terraform works through three main commands:</p><ul><li><strong>terraform plan</strong>: Shows what changes Terraform will make without actually making them (like a preview)</li><li><strong>terraform apply</strong>: Executes the plan and creates/updates your infrastructure</li><li><strong>terraform destroy</strong>: Tears down everything defined in your configuration</li></ul><p>For data engineering, this is incredibly powerful. Instead of manually setting up storage buckets, databases, and compute resources for each project or environment (development, staging, production), you define everything once in Terraform and can spin up identical infrastructure with a single command. Need to replicate your entire data pipeline setup in a new region? Just run terraform apply. Want to tear down a test environment to save costs? Run terraform destroy. This makes infrastructure management as reproducible and version-controlled as your code.</p><p>The module only touched on Terraform briefly, covering basic resource creation and the core workflow. There’s much more to explore — modules for reusable infrastructure components, state management for tracking resources, variable files for different environments, and advanced patterns for managing complex cloud architectures. This was just an introduction to show how infrastructure-as-code fits into modern data engineering workflows.</p><p>If you want to have a proper look at the code, it’s all on my <a href="https://github.com/oscaralateras/data-engineering-learning-in-public/tree/main">GitHub</a>. If you have any questions, comments, or feedback, they’re always welcome — I’m still learning myself and appreciate any insights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9acb5785f35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I Learned About Large Language Models: A Simple, Intuitive Guide]]></title>
            <link>https://medium.com/@oscaralateras70/what-i-learned-about-large-language-models-a-simple-intuitive-guide-209fc65b0b79?source=rss-5ffb2f07d8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/209fc65b0b79</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Oscar Alateras]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 02:53:25 GMT</pubDate>
            <atom:updated>2025-07-09T02:53:25.761Z</atom:updated>
            <content:encoded><![CDATA[<p>These are my personal notes from a module I recently completed in the <a href="https://academy.towardsai.net/courses/beginner-to-advanced-llm-dev"><strong>LLM Developer course by Towards AI Academy</strong></a>. I want to share what I’ve learned about Large Language Models (LLMs) and explain them to you in an intuitive way, without using math or code. My goal with these notes is to break down how LLMs work, why transformers and attention are important, how tokenisation and embeddings work, and post-training techniques. I hope these explanations help anyone looking for a clear, jargon-free understanding of LLMs.</p><h3>How LLMs Work</h3><p>At their core, LLMs are powerful word predictors. They don’t truly “understand” language the way humans do — instead, they are trained to guess the next word in a sentence based on the words that came before. By repeating this prediction process over and over, they can generate entire paragraphs of text. LLMs use <strong>artificial neural networks</strong>, which are big webs of simple mathematical functions connected together. These connections have adjustable values called <strong>parameters</strong> (often called weights and biases). During training, the model reads massive amounts of text, guesses the next word billions of times, and adjusts its parameters each time it’s wrong so it gets better at making predictions. The amazing part is that even though the model doesn’t memorise every sentence it sees, it learns patterns: how words relate to each other, what sentence structures look like, and how to produce text that sounds natural. That’s why LLMs can generate text on topics they haven’t seen exactly before — because they’ve learned general patterns rather than rote facts.</p><h3>The Role of Transformers and Attention</h3><p>One of the biggest breakthroughs in modern AI was the <strong>transformer architecture</strong>, introduced in <a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf">2017</a>. Before transformers, models processed text one word at a time or in small chunks, which made it hard for them to understand long sentences or capture complex context.</p><p>Transformers changed everything with a key innovation called the <strong>attention mechanism</strong>. Attention allows the model to look at all the words in a sentence at once and figure out which words are most important to each other. This helps the model understand context better.</p><p>For example, in the sentence:</p><p>“He sat on the bank and watched the river flow.”</p><p>The word<em> “bank” </em>could mean a financial institution or the side of a river. With attention, the model can look at words like “sat” and “river” in the same sentence and realise that<em> “bank” </em>here probably means the edge of a river, not a place to store money.<em> </em>This ability to look at every word’s relationship to every other word makes transformers great at processing language, understanding meaning, and generating more accurate, coherent text.</p><h3>Tokenisation and Embeddings</h3><p>Before an LLM can process text, it needs to convert words into a format it can work with. This starts with <strong>tokenisation</strong>, which breaks text into smaller pieces called tokens. A token can be a whole word, a sub-word (like “un-” or “-ing”), or even a single character, depending on the tokeniser used. For example, the sentence:</p><p>“The quick brown fox”</p><p>might be split into the tokens<em> “The”, “quick”, “brown”, and “fox.”</em></p><p>After tokenisation, the model turns each token into an <strong>embedding</strong> — a list of numbers that represents the meaning of the token in a high-dimensional space. You can think of embeddings as placing words as dots in a multi-dimensional map, where words with similar meanings end up near each other. For instance, the embeddings for “cat” and “kitten” would be close together, while “cat” and “car” would be farther apart. Embeddings allow the model to capture the relationships between words and concepts, which is essential for generating text that makes sense and feels natural.</p><h3>How LLMs Learn: The Training Process</h3><p>Training an LLM is like playing an enormous, never-ending game of fill-in-the-blank. During training, the model is fed billions of sentences with words hidden or masked. Its goal is to guess the missing word based on the surrounding words. Every time it guesses incorrectly, it adjusts its parameters — tiny numerical values in its neural network — so it gets a little better at predicting next time.</p><p>This training process repeats billions of times across massive datasets. Along the way, the model uses techniques like:</p><ul><li><strong>Masked language modelling</strong>, where words are hidden during training so the model can’t just memorise them.</li><li><strong>Softmax</strong>, which helps the model turn its guesses into probability distributions over possible words.</li><li><strong>Backpropagation</strong>, the process of correcting mistakes by updating parameters.</li><li><strong>Gradient descent</strong>, which controls how big each adjustment is so the model learns steadily without overreacting.</li></ul><p>This intense repetition helps the model learn patterns in language — how words and phrases fit together — without memorising everything it sees.</p><h3><strong>Post-Training: Instruction Tuning and RLHF</strong></h3><p>Once the main training is finished, LLMs still need to learn how to better follow instructions and respond the way humans expect. This is where two key steps come in: <strong>instruction tuning</strong> and <strong>reinforcement learning from human feedback (RLHF)</strong>.</p><ul><li><strong>Instruction tuning</strong> helps the model shift from simply predicting text to actually following directions. This is done by training it on curated examples where instructions are paired with correct answers, teaching the model how to handle tasks like answering questions or summarising text.</li><li><strong>RLHF</strong> takes things further by involving humans in the loop. People look at different outputs the model produces, then rank them from best to worst. These rankings are used to train a separate reward model, which scores how good future outputs are. This reward model then guides the LLM to produce responses that humans prefer.</li></ul><p>Together, these steps make the model’s responses more helpful and aligned with what users want. But even with these improvements, LLMs can still make mistakes, show biases, or misunderstand questions, which is why continuous monitoring and fine-tuning are needed for safe and reliable deployment.</p><h3><strong>Conclusion</strong></h3><p>Writing these notes helped me see that while LLMs are complex under the hood, their core idea is simple: they predict the next word based on patterns learned from massive amounts of text. The transformer architecture and attention mechanism were key breakthroughs that allowed LLMs to process context effectively, and techniques like tokenisation and embeddings make raw text understandable for models. I also learned that training LLMs isn’t just about feeding them data — it involves careful tuning and feedback through processes like RLHF to make them more helpful and aligned with human expectations. Overall, this module gave me an intuitive grasp of LLMs without needing to dive into equations or code, and I feel much more confident explaining how they work to others.</p><p><strong>If you found these notes helpful or want to discuss AI and machine learning further, feel free to connect with me on </strong><a href="https://www.linkedin.com/in/oscar-alateras-411372293/"><strong>LinkedIn</strong></a><strong> or check out my projects on </strong><a href="https://github.com/oscaralateras"><strong>GitHub</strong></a><strong>. I’d love to hear your thoughts and connect!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=209fc65b0b79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding Energy Use: PCA and K-Means on Daily Consumption Patterns]]></title>
            <link>https://medium.com/@oscaralateras70/decoding-energy-use-pca-and-k-means-on-daily-consumption-patterns-afb2239ab6a4?source=rss-5ffb2f07d8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/afb2239ab6a4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pca-analysis]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Oscar Alateras]]></dc:creator>
            <pubDate>Thu, 26 Jun 2025 04:54:04 GMT</pubDate>
            <atom:updated>2025-06-26T05:23:09.042Z</atom:updated>
            <content:encoded><![CDATA[<p>I analysed energy consumption for 300 Australian households, tracking 48 half-hour intervals per day over the 2012–2013 financial year. After cleaning, standardising, and aggregating the data into a 300 by 48 matrix representing daily usage profiles, I aimed to segment customers to inform pricing strategies. I chose K-means clustering because its centroid-based approach creates distinct, non-overlapping groups that are easy to interpret and target with differentiated pricing or demand-response offers. To support this, I applied <strong>Principal Component Analysis (PCA)</strong> — a dimensional-reduction method that re-expresses the data along new, orthogonal axes ordered by how much variance they capture — to suppress noise and let the dominant usage patterns emerge, making the subsequent clustering more stable, faster, and easier to link to real-world behaviours like peak-time demand or off-peak consistency. I implemented these algorithms from scratch using NumPy to deepen my understanding of the mechanics (particularly linear algebra) under the hood. This project showcases how linear algebra can drive practical insights into energy usage. In this post, I’ll walk through key parts of my process and the resulting findings.</p><h4>PCA</h4><p>My goal was to compress the 48 half-hourly intervals into a smaller number of meaningful features that still captured most of the behaviour across households. I began by computing the <strong>covariance matrix</strong>, which measures how each time interval varies with every other. For example, if households that use more energy at 6 pm also tend to use more at 6:30 pm, the covariance between those two columns is high.</p><pre>covariance_matrix = (1 / (n_samples - 1)) * (X_np.T @ X_np)</pre><p>Next, I performed <strong>eigendecomposition</strong> on the covariance matrix. Each <strong>eigenvector</strong> represents a direction (a pattern of usage), and its <strong>eigenvalue</strong> tells me how important that pattern is. Sorting them gives a ranked list of the most informative usage behaviours.</p><pre>eigenvalues_complex, eigenvectors_complex = np.linalg.eig(cov_matrix)<br>idx = eigenvalues.argsort()[::-1]<br>return eigenvalues[idx], eigenvectors[:, idx]</pre><p>To decide how many patterns to keep, I plotted a <strong>scree chart</strong> and chose the minimum number of components that explained 80% of the total variance — enough to capture meaningful structure while ignoring noise, which in this case was 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqZvul18WiMmcGFjS6FrXA.png" /></figure><p>Finally, I <strong>projected</strong> the data using <strong>X′ = X · W</strong>, where <strong>W</strong> holds the top 4 eigenvectors. This is a linear transformation that rotates the data from its original 48-dimensional space onto a new 4-dimensional basis where the axes are orthogonal and ranked by importance. Each new axis captures a distinct pattern of electricity usage, and each household is now represented by how strongly it expresses each of those patterns. This reduced dataset not only speeds up clustering, but also gives cleaner, more interpretable inputs.</p><pre>projection_matrix = eigenvectors[:, :n_components]<br>X_pca_np = X_np.dot(projection_matrix)</pre><p>The loadings for each principal component below reveal distinct patterns in how electricity usage varies across the day. <strong>PC1</strong> appears to capture overall consumption level (with uniformly positive weights), while <strong>PC2–PC4</strong> highlight variation in time-of-day preferences — such as <strong>PC2</strong> contrasting morning vs. evening usage, <strong>PC3</strong> showing a strong midday peak, and <strong>PC4</strong> isolating early morning and late evening behaviour shifts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0DJQOWiCK7CU1va5H9iJw.png" /></figure><h4>K-means Clustering</h4><p>To turn the four-component PCA space into actionable customer groups, I ran <strong>K-means</strong> from scratch and used the <strong>elbow method</strong> to pick the best <em>k</em>. I limited the search to <strong>2–10 clusters</strong> because anything smaller risks merging genuinely different usage styles, while anything larger tends to create tiny, hard-to-interpret segments that are difficult for pricing teams to act on.</p><p>The core of the algorithm is in three concise steps:</p><ol><li><strong>Initialise centroids</strong> at random observations for reproducibility.</li><li><strong>Assign points</strong> to the nearest centroid by Euclidean distance.</li><li><strong>Update centroids</strong> to the mean of their assigned points and repeat until positions stabilise.</li></ol><pre># Initialise random centroids<br>initial_indices = rng.choice(n_samples, k, replace=False)<br>centroids = X_np[initial_indices]<br><br>for i in range(max_iters):<br>    # Assign each point to the nearest centroid<br>    distances = np.sqrt(((X_np[:, np.newaxis, :] - centroids) ** 2).sum(axis=2))<br>    labels = np.argmin(distances, axis=1)<br>    # Update centroids to the mean of their assigned points<br>    new_centroids = centroids.copy()<br>    for j in range(k):<br>        points_in_cluster = X_np[labels == j]<br>        if len(points_in_cluster) &gt; 0:<br>            new_centroids[j] = points_in_cluster.mean(axis=0)<br>    # Convergence check<br>    if np.allclose(centroids, new_centroids):<br>        break<br>    centroids = new_centroids</pre><p>To evaluate each <em>k</em>, I recorded the <strong>inertia</strong> — the sum of squared distances between every point and its cluster centroid:</p><pre># Compute total inertia (cluster compactness)<br>inertia = np.sum([<br>    np.sum((X_pca_np[labels == i] - centroids[i])**2) for i in range(k)<br>])</pre><p>I plotted <strong>inertia versus <em>k</em></strong> — with lower inertia indicating tighter, more cohesive clusters — to pinpoint the optimal number of clusters. Using the <strong>elbow method</strong>, I looked for the point where adding extra clusters yields diminishing returns, forming the characteristic “elbow” in the curve. The plot below shows that this bend occurs at <strong>k = 5</strong>, so I selected five clusters as the best balance between compactness and interpretability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*K6CtizTNEUVoNHNVPcGIhw.png" /></figure><p>To better understand the behaviour of each group, I plotted the <strong>average daily energy usage profiles</strong> for the five clusters. This helped me visually compare how consumption varies by time of day across segments, and extract insights relevant to the pricing strategy goal. Here’s what I found:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2TIkjqzhbc45QGMXpDfdcA.png" /></figure><h4>🟣 Cluster 0 — Dual Peak (Morning &amp; Evening)</h4><p>These users have elevated consumption in both the <strong>morning (8–9 am)</strong> and <strong>evening (6–9 pm)</strong>, consistent with full-day occupancy or active routines. Pricing strategies here could include <strong>higher peak-hour tariffs</strong> or tailored plans rewarding off-peak flexibility.</p><h4>🔵 Cluster 1 — High Evening-Peak Users</h4><p>This group shows the <strong>highest overall energy use</strong>, with a sharp spike around <strong>7–9 pm</strong>, likely driven by cooking, heating, or entertainment. These households are prime candidates for <strong>time-of-use pricing</strong> or <strong>demand-shifting incentives</strong> to reduce stress on the grid in peak hours.</p><h4>🔵 Cluster 2 — Moderate Evening Consumers</h4><p>This segment has <strong>moderate evening usage</strong> (around 6–8 pm) but lower demand overall. These households might be ideal for <strong>fixed-rate plans</strong> or light <strong>nudges toward off-peak efficiency</strong>.</p><h4>🟢 Cluster 3 — Low, Stable Users</h4><p>The lowest and flattest curve — these households consume small, steady amounts throughout the day. They’re ideal for <strong>low flat-rate tariffs</strong>, or even <strong>prepaid billing models</strong> for energy-conscious or low-income households.</p><h4>🟡 Cluster 4 — Flat, High Overnight Users</h4><p>With consistently high demand <strong>throughout the night and early morning</strong>, this cluster may reflect households with overnight appliances or shift workers. They may benefit from <strong>off-peak discounts</strong> or <strong>overnight load optimisation plans</strong>.</p><p>These distinctions allow energy providers to craft more <strong>targeted pricing plans</strong>, improve <strong>grid stability</strong>, and enhance <strong>customer engagement</strong> by aligning tariffs with behaviour.</p><p>I mapped the five clusters onto the first two principal components — selected because they capture nearly 70 % of the total variance — to visually assess how well the segments separate in the reduced feature space. The scatterplot shows minimal overlap: Cluster 3 is tightly grouped, Clusters 0 and 2 are moderately compact, while Clusters 1 and 4 are more dispersed, reflecting greater within-group variability. This contrast highlights which segments are behaviourally consistent enough for standardised tariffs and which are diverse enough to justify more personalised or flexible pricing strategies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*rcn-gWj78FofMqr0KOe5Fg.png" /></figure><h3>Conclusion</h3><p>This project helped me connect core linear algebra concepts — like covariance, eigen-decomposition, and vector projection — to real-world applications in customer segmentation. By applying PCA and K-means from scratch, I uncovered five distinct usage patterns that inform targeted and flexible energy pricing strategies. Visualising both loadings and cluster structure gave clear insights into which groups are consistent and which are behaviourally diverse.</p><p>You can explore the full code on my GitHub <a href="https://github.com/oscaralateras/lin-alg-energy-segmentation/tree/main">here</a>. Feel free to explore or raise issues — feedback is always welcome!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afb2239ab6a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Algebra for Machine Learning: Your Essential Guide to the Core Concepts]]></title>
            <link>https://medium.com/@oscaralateras70/linear-algebra-for-machine-learning-your-essential-guide-to-the-core-concepts-9c49af97e192?source=rss-5ffb2f07d8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c49af97e192</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[algebra]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Oscar Alateras]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 07:00:53 GMT</pubDate>
            <atom:updated>2025-06-26T05:56:25.758Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine learning (ML) might feel like magic — from Netflix’s show suggestions to the sensor-fusion that steers self-driving cars — but its power rests on solid mathematics. At the heart of that mathematics is <strong>linear algebra</strong>, the language models use to encode data, uncover patterns and make decisions.</p><p>In the rest of this post we’ll unpack <strong>three core pillars</strong> of linear algebra that every ML practitioner leans on:</p><ul><li><strong>Vectors</strong> and their core operations, including the dot product</li><li><strong>Matrices</strong> and how their operations implement linear transformations</li><li><strong>Eigenvalues and eigenvectors</strong>, which re-express data along its most informative directions (an eigenbasis)</li></ul><p>While many other linear-algebra ideas matter, mastering these foundations is the fastest path to demystifying how modern ML algorithms really work.</p><h3><strong>Vectors</strong></h3><p>A vector is a quantity with both <strong>magnitude</strong> (length) and <strong>direction</strong>. The plot shows the vector <strong>[3 , 4]</strong>, which moves 3 units right and 4 units up from the origin <strong>[0, 0]</strong>. Think of the origin as your <strong>starting point</strong> and the arrow tip as your <strong>destination</strong> — the vector supplies the exact travel instructions. In machine learning, a vector usually represents one data point, with each component corresponding to a feature value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*VMtHKvCKiTpuBLMYBK8B7w.png" /></figure><h4><strong>Vector Operations</strong></h4><p>Vectors can be <strong>combined or scaled</strong> using operations that form the basis for manipulating data in machine learning. The plot below shows two core operations:</p><ul><li><strong>Vector Addition</strong> adds corresponding components. For instance, <strong>Vector A = [2, 1]</strong> (blue) and <strong>Vector B = [−1, 3]</strong> (green) sum to <strong>[1, 4]</strong> (red), representing their combined movement. Geometrically, this is often shown using the parallelogram rule — placing vectors tail-to-tail and drawing the diagonal.</li><li><strong>Scalar Multiplication</strong> stretches or shrinks a vector by a constant. Multiplying <strong>[1, 2]</strong> by 2 (shown in orange) results in <strong>[2, 4]</strong>, doubling its length while preserving direction.</li></ul><p>These operations are key to ML workflows: vector addition can combine feature signals or gradients, while scalar multiplication underpins <strong>feature scaling</strong> (like normalization or standardization) that ensures models train effectively on data with different units.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-u07CCRjRZGUoxIkqEP8g.png" /></figure><h3><strong>Dot Product</strong></h3><p>The dot product is a key vector operation that takes two vectors and returns a single number (a scalar) representing how much they point in the same direction. For example, with vector u = [3, 1] (blue) and vector v = [1, 3] (green), their dot product is 6. Geometrically, this equals the length of v multiplied by how much of u points along v — like shining a flashlight (u) onto a path (v), and measuring how much light lands on it (the red arrow). The longer the path, the more total light it catches. In machine learning, the dot product plays several key roles:</p><ul><li><strong>Similarity</strong>: it underpins <strong>cosine similarity</strong>, a common metric for comparing text/document embeddings</li><li><strong>Neural networks</strong>: it powers <strong>weighted sums</strong> within each neuron</li><li><strong>Dimensionality reduction</strong>: used to <strong>project</strong> data during PCA, revealing meaningful axes in the feature space</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*X10OEiNZHCe72hE3KBYLvQ.png" /></figure><h3><strong>Matrices</strong></h3><p>A <strong>matrix</strong> arranges numbers into rows and columns, allowing us to store multiple related vectors in a single object. If a vector gives directions to one destination, a matrix acts like a map, offering directions to many destinations from the same starting point. For example, consider the matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/99/1*IpzBnyZiuHH-0_Ul9Os7PQ.png" /></figure><p>This matrix contains two <strong>column vectors — </strong>[1,3] and [2,4] — which are visualized in the plot as arrows from the origin. Each column represents a distinct vector, and when grouped together, they form the full matrix. In machine learning, matrices are used to represent entire datasets — typically, each <strong>row</strong> corresponds to a data point (like a sample or observation), and each <strong>column</strong> to a feature. This structure allows for fast, parallel computations, such as applying a weight matrix to all samples at once during training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*XJEelROabuUBj4Dij57zHg.png" /></figure><h4><strong>Matrix Operations</strong></h4><p>Matrix multiplication is the core operation for applying transformations to data. It works by pairing each <strong>row</strong> of one matrix with each <strong>column</strong> of another matrix (or a vector) and taking their <strong>dot product</strong> — summing the products of corresponding elements — to produce a new matrix or vector. For instance, multiplying a matrix A by a vector x results in a new, transformed vector y = Ax. In machine learning, this operation underpins linear transformations: it is the step in which models learn to map input data to meaningful outputs, enabling tasks such as prediction and classification.</p><h4><strong>Linear Transformation</strong></h4><p>While a matrix can store a collection of vectors, its true power is revealed when it performs an action known as a <strong>linear transformation</strong>. Instead of thinking of a matrix as a static grid of numbers, think of it as a machine or function: you feed it a vector, and it outputs a new, transformed vector. This process can rotate, stretch, shear, or otherwise reshape the original vector. And the engine behind all of this is <strong>matrix multiplication</strong>, which calculates precisely where a vector lands after the transformation is applied.</p><p>To understand how a linear transformation works, we first need to look at the vectors that define our entire coordinate system: the <strong>basis vectors</strong>. As shown in the diagram below, these are <strong>î</strong> (i-hat), the gray vector (1, 0) that points one unit along the x-axis, and <strong>ĵ</strong> (j-hat), the lighter gray vector (0, 1) that points one unit along the y-axis. Every other vector in the plane, such as the green vector v, can be described as a unique &quot;recipe&quot; that combines these two fundamental building blocks. For instance, the coordinates of v = (-2, 1) are the instructions for this recipe: take <strong>-2 times the î vector</strong> and add it to <strong>1 times the ĵ vector</strong> to get your final location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*sptoVABhKhBtSL2W2xIpoA.png" /></figure><p>Now here’s the key insight: when we apply a matrix transformation, what we’re really doing is <strong>moving the basis vectors</strong>. This is shown in the second figure, where we apply the matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/67/1*LVuWIn0hFfAspRcZ8Yr0gA.png" /></figure><p>The first column tells us is the new destination for <strong>î </strong>(2, 1,) and the second column reveals the new destination for <strong>ĵ</strong> (-1, 1,) . These transformed basis vectors redefine the entire coordinate system. To find where the original green vector <strong>(1, 2)</strong> ends up, we use its original “recipe” in the new system: one part transformed î and two parts transformed ĵ. First, we use <strong>scalar multiplication</strong> to scale them: 1 * (2, 1) and 2 * (-1, 1). Then, we use <strong>vector addition</strong> to combine these results: (2, 1) + (-2, 2), which gives us (0, 3). This final result, the <strong>purple vector</strong>, shows where the original vector lands after transformation. Here’s the powerful idea: in the <strong>original coordinate grid</strong>, the transformed vector’s position is now (0, 3). But in the new, “warped” grid defined by the transformed î and ĵ, its coordinates are still (1, 2)— because its <strong>recipe hasn’t changed</strong>, only the space it lives in has.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*iGamWF3w33ujcv_Z5WPynA.png" /></figure><h3><strong>Eigenvalues and EigenVectors in an EigenBasis</strong></h3><p>An <strong>eigenbasis</strong> is a set of vectors that, when transformed by a matrix, <strong>only scale</strong> — they stretch or shrink — but crucially, they <strong>don’t rotate</strong>. Their direction stays exactly the same.</p><p>In the <strong>left diagram</strong>, we see a case <strong>that is not</strong> an eigenbasis: the transformed <strong>î</strong> (blue arrow) is <strong>knocked off</strong> its original axis. The vector has changed both in magnitude and direction, which disqualifies it as an eigenvector.</p><p>In contrast, the <strong>right diagram</strong> shows a proper eigenbasis. Both <strong>î</strong> (blue) and <strong>ĵ</strong> (red) have been transformed by the matrix, but remain perfectly aligned with their original axes. They’ve simply stretched — <strong>î</strong> by a factor of 3, and <strong>ĵ</strong> by a factor of 3 as well.</p><p>In this context:</p><ul><li>An <strong>eigenvector</strong> is a direction that remains unchanged in orientation after a transformation</li><li>The corresponding <strong>eigenvalue</strong> tells you how much the eigenvector is scaled — either stretched (&gt;1), shrunk (&lt;1), or even flipped (if negative)</li></ul><p>In <strong>machine learning</strong>, eigenvectors and eigenvalues are most famously used in <strong>Principal Component Analysis (PCA)</strong>. In PCA, the <strong>eigenvectors</strong> of the data’s covariance matrix define the <strong>principal components</strong> — the new axes onto which data is projected. The corresponding <strong>eigenvalues</strong> tell us how much <strong>variance</strong> each component captures, effectively quantifying which directions carry the most important structure in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bHvnU2TGQn-Gpr4soMOz0A.png" /></figure><h3>Linear Algebra Today, Calculus Tomorrow</h3><p>Linear algebra isn’t just background math — it’s the operating system of machine learning. Vectors let us encode data, matrices transform it, and eigenvectors reveal its hidden structure. Once you see these pieces working together, the “magic” behind modern models becomes a logical, visual framework.</p><p><strong>Happy Learning!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c49af97e192" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>