Epsilon AI Learning
Ask AI
العربية
Enroll

Level 2 · Expert · CDSE

Certified Data Scientist Expert (Advanced)

The advanced data-science layer on top of CDSP: OOP, web scraping, advanced SQL, big data with Dask, ensembles and cloud deployment.

88 hours 7 lessons Prerequisite: CDSP
Your progress 0 / 7

01Programming

Advanced Python & OOP

As projects grow, scripts turn into systems. Object-oriented programming organizes code into reusable, self-contained pieces you can trust.

12 min read

Classes and objects

A class is a blueprint; an object is a thing built from it. The class bundles data (attributes) with the functions that act on that data (methods). Instead of loose variables and functions, related state and behavior live together.

python
class Account:
    def __init__(self, owner, balance=0):
        self.owner = owner          # attribute
        self.balance = balance

    def deposit(self, amount):      # method
        self.balance += amount
        return self.balance

acc = Account("Sara", 100)
acc.deposit(50)                     # 150

The four pillars

  • Encapsulation — bundle data with its methods and hide internals.
  • Inheritance — a class can extend another, reusing and specializing it.
  • Polymorphism — different classes respond to the same method name in their own way.
  • Abstraction — expose a simple interface, hide the complex implementation.

Why it matters for data science

scikit-learn, PyTorch and Pandas are all built with OOP — every model is an object with .fit() and .predict(). Understanding classes lets you build custom transformers, extend library classes, and structure a project so it stays maintainable as it scales.

Test yourself What does the `self` parameter refer to in a method?

The specific object the method is called on. self.balance means 'this object's balance', so each Account keeps its own state separate from others.

Key takeaways

  • A class bundles data + methods; objects are instances that keep their own state.
  • Encapsulation, inheritance, polymorphism and abstraction are the four pillars.
  • Every ML library is OOP — mastering classes lets you extend and structure real projects.

02Data

Web Scraping

When there's no download button and no API, web scraping lets you collect data straight from web pages — programmatically and at scale.

9 min read

How a scrape works

You request a page's HTML, then parse it to pull out the parts you want. requests fetches the HTML; BeautifulSoup navigates the tag tree to extract text and links by their tags, classes or ids.

python
import requests
from bs4 import BeautifulSoup

html = requests.get("https://example.com/jobs").text
soup = BeautifulSoup(html, "html.parser")
titles = [h.text.strip() for h in soup.select("h2.job-title")]

Static vs. dynamic pages

If the data is in the initial HTML, requests + BeautifulSoup is enough. If the page builds content with JavaScript after loading (infinite scroll, dashboards), you need a browser automation tool like Selenium or Playwright that runs the page like a real browser first.

Test yourself Your scraper gets an empty list even though you see the data in your browser. Likely cause?

The page is dynamic — the content is rendered by JavaScript after the initial HTML loads, so requests never sees it. Switch to Selenium/Playwright, or find the underlying API call the page makes.

Key takeaways

  • requests fetches HTML; BeautifulSoup parses it by tag/class/id.
  • Dynamic (JS-rendered) pages need Selenium/Playwright, not just requests.
  • Respect robots.txt, throttle requests, and prefer an official API when available.

03Data

Advanced SQL

Beyond SELECT: window functions, CTEs and stored logic let you answer analytical questions that basic GROUP BY can't.

11 min read

Window functions

A window function computes across a set of rows related to the current row — without collapsing them like GROUP BY does. This is how you get running totals, rankings, and row-to-row comparisons while keeping every row visible.

Rank customers by spend within each city
SELECT name, city, total,
       RANK() OVER (PARTITION BY city ORDER BY total DESC) AS city_rank,
       SUM(total) OVER (PARTITION BY city) AS city_total
FROM   customers;

CTEs make complex queries readable

A Common Table Expression (WITH …) names a subquery so you can build a query in clear, stackable steps instead of deeply nested parentheses. Complex analytics become a readable pipeline — and CTEs can even be recursive for hierarchies (org charts, categories).

sql
WITH monthly AS (
  SELECT DATE_FORMAT(created, '%Y-%m') AS m, SUM(total) AS rev
  FROM orders GROUP BY m
)
SELECT m, rev, rev - LAG(rev) OVER (ORDER BY m) AS growth
FROM monthly;
Test yourself You need each row plus its category's average on the same line. GROUP BY or a window function?

