Get Started. It's Free
or sign up with your email address
Data Science by Mind Map: Data Science

1. NLP

1.1. Text preparation

1.1.1. Remove punctuation

1.1.2. Lower case

1.1.3. Tokenize words

1.1.4. Remove stop words

1.1.5. Remove blanks

1.1.6. Remove single letter words

1.1.7. Remove/translate non-english words

1.1.8. Stemming/Lemitization Snowball ()

1.2. Tool-kits

1.2.1. NLTK (python)

1.2.2. Spacy (python)

1.3. Text classifiction

1.3.1. 1. Prepare text data (see text preparation)

1.3.2. 2. CountVectorize each feature (word) into a matrix

1.3.3. 3. Apply TD-IDF (Term Frequency, Inverse-Term-Frequency) to account for different length of documents

1.3.4. 4. Split data set into variables (countvector of text) and target (category label of the text)

1.3.5. 5. Deploy standard ML classification process (model, evaluate, iterate/tune)

1.4. Topic modelling

1.5. Entity recognition

2. Network Analysis

2.1. Metrics

2.1.1. Centricity

2.1.2. Betweenness

2.2. Data format


3. Front-End (Web application tools)

3.1. Flask (python)

3.2. Shiny (R)

3.3. Dash (Python)

3.4. Tableau

3.5. Carto

3.6. Angular/React (JS)

3.7. Django (python)

4. Linear Algebra

4.1. Vector/Matrix operations

4.1.1. Matrix/Matrix Addition

4.1.2. Matrix/Matrix Multiplication

4.1.3. Matrix/Vector Multiplication

4.2. Matrix properties

4.2.1. Matrices are not commutative (A*B != B*A)

4.2.2. Matrices are associative (A*B)*C = A*(B*C)

4.2.3. Matrices with the identity matrix are commutative (AI = IA)

4.2.4. SHAPE(M) = ALWAYS Row,Columns (R,C) (e.g. 2,3)

4.3. Inverse & Transposed Matrices

4.3.1. Inverse: A*A^-1 = A^-1*A = I (A^-1 is the inverse matrix of A, though not all matrices have an inverse)

4.3.2. Transpose: A -> AT (where A is a m*n matrix and AT is an n*m, where Aij = ATji) First column becomes first row basically. X

5. Data Vizualisation libraries

5.1. GGPLOT2(R)




6. Anomaly detection


6.2. Can be an unsupervised problem (looking for points with high p(x) standard deviation away from the mean of many of the features), from but mostly setup as a supervised problem with a training set with labels of anomalies

6.2.1. Premise Premise: assume features follow normal distribution. Find the u, sd & p(x) for each feature and use this to create new derived p(x) features. Then use these to predict anomalies

6.2.2. Process Create a 'good training' set with 60% of all non-anomaly (y=0) examples and use this to create p(x) derived features from each of the original features (see formula p(x) below). If you complete this process and still find anomaly y=1 samples which are not detected then it is a good idea to look into these specific example to see if there are new derived features that can be create to help detect it Put the remaining 20% of non-anomalously records with 50% of the anomalously records (y=1) into a training set, and the last 20% of non-anomalously and last 50% of anomalously records into a test set Use 'good training' set to create the p(x) derived features, use the training set to predict y=0 good, y=1 anomaly, and optimize the model, then finally use test set to do cross-validation performance We can then use standard supervised performance metrics to evaluate the model - though due to imbalanced classes must use a more robust metric (like F1) rather than accuracy!

6.2.3. Pros (supervised / anomaly detection) AD preferable when we have a very small set of positive (y=1) examples (as we want to save this just for training and test set and can 'expend' many y=0 examples to fit the p(x) model) When anomalies may follow many different 'patterns' so fitting a standard supervised model may not be able to find a good separation boundary, but the pattern of their probability distribution (i.e. the fact they are very different from normal) will be a constant pattern

6.2.4. Examples Spam detection Manufacturing checks Machine/data monitoring

