Cheat sheet · Specialise
Data science cheat sheet (Statistics and R)
Opens with creditsFor students and researchers doing data science with statistics first and R as the main language: the tidyverse, inference, experiments, tidymodels and reproducible reports. Snippets are R wherever the code differs from Python.
Chapters
10 chapters · 80 concepts
1Code for data: Python or RThe working set you touch every day: notebooks, arrays, data frames, filtering, grouping, joining and reshaping, plus an environment someone else can rebuild.10 concepts
- 1Notebook workflowCode, output, charts and notes in one document you run cell by cell: Jupyter or Colab for Python, RStudio with Quarto or R Markdown for R.
- 2Arrays and vectorsA block of values of one type: a NumPy array in Python, an atomic vector in R.
- 3Vectorised operationsWriting one expression over a whole column instead of looping over rows, so the work runs in fast compiled code.
- 4DataFrame and tibbleA table in memory: named columns, each with one type, and rows that line up across them. pandas in Python, tibbles in R.
- 5Selecting and filtering rowsKeeping the columns you need and the rows that meet a condition:
locand boolean masks in pandas,selectandfilterin dplyr. - 6Group by and aggregateSplitting rows into groups by one or more columns, computing a summary for each group and combining the results into a new table.
- 7Merging tablesCombining two data frames on a key column, like a SQL join:
mergein pandas,left_joinand friends in dplyr. - 8Long and wide formatWide data has one column per period or category; long data has one row per observation with a column saying which one.
- 9Reproducible environmentA per-project record of the exact package versions an analysis used, so it runs the same on another machine or next year.
- 10The pipe and dplyr verbsThe pipe
|>passes the result on the left as the first argument on the right, so an analysis reads as a chain of verbs: filter, mutate, group_by, summarise…
10 in this chapterOpen this chapter2Statistics and probability you useSummaries, distributions, uncertainty and tests: the part of statistics that decides whether a pattern in your data is real, and which test to reach for.10 concepts
- 1Mean, median, standard deviation and IQRThe mean is the sum over n; the median is the middle value; the standard deviation is the typical distance from the mean; the IQR is Q3 minus Q1, the spread of…
- 2Common distributionsShapes that describe how a random quantity behaves: normal for sums of many small effects, binomial for counts of successes in n tries, Poisson for counts of…
- 3Conditional probability and Bayes' ruleP(A|B) is the probability of A given that B happened.
- 4Sampling distribution and the CLTIf you repeated your sample many times, the sample mean would vary; that spread is its sampling distribution.
- 5Standard errorThe standard deviation of an estimate across repeated samples.
- 6Confidence intervalA range built so that 95% of intervals made this way would contain the true value.
- 7Hypothesis test and p-valueAssume no effect (the null hypothesis) and ask how surprising your data would be.
- 8Type I, type II errors and powerA type I error is finding an effect that is not there (rate alpha, usually 5%).
- 9Which test whenTwo group means: Welch t-test.
- 10Correlation versus causationCorrelation measures how two variables move together, from -1 to 1.
10 in this chapterOpen this chapter- SQL for data workPulling the data you need from a warehouse or database: aggregates, joins at the right grain, window functions, and running SQL from your notebook.6 conceptsOpens with credits
- Data cleaning and EDAGetting raw data into a shape you can trust, then exploring it before you model anything: missing values, duplicates, types, outliers and first looks.7 conceptsOpens with credits
- Visualisation and storytellingChoosing the chart that answers the question, drawing it with your plotting library, showing uncertainty, and writing up the finding so someone can act on it.6 conceptsOpens with credits
- Machine learning with scikit-learn or tidymodelsThe core modelling loop for tabular data: split, baseline, fit, validate, compare. Enough to model well; the machine learning roadmap goes deeper.9 conceptsOpens with credits
- Experiments and A/B testingDesigning a fair experiment, sizing it, running it without peeking, checking it is healthy and reading the result honestly.9 conceptsOpens with credits
- Features and model evaluationTurning raw columns into useful inputs without leaking the answer, and choosing the metric that matches the decision.9 conceptsOpens with credits
- Working with messy real dataGetting data from APIs, open portals and the web responsibly, documenting where it came from, and knowing the biases it carries.6 conceptsOpens with credits
- Portfolio and first roleProjects that show judgement, write-ups people finish reading, a Kaggle profile used well, and the routes into a first data science job.8 conceptsOpens with credits
- 11Glossary, A to ZEvery concept in the sheet and the smaller terms it uses, in one list.138 terms
About this sheet
Statistics, pandas, ML, experiments.
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allBest practices
See all- Data Pipeline Best PracticesHow to build data pipelines you can re-run, test and trust: idempotent tasks, orchestrator hygiene, layered transformations, data tests, freshness, ownership and monitoring.
- Data Analysis Best PracticesAn analyst's workflow in SQL, pandas and Polars: framing the question, reading data correctly, joins and grain, aggregation pitfalls, reproducible notebooks, checking results and sharing findings.
- Data Modeling Best PracticesDimensional data modeling for analytics: declaring the grain, fact and dimension tables, slowly changing dimensions, dbt marts, naming, tests, contracts and a semantic layer.
Checklists
See all- ML Model Deployment ChecklistAn ML model deployment checklist: baselines, training and serving consistency, validation, model registry, canary rollout, rollback, drift monitoring and ownership, with how to verify each.
- Data Quality ChecklistA data quality checklist for warehouse tables: ownership, freshness, volume, schema, nulls, uniqueness, referential checks, anomaly monitoring and data incidents, with how to verify each.
- Analytics Dashboard ChecklistAn analytics dashboard checklist for launch day: purpose and audience, metric definitions, data freshness, correctness, performance, access, accessibility, ownership and adoption.
Project structures
See all- Machine learning project project structureFor students and analysts whose model works in a notebook and now needs to be reproducible, reviewable, served and watched. It starts from the Cookiecutter Data Science v2 layout (immutable raw data, numbered notebooks, a real Python package) and grows into versioned data with DVC, typed parameters, data validation with pandera, experiment tracking and a model registry with MLflow, a FastAPI prediction service, drift monitoring and, for a team, scheduled retraining, model cards, fairness checks and shadow deployment.
- MLOps pipeline project structureFor engineers who can train a model and now need the training to be a pipeline anyone can rerun, review and release. A uv workspace holds the pipeline package (prepare, validate, featurize, train, evaluate, register steps run by DVC), a small shared feature package, and a separate FastAPI prediction service that loads models from the MLflow registry by alias. It grows into CI that reproduces the pipeline on pull requests, scheduled retraining, approved promotion and monitoring.
- dbt project project structureA dbt project that turns raw tables into tested, documented models, using the staging, intermediate and marts layers from dbt's own structure guide. It runs on DuckDB on your laptop, so you can learn analytics engineering for free, and grows into a governed project with checks, contracts, slim CI and a hosted docs site that moves to BigQuery or Snowflake unchanged.
Career questions
See all- What is the difference between a data analyst, a data scientist and a machine learning engineer?Analysts answer business questions with SQL, spreadsheets, dashboards and reports. Data scientists add statistics, experiments and predictive models. ML engineers build and run models inside production software. Titles vary by company, so read the work in the job advert, and pick by the kind of problem you enjoy, not the title that sounds most senior.
- Should I learn Python or R for data science?For most people aiming at industry jobs, learn Python first: it covers analysis, machine learning and production code, and most data job adverts ask for it. Choose R first if you are heading into statistics, academic research, public health or survey work, where it is strong. Either way, SQL comes too, and the concepts transfer.
- How do I move into AI engineering, data science or DevOps?Pick the field by the work you want to do every day, not by the hype. Use what you already know as a bridge: developers usually reach AI engineering or DevOps fastest, analysts reach data science fastest, and a portfolio of one or two serious projects matters more than certificates.
Work with me
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com