A window function: AVG(x) OVER (PARTITION BY category). GROUP BY would collapse the rows into one per category; a window keeps every row and attaches the group average alongside it.

Stored logic & performance

  • Stored procedures & functions save reusable logic inside the database.
  • Triggers run automatically on INSERT/UPDATE/DELETE (audit logs, validation).
  • Indexes make lookups fast; read a query's EXPLAIN plan to find slow spots.

Key takeaways

  • Window functions compute over related rows without collapsing them.
  • CTEs turn nested queries into readable, stackable steps (and can recurse).
  • Procedures/triggers store logic in the DB; indexes and EXPLAIN drive performance.

04Data

Big Data with Dask

When data is too big for Pandas to fit in memory, Dask runs the same familiar code across chunks and cores — and even across machines.

8 min read

The problem: memory & one core

Pandas loads the whole dataset into RAM and uses one CPU core. A 50 GB file on a 16 GB laptop simply won't open, and big operations are slow. Big-data tools solve both by splitting the work.

How Dask helps

A Dask DataFrame is many Pandas DataFrames under one interface. It splits data into partitions and processes them in parallel, only loading what it needs. The API mirrors Pandas, so your existing skills transfer almost unchanged.

python
import dask.dataframe as dd
df = dd.read_csv("huge/*.csv")          # lazy — nothing loaded yet
result = df.groupby("city").amount.mean()
result.compute()                        # now it runs, in parallel
Test yourself You wrote a Dask pipeline but no computation seems to happen. What are you likely missing?

The .compute() call. Dask is lazy and only builds a plan until you explicitly trigger it with .compute() (or .persist()). That laziness is a feature — it optimizes before running.

Key takeaways

  • Dask scales Pandas beyond RAM by partitioning and parallelizing.
  • Its API mirrors Pandas, so your skills transfer directly.
  • It's lazy — nothing runs until .compute(); Spark handles cluster-scale data.

05Data

Advanced Preprocessing

Advanced preprocessing squeezes more signal from hard data: imbalanced classes, text, and time — often the difference between a mediocre and a winning model.

10 min read

Imbalanced classes: SMOTE

When one class is rare (1% fraud), a model can score high by ignoring it. SMOTE and ADASYN fix this by synthesizing new, plausible minority examples between existing ones — balancing the classes so the model actually learns the rare pattern. Resample only the training set, never the test set.

Turning text into numbers

Models need numbers, so text must be vectorized. TF-IDF weights words by how distinctive they are to a document. Word2Vec goes further — it learns dense embeddings where words with similar meaning sit close together, capturing semantics a bag-of-words misses.

Time-series features

  • Lag features — yesterday's value as a predictor of today's.
  • Rolling windows — moving averages/std smooth noise and expose trend.
  • Calendar features — day-of-week, month, holiday flags capture seasonality.
Test yourself Should you run SMOTE on the whole dataset before splitting into train/test?

No. Resample only after the split, on the training set alone. SMOTE before splitting leaks synthetic points into the test set, so your evaluation is over-optimistic and won't reflect real performance.

Key takeaways

  • SMOTE/ADASYN synthesize minority examples — on the training set only.
  • TF-IDF weights distinctive words; Word2Vec learns meaning-aware embeddings.
  • Lag, rolling-window and calendar features unlock time-series models.
The idea Data preprocessing

Raw data is messy — missing values, different scales, text categories. Preprocessing cleans, fills, encodes, and scales it into a tidy matrix a model can learn from.

06Modeling

Advanced Machine Learning

Advanced ML is mostly about ensembles — combining many models into one strong one — plus techniques for high dimensions and hidden patterns.

13 min read

Ensembles: wisdom of crowds

One model can be biased or noisy; many diverse models averaged together are usually more accurate and stable. Bagging (e.g. Random Forest) trains models in parallel on random data subsets and averages them. Boosting trains models in sequence, each one fixing the previous one's mistakes.

XGBoost — the competition favorite

Gradient boosting — and its fast implementation XGBoost (with LightGBM and CatBoost) — dominates tabular-data problems. It builds shallow decision trees one after another, each correcting the residual errors of the ensemble so far. It's often the strongest model you can reach for on structured data.

