Concept #57Easyextended-ai-concepts

What is Machine Learning (ML)?

#gen-ai#llm

Answer

What is Machine Learning (ML)?

Machine Learning is a subset of AI where systems learn patterns from data automatically — without being explicitly programmed with rules.

Core Idea

Instead of writing rules manually, you give examples and let the algorithm discover the rules itself.

text
Traditional: Rules + Data → Output
ML:          Data + Output → Rules (learned automatically)

ML Workflow

python
# Typical ML pipeline
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

# 1. Prepare data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

# 2. Choose and train model
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)

# 3. Evaluate
accuracy = model.score(X_test, y_test)

# 4. Predict on new data
prediction = model.predict(new_data)

Types of ML

TypeDescriptionExamples
SupervisedLearn from labeled data (input → label)Email spam filter, image classifier
UnsupervisedFind patterns in unlabeled dataCustomer segmentation, anomaly detection
ReinforcementLearn via rewards/penaltiesGame AI, robot control
Self-supervisedGenerate labels from data itselfLLM pre-training

Key ML Algorithms

AlgorithmBest For
Linear/Logistic RegressionSimple relationships, baseline
Decision Trees / Random ForestTabular data, interpretability
Gradient Boosting (XGBoost)Tabular data competitions
K-MeansClustering
Neural NetworksImages, text, complex patterns

ML vs Traditional Programming

TraditionalMachine Learning
Human writes rulesAlgorithm learns rules
text
if x > 5: label = "high"
text
model.fit(X, y)
Fails on new patternsGeneralizes to new data
Easy to debugHarder to interpret

Where ML Fits in AI Hierarchy

text
AI (broadest)
  └── Machine Learning (learns from data)
        └── Deep Learning (neural networks)
              └── Generative AI (creates content)
                    └── LLMs (language-specific)

Relevance to Gen AI Engineering

Modern LLMs are built on ML principles — specifically self-supervised deep learning:

  • Pre-training: predict next token (self-supervised ML)
  • Fine-tuning: supervised ML on task-specific data
  • RLHF: reinforcement learning for alignment

Understanding ML fundamentals (loss functions, gradient descent, overfitting, evaluation metrics) is essential for Gen AI engineering.