Data Science Cheet Sheet
Data science is a concept to unify statistics, data analysis, machine learning, domain knowledge
and their related methods in order to understand and analyze actual phenomena with data.
Table of Contents
Statistics
TODO
https://www.youtube.com/watch?v=xxpc-HPKN28
Individuals vs characteristics
Population (census) vs sample
Parameters vs samples
Descriptive vs inferential
Normal distribution and empirical rule (68-95-99.7)
z-score
Inference: Estimation, Testing, Regression
Central limit theorem:
- The sampling distribution (the distribution of x-bars (mean of the sample) from all possible samples) is also a normal distribution.
- The mean of x-bars is equal to mean of the population.
- The standard deviation of the x-bars is standard deviation of population divided by sqrt(n).
https://www.khanacademy.org/math/statistics-probability/significance-tests-one-sample/more-significance-testing-videos/v/hypothesis-testing-and-p-values
p-value - the probability of getting a certain result given the null-hypothesis.
Machine Learning
Neural Networks
DNN implementations:
- Python: TODO
- Python + numpy:
- TensorFlow: TODO
- Keras: TODO
Structuring ML Projects
It is better to find a single optimization metric, this way it will be easier to choose a better model.
When it's not possible to choose a single optimization metric, you can add satisfying metrics.
For example, error rate is an optimization metric and the time it takes to run the classification on an object is a
satisfying metric.
Bayes error rate is the lowest possible error rate for any classifier of a random outcome
(into, for example, one of two categories) and is analogous to the irreducible error.
If your algorithm is performing worse than a human, then to improve your algorithm you can:
- Get labeled data from humans.
- Gain insight from manual error analysis: why did a person get this right?
- Better analysis of bias/variance.
When to focus on bias and when on variance:
- If human error is 1%, train error is 8%, dev error is 10%, then focus on avoidable bias, i.e reducing the train error,
because it can potentially be reduced by 7 pp, compared to just 2 pp for dev error. To reduce the train error you can try the following:
- Train a bigger model
- Train longer
- Try better optimization algorithms: RMSProp, Adam
- Try a different NN architecture: RNN, CNN
- Hyperparameter search
- If human error is 7%, train error is 8%, dev error is 10%, then focus on variance, i.e reducing the dev error,
because it can potentially be reduced by 2 pp, compared to just 1 pp for train error. To reduce the dev error you can try the following:
- Add more data
- Regularization: L1, L2, dropout,
- Data augmentation
- Try a different NN architecture: RNN, CNN
- Hyperparameter search
Problems where ML significantly surpasses human-level performance:
- Online advertising
- Product recommendations
- Logistics (predicting transit time)
- Loan approvals
All of the above are ML on structured data as opposed to natural perception.
Advice from Andrej Karpathy for learning ML: try implementing a NN from scratch, without relying on any libraries
like TensorFlow. This will help you learn how deep learning works under the hood.
Error Analysis: focus on what contributes most to the algorithm error. For example, if 90% of errors are due to
blurry images and 10% are due to misclassified as a dog instead of a cat, then focus on blurry images to reduce the error.
Incorrectly labeled data:
- fix it if it contributes a significant portion to error;
- fix it across train, dev, test datasets universally. Otherwise it may introduce bias to the dataset.
It's important to make your dev and test datasets as close to real-world data, even if it results in
train and dev/test datasets be drawn from different distributions. This way you optimise to the right target.
In this case to perform bias/variance analysis introduce train-dev dataset, to measure the variance contribution
to error.

Transfer Learning - using intermediate NN layers, that were pre-trained on some problem A, for a different problem B.
For example problem A can be classifying cats and dogs, problem B can be classifying lung desease in radiology images.
It makes sense when:
- Problems A and B have the same input.
- There is a lot more input for problem A than for problem B.
- Low level features from A could be helpful for learning B.
Multi-task Learning - training a NN for a classification problem where an input can be assigned multiple classes,
for example an image which can contain cars, pedestrians, stop signs, traffic lights, or any combination of those.
It can give better results than training a separate NN for each class, because the intermediate layers are reused.
End-to-end ML - solving a problem using just an ML algorithm without any hand-designed components as part of the
whole system. For example, for a speech recognition task an end-to-end ML approach is to use audio as an input for
an ML algorithm and the transcript as the output, as opposed to manually extracting features from the audio first,
then phonemes, the words, and then generating a transcript.
- Pros: let the data speak, less hand-designing of components needed.
- Cons: may need large amount of data, excludes potentially useful hand-designed components.
Convolutional Neural Networks
Colab Notebooks:
Why convolutions:
- Parameter sharing
- Sparsity of connections
Computer Vision Networks:
- AlexNet
- VGG-16 - 16 layers of "same" ConvLayers and MaxPooling layers
- ResNet
- Inception Network
Face Recognition:
- One Shot Learning, Triplet Loss
Neural Style Transfer:
DeepFake Colab:
YOLO (You Only Look Once) algorithm:
Sequence Models
TODO: Add more details
- RNN (Recurrent Neural Network) - has a problem of exploding/vanishing gradients.
- LSTM (Long Short-Term Memory Network) - solves the problem of exploding/vanishing gradients by
adding memory units.
- GRU (Gate Recurrent Unit) - simplified version of LSTM.
- Attention Model - adds attention mechanism to LSTM: Colab Notebook
Heroes of ML
AI for Industries
AI for Healthcare
AI for Medicine Specialization, Coursera
AI for Diagnosis:
- Applications of AI for diagnosis (mostly computer vision):
- Diagnosing edema in lungs from X-Rays scans.
- Dermatology: detecting whether a mole is a skin cancer: https://www.nature.com/articles/nature21056.
- Ophthalmology: diagnosing eye disorders using retinal fundus photos (e.g. diagnosing diabetic retinopathy).
- Histopathology: determining the extent to which a cancer has spread from microscopic images of tissues.
- Identifying tumors in MRI data - image segmentation. A CNN called U-Net is used for this.
- Challenges:
- Patient Overlap - as an example, the model can memorize a necklace on X-Rays images of a single patient and
give an over-optimistic test evaluation. To fix this split train and test sets by patient, so that all images of
the same patient are either in train or test sets.
- Set Sampling - when there is an imbalance dataset. Minority class sampling is used
- Ground Truth / Reference Standard - consensus voting.
AI for Prognosis:
- Applications of AI for prognosis (mostly applications of Survival analysis):
- Predicting risk of an event or when an event is likely to happen. E.g. death, heart attack or stroke, for people with a specific condition or for the general population. It's used to inform the patient and to guide the treatment.
- Risk of breast or ovarian cancer using data from blood tests.
- Risk of death for a person with a particular cancer.
- Risk of a heart attack.
- Risk of lung cancer recurrence after therapy.
- Survival analysis