PCA & association rules

  • PCA reduces many correlated features to a few 'principal components' that keep most of the variance — great for visualization and speed.
  • DBSCAN clusters by density, finding arbitrary shapes and flagging outliers (unlike k-means).
  • Association rules (Apriori / FP-Growth) find 'customers who buy X also buy Y' — market-basket analysis.
Test yourself Random Forest vs. XGBoost: which reduces variance by averaging parallel trees, and which reduces bias by sequential correction?

Random Forest is bagging — parallel trees averaged, reducing variance. XGBoost is boosting — sequential trees each fixing prior errors, reducing bias. That's why boosting can reach higher accuracy but overfits more easily.

Models & techniques — what, when & why

XGBoost (Gradient Boosting) Ensemble · boosting

Builds shallow trees sequentially, each correcting the residual errors of the last.

When you want top accuracy on structured/tabular data.

Boosting reduces bias and usually wins tabular benchmarks — but needs careful tuning.

Example: Kaggle-style price/credit-risk models; LightGBM/CatBoost are fast cousins.

PCA Dimensionality reduction

Compresses many correlated features into a few 'components' keeping most variance.

Too many features, heavy correlation, or to visualize high-dimensional data in 2D.

Speeds training and cuts noise/overfitting by removing redundancy.

Example: Reduce 200 sensor readings to 10 components before modeling.

DBSCAN Unsupervised · density

Clusters points that are densely packed and labels sparse points as outliers.

Arbitrary-shaped clusters and anomaly detection, when you don't know cluster count.

Unlike k-means, it finds non-round clusters and doesn't need k up front.

Example: Detect fraud rings or map dense geographic hotspots.

Association Rules (Apriori) Unsupervised · rules

Finds items that frequently occur together and expresses them as 'if X then Y' rules.

Market-basket analysis, cross-sell, and recommendation seeds.

Surfaces actionable co-purchase patterns directly from transaction logs.

Example: 'Customers who buy bread + eggs also buy butter' → bundle them.

Key takeaways

  • Bagging (Random Forest) averages parallel models; boosting (XGBoost) corrects sequentially.
  • XGBoost usually wins on tabular data but needs careful tuning.
  • PCA compresses features; DBSCAN and association rules find hidden structure.
The idea How a machine-learning model learns

Features flow into a model that outputs a prediction; the error is measured and fed back to adjust the model. Repeat over many epochs and the loss falls — the model improves.

Try it Classification threshold — precision vs recall

A classifier gives each case a score; the threshold decides positive vs negative. Slide it and watch precision, recall, and accuracy trade off — there is no single “right” cut.

Precision · Recall · Acc

Practice this in the interactive lab

07Engineering

Docker, Cloud & Advanced Deployment

Production ML runs on containers and the cloud. Docker makes your model run anywhere identically; the cloud makes it scale.

10 min read

Docker: 'works on my machine' — solved

A container packages your code with its exact dependencies and environment, so it runs identically on your laptop, a colleague's machine, and a server. No more version mismatches. You write a Dockerfile once; anyone can build and run the same image.

A minimal model service
# Dockerfile
FROM python:3.11-slim
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]

# build & run
docker build -t my-model .
docker run -p 8000:8000 my-model

Cloud & scaling

Deploy the container to a cloud (AWS, Azure, GCP). For traffic that spikes, an orchestrator like Kubernetes runs many copies and load-balances across them, adding or removing copies automatically. This is the operational backbone of real ML products.

Test yourself Your model works locally but crashes on the server with a library version error. How does Docker prevent this?

The container ships the exact Python version and pinned dependencies with your code, so the server runs the identical environment you built and tested. There's no separate 'server setup' to drift out of sync.

Key takeaways

  • Docker packages code + environment so it runs identically everywhere.
  • Cloud + Kubernetes scale a service up and down with demand.
  • MLOps (CI/CD, MLflow, monitoring) operationalizes the whole ML lifecycle.

Type to search across Epsilon.

navigate open esc close Open full search →

Get this download

Enter your details and we'll email you the download link right away.

We'll email the link to you — no spam.
WhatsApp Call Enroll