6.2.5. Formula for p(x) Using set of y=0 data points create new derived features which model the original features as a normal distribution and calculate the sample mean, sd, and p(x) as new derived features Assumes features are Normally distributed (x~(u,s2) To check this assumption more-or-less holds true it is highly recommended to graph the features first Even if this does not hold true AD algorithms generally work OK

6.2.6. Multivariate Gaussian Distribution (AD) Premise Standard AD uses single-variance Gaussian distribution - essentially creating a circle radius of p(x) around the mean. However often it may be better to have a more complex shape around the mean - to do this we simply use a multi-var gaussian formula to calculate p(x) Formula Advantages Disadvantages

7. Time-series analysis

8. Recommendation engines

8.1. Content based

8.2. Collaborative filter

9. Labeling Data

9.1. Manual Labeling

9.1.1. Calculate approximate time it would take (e.g. 10s to label one, ergo...)

9.2. Crowd Source

9.2.1. E.g. Amazon Mechanical Turk / Chiron

9.3. Synthetic Labeling

9.3.1. Introducing distortions to smaller training set to amplify it (but only if distortions are what we would expect to find in real training set not just random noise)

10. Data Preparation

10.1. Unbalanced Classes

10.1.1. Collect more data

10.1.2. Change performance metrics Confusion matrix Precision Recall F1 Kappa ROC Curves

10.1.3. Resampling data Up sampling 'Oversampling' Down sampling

10.1.4. Generate Synthetic samples SMOTE

10.1.5. Try different algorithms

10.1.6. Try Penalized Models e.g. penalized-LDA Weka CostSensitive wappers

10.1.7. Try different approaches Anomaly detection Change detection

10.1.8. Get creative Split into smaller problems

10.2. Scaling/normalizing (feature scaling)

10.2.1. best for numeric variables which are on different scales (e.g. height = 178m, score = 10,000, shoesize = 5).

10.2.2. This will make gradient descent work much better! as less back and forth as it tries to find local minimum between the parameters.

10.2.3. Many variations but generally we want to get all features into approximately a -1 < x < 1 range

10.2.4. MEAN NORMALIZATION: X - Xu / Xmax - Xmin Will have a Xu ~= 0 Can also use standard deviation as denominator (X / s)

10.3. Feature construction

11. Data Project Management

11.1. CRISP-DM

11.1.1. 1. Business understanding

11.1.2. 2. Data understanding

11.1.3. 3. Data preperation

11.1.4. 4. Modelling

11.1.5. 5. Evaluation

11.1.6. 6. Deployment


11.2. Ceiling Analysis

11.2.1. Assess which part of the pipeline is most valuable to spend your time?

11.2.2. To do this, override each module/step with the perfect output (e.g. replace predictions with correct labels) for each module and assess where getting closer

12. Machine Learning

12.1. Generic ML approaches

12.1.1. ML Diagnostics (assess algorithms) Over-fitting (high variance) The hypothesis equation is 'over fit' to the training data (e.g. complex polynomial equation that passes through each data point) meaning it performs very well in training but fails generalize well in testing Under-fitting (high bias) The hypothesis equation is 'under fit' meaning it over generalized the problem (e.g. using a basic linear separation line for a polynomial problem), meaning if cannot identify more complex cases well Approaches Cross-validation Learning curves General diagnostic options

12.1.2. Generic ML algorithm Methodology Input: x, the input variable that predicts y target: y, a labelled outcome hypothesis: h(x), the function line that is a function of x Parameter: θ, the parameter(s) we choose with the objective of minimising the cost function Cost function: J(θ) a function of the parameters that we try to reduce to get a good prediction (e.g. MSE). We can plot this to see the minimum point. e.g. RMSE Goal: minimize J(θ), the goal of the algorithm to minimize the error of the cost function through changing the parameters Gradient decent (cost reduction mechanism): Repeat θj := θj - α dθj/d J(θ) := assignment operator, take a and make it b α = learning rate = how big steps to take, if it is too small then baby-steps will take a lot of time, if too big can fail to converge, or even diverge. The learning rate impact varys depending of slope of the derivative - This means that closer to convergence the steps will be smaller anyway. Simultaneously updates all parameters! dθj/d J(θ) = derivative function, the slope of the straight line at the tangent of the curve at each point (derivative). If slope is positive then it is θ - positive number makes θ less, if slope is negative then makes θ more until we get to a point where derivative is 0 (local minimum). Sometimes called "Batch" gradient decent as it looks at all the available examples in the training set (compared to cross-validation where we look at a sub-set of samples) Pros: works well even when you have a large number of features - so scales well. Cons: you need to choose a learning rate (α) and you need to do lots of iterations There are however other ways of solving this problem Prediction: a predict value of y using a new x sample and a θ trained by reducing the cost function for the training set

12.1.3. The phenomenon of increasing training data X 2001 This only holds if the features X hold enough information to predict y (i.e. predicting missing word from a specific sentence compared to trying to predict house prices from only having the square feet ... not possible even for human experts)

12.2. Supervised (predictive models)

12.2.1. Classification models Performance Metrics Confusion matrix Simple Metrics Advanced Metrics Other considerations Classification Model Types Logistic Regression SVMs KNN Decision Trees Random Forest XGBoost Classification types Binary class Multi class

12.2.2. Regression models Performance Metrics / Cost function We can measure the accuracy of our hypothesis function by using a cost function. This takes an average difference (actually a fancier version of an average) of all the results of the hypothesis with inputs from x's and the actual output y's. We can measure the accuracy of our hypothesis function by using a cost function. This takes an average difference (actually a fancier version of an average) of all the results of the hypothesis with inputs from x's and the actual output y's. Cost functions Regression Model Types Linear Regression Decision Trees for Regression Random Forest for Regression

12.2.3. Reinforcement models Performance Metrics Neural Networks Architectures

12.2.4. Ensemble modeling Definition Ensembling is a technique of combining two or more algorithms of similar or dissimilar types called base learners Types Averaging: Majority vote: Weighted average: Methods Bagging Boosting Stacking Advantages/Disadvantages of ensembling Advantages Disadvantages

12.3. Unsupervised (descriptive models)

12.3.1. Clustering KNN Process DBscan Auto-encoders (Neural Nets)

12.3.2. Dimensionality reduction PCA Reduce the dimensions of a dataset by finding a plane between similar variables than can be used to express the original variables in a lower-dimensional space

13. Statistics

13.1. Distributions

13.1.1. Gaussian (normal) distribution Described by the mean (u) and variance (σ2) - middle is mean, width is 95% in 2σ 'Bell shaped curve' probability distribution = 1

13.2. Statistical tests

13.2.1. t-test

13.2.2. ANOVA

14. HL Programming Languages

14.1. R

14.2. Python

14.2.1. Vectorization Matrix / for loops Matrix multiplications applied across an entire dataset is much more efficient that a for loop as do not have to reset and find memory space for each variables each time and has pre-indexed order for column vector

14.3. Octave

15. Data gathering

15.1. APIs

15.2. Web Scrapers

15.2.1. Selenium/PhantonJS Good when info is behind JS or when you need to interact with the browser (e.g. login as a human)

15.2.2. BeautifulSoup Simple scraper than you can use directly in a python script

15.2.3. Scrapy Most developed and efficient scraper for large trawling. Also offers lots of functionality to customize (e.g. IP masking). Though needs to be setup with correct directory and class structures.

15.3. Manual Labeling

15.3.1. Manual

15.3.2. Services Mechanical turk (etc.)

15.3.3. Exotic sampling

15.4. Major file types

15.4.1. CSV

15.4.2. JSON

16. Optimization algorithms

17. Big Data

17.1. Big Data technologies

17.1.1. Hadoop

17.1.2. Spark

17.2. ML on large datasets

17.2.1. Gradient descent Stochastic gradient descent