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

1. Data Preparation

1.1. Unbalanced Classes

1.1.1. Collect more data

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

1.1.3. Resampling data Up sampling 'Oversampling' Down sampling

1.1.4. Generate Synthetic samples SMOTE

1.1.5. Try different algorithms

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

1.1.7. Try different approaches Anomaly detection Change detection

1.1.8. Get creative Split into smaller problems

1.2. Scaling/normalizing (feature scaling)

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

1.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.

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

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

1.3. Feature construction

2. NLP

2.1. Text preparation

2.1.1. Remove punctuation

2.1.2. Lower case

2.1.3. Tokenize words

2.1.4. Remove stop words

2.1.5. Remove blanks

2.1.6. Remove single letter words

2.1.7. Remove/translate non-english words

2.1.8. Stemming/Lemitization Snowball ()

2.2. Tool-kits

2.2.1. NLTK (python)

2.2.2. Spacy (python)

2.3. Text classifiction

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

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

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

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

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

2.4. Topic modelling

2.5. Entity recognition

3. Network Analysis

3.1. Metrics

3.1.1. Centricity

3.1.2. Betweenness

3.2. Data format


4. Optimization algorithms

5. Front-End (Web application tools)

5.1. Flask (python)

5.2. Shiny (R)

5.3. Dash (Python)

5.4. Tableau

5.5. Carto

5.6. Angular/React (JS)

5.7. Django (python)

6. Data gathering

6.1. APIs

6.2. Web Scrapers

6.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)

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

6.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.

6.3. Manual Labeling

6.3.1. Manual

6.3.2. Services Mechanical turk (etc.)

6.3.3. Exotic sampling

6.4. Major file types

6.4.1. CSV

6.4.2. JSON

7. HL Programming Languages

7.1. R

7.2. Python

7.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

7.3. Octave

8. Linear Algebra

8.1. Vector/Matrix operations

8.1.1. Matrix/Matrix Addition

8.1.2. Matrix/Matrix Multiplication

8.1.3. Matrix/Vector Multiplication

8.2. Matrix properties

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

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

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

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

8.3. Inverse & Transposed Matrices

8.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)

8.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

9. Statistics

9.1. Distributions

9.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

9.2. Statistical tests

9.2.1. t-test

9.2.2. ANOVA

10. Time-series analysis

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. Data Vizualisation libraries

12.1. GGPLOT2(R)




13. Machine Learning

13.1. Generic ML approaches

13.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

13.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

13.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)

13.2. Supervised (predictive models)

13.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

13.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

13.2.3. Reinforcement models Performance Metrics Neural Networks Architectures

13.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

13.3. Unsupervised (descriptive models)

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

13.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

14. Anomaly detection


14.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

14.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

14.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!

14.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

14.2.4. Examples Spam detection Manufacturing checks Machine/data monitoring

14.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

14.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

15. Recommendation engines

15.1. Content based

15.2. Collaborative filter

16. Big Data

16.1. Big Data technologies

16.1.1. Hadoop

16.1.2. Spark

16.2. ML on large datasets

16.2.1. Gradient descent Stochastic gradient descent

17. Labeling Data

17.1. Manual Labeling

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

17.2. Crowd Source

17.2.1. E.g. Amazon Mechanical Turk / Chiron

17.3. Synthetic Labeling

17.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)