BAB 02

02 - Foundational Skills: Python, Math, Data, Git, SQL

Estimasi Waktu: 45 menit Level: Beginner


The Foundation Stack

Sebelum lo bisa bikin AI, lo harus bisa bikin software. Ini adalah skills yang SEMUA AI role butuhkan β€” gak peduli lo mau jadi AI engineer atau AI researcher.


1. Python: The Language of AI

Python adalah lingua franca AI. Semua major framework (PyTorch, TensorFlow, JAX, HuggingFace) pakai Python.

Yang WAJIB Dikuasai:

Data Structures

# Lists, dicts, sets, tuples β€” fundamental
data = [{"name": "Maya", "score": 92}, {"name": "Rama", "score": 87}]
scores = {d["name"]: d["score"] for d in data}  # dict comprehension

Functions & Classes

class ModelEvaluator:
    def __init__(self, model, test_data):
        self.model = model
        self.test_data = test_data

    def evaluate(self) -> dict:
        results = self.model.predict(self.test_data)
        return {"accuracy": self._calc_accuracy(results)}

NumPy Proficiency

import numpy as np

# Vectorized operations β€” ini fundamental untuk ML
embeddings = np.random.randn(1000, 768)  # 1000 vectors, 768 dims
similarities = embeddings @ embeddings.T  # matrix multiplication

File I/O & JSON

import json
from pathlib import Path

data = {"model": "gpt-4", "temperature": 0.7}
Path("config.json").write_text(json.dumps(data, indent=2))

Async/Await

import asyncio
import aiohttp

async def call_llm(prompt: str) -> dict:
    async with aiohttp.ClientSession() as session:
        async with session.post(url, json={"prompt": prompt}) as resp:
            return await resp.json()

Yang BAGUS untuk Dikuasai:

Resources:


2. Mathematics for AI

Tenang, lo gak perlu PhD math. Tapi lo perlu paham konsep inti.

Yang WAJIB:

Linear Algebra (50% dari AI math)

Probability & Statistics (30%)

Calculus (20%)

Resources:

Rule of Thumb:

Lo gak perlu bisa hitung manual. Lo perlu paham konsep dan intuisi. Library yang hitung; lo yang paham kenapa dan kapan.


3. Git & Version Control

Yang WAJIB:

git init / clone
git add / commit / push / pull
git branch / checkout / merge
git stash / pop
.gitignore

Yang BAGUS:


4. SQL & Databases

AI Engineer kerja dengan data. Data tinggal di database. SQL = skill wajib.

Yang WAJIB:

-- Basic queries
SELECT column FROM table WHERE condition;

-- Joins
SELECT * FROM users
JOIN orders ON users.id = orders.user_id;

-- Aggregations
SELECT category, COUNT(*), AVG(price)
FROM products
GROUP BY category;

-- Subqueries
SELECT * FROM users
WHERE id IN (SELECT user_id FROM orders WHERE total > 100);

Yang BAGUS:


5. APIs & HTTP

AI models diakses via API. Paham HTTP = fundamental.

Yang WAJIB:

Contoh: Call OpenAI API

import httpx

response = httpx.post(
    "https://api.openai.com/v1/chat/completions",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "model": "gpt-4o",
        "messages": [{"role": "user", "content": "Hello"}],
    },
)
result = response.json()
print(result["choices"][0]["message"]["content"])

6. Linux / Command Line

Yang WAJIB:


The 3-Month Foundational Plan

Month 1: Python Intensif

Month 2: Math + SQL

Month 3: Tools + Integration


Latihan

  1. Kerjakan 50 soal Python di LeetCode Easy
  2. Tonton 3Blue1Brown Linear Algebra (15 video)
  3. Setup GitHub profile + push 1 project
  4. Build 1 API integration script (panggil OpenAI/Groq API)

Target: Python proficiency siap ML, Github profile aktif, 1 API project.