Learnixo

Machine Learning Foundations · Lesson 1 of 70

What is Machine Learning?

The Core Definition

Machine learning is a subset of AI where systems learn patterns from data rather than being explicitly programmed with rules.

Traditional programming:

Input + Rules → Output

Machine learning:

Input + Output (examples) → Rules (learned automatically)

Traditional:
if temperature > 38.5 and heart_rate > 100:
    flag_as_sepsis = True   # Programmer wrote this rule

Machine Learning:
model.fit(patient_vitals, sepsis_labels)   # Model discovers the rule from 10,000 examples
prediction = model.predict(new_patient)

Why ML Instead of Rules?

Rules work when the logic is simple and stable. ML wins when:

  1. Too many rules — spam detection has millions of patterns; you can't write them all
  2. Rules change — fraud patterns evolve; hard-coded rules go stale
  3. Rules are implicit — humans recognize faces but can't articulate how
  4. Scale — personalizing recommendations for 500 million users requires learned models

The Three Types of ML

Supervised Learning

The most common type. The training data has labels — correct answers are provided.

Input (X)           Label (y)
Patient vitals  →   Has sepsis: Yes/No
Drug description →  Drug class: anticoagulant/antidiabetic
Image           →   Cat or Dog

The model learns to predict y from X.


Unsupervised Learning

No labels. The model finds structure in unlabeled data.

Input (X)           Goal
1000 clinical notes →  Find 5 patient clusters with similar conditions
Drug embeddings     →  Find drugs that cluster together (similar mechanism)

Reinforcement Learning

An agent takes actions in an environment and learns from rewards and penalties.

Agent: AI drug dosing assistant
Environment: Simulated patient
Action: Increase/decrease/maintain dose
Reward: +1 if patient improves, -1 if patient deteriorates

Used in robotics, game-playing (AlphaGo), and increasingly in LLM alignment (RLHF).


ML in the AI Stack

Artificial Intelligence (broad field)
  └── Machine Learning (learns from data)
        ├── Classical ML (decision trees, SVMs, logistic regression)
        └── Deep Learning (neural networks with many layers)
              └── Foundation Models / LLMs (transformers at scale)

LLMs like GPT-4 are trained with ML — specifically deep learning with supervised pre-training and RLHF alignment. Knowing the ML foundations helps you reason about why LLMs behave the way they do.


What a Model Actually Is

A model is a mathematical function with parameters (weights) that are adjusted during training.

Python
# Conceptually: a model is a parameterized function
def model(X, weights):
    return X @ weights   # Dot product: prediction

# Training: find weights that minimize error
weights = optimize(training_data, minimize=loss_function)

# Inference: apply learned weights to new data
prediction = model(new_input, weights)

During training, the algorithm adjusts weights to make predictions closer to the true labels. When training ends, the weights are fixed — that's your model.


Key Vocabulary

| Term | Definition | |---|---| | Training | The process of adjusting weights using labeled data | | Inference | Using the trained model to make predictions on new data | | Feature | An input variable used by the model | | Label / Target | The correct answer the model tries to predict | | Parameters / Weights | Internal values the model learns during training | | Hyperparameters | Settings chosen before training (e.g., learning rate) | | Generalization | Ability to perform well on unseen data, not just training data |


Interview Answer Template

Q: What is machine learning?

Machine learning is a subfield of AI where algorithms learn patterns from data rather than being explicitly programmed. Instead of writing rules manually, you show the model examples of inputs and desired outputs, and it learns the mapping. The three main types are supervised learning (labeled data), unsupervised learning (finding structure without labels), and reinforcement learning (learning through trial and reward). ML is the engine behind LLMs, recommendation systems, medical diagnosis tools, and fraud detection.