注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Machine Learning:Computer learns from experience E task T and performance P; If P improves with E in task T
I. Linear Regression
1. Cost Function
Sum of square error. From 1point 3acres bbs
Optimization method: gradient descent, repeat until it converges.
. check 1point3acres for more.It’s a convex function, local min value is global min value
Choose learning rate: too small, converge too slow; too large, it may not converge. .и
Feature scaling can help converge faster-baidu 1point3acres
2. L1 norm: absolute error – unstable solution, may have multiple solutions, built-in feature selection . check 1point3acres for more.
L2 norm: square error – stable solution; has analytical solution
3. Assumption
1) Linearity; Check: scatter /residual plot; solution: Exponential/log transform
2) Constant variance for error; Check: residual plot; solution: log transform
3) No autocorrelation; Check: residual plot against time; solution: time series
4) No multicollinearity; Check: correlation matrix(heatmap);solution: combine/PCA
II. Logistic regression
1. Function
H(x) = g(ΘX). check 1point3acres for more.
g(z) = 1/(1+e^(-z))
g(z) Graph:
. 1point 3acres 2. Decision boundary
Define y=1 if H(x)>0.5/z>0 and y=0 if H(x)<0.5/z<0
Decision boundary is 0.5. ----
3. Cost function. check 1point3acres for more.
Can’t use same cost function as linear regression; it’s not convex for logistic regression, it has multiple local minimums; hard to find the global minimum. 1point3acres
-y*log(h(x)) – (1-y)*log(1-h(x))
. ΧUse maximum likelihood estimate to optimize the cost function
MLE:
Find the parameter by maximizing the likelihood to make the observations.
4. Confusion matrix
Table to measure results from logistic regression.
1) Accuracy
(TP + TN)/Total #
Not good for imbalance data
2) Type I error: FP; P-value is probability of type I error: probability of rejecting the null hypothesis while the null is actually true
Type II error: FN
3) Precision: TP/(FP + TP); Positive relation with threshold
Recall: TP/(TP+FN); Negative relation with threshold
We care about precision or recall for different test;
Eg: for cancer detection, we care more about recall rate, we don’t want to tell the patient that he doesn’t have cancer but actually he has cancer.
F score: 2*Precision*Recall/(Precision+Recall)
4) TP rate (Power/1-TypeII error): TP/(TP+FN)
FP rate(TypeI error): FP/(FP+TN)
ROC AUC: . 1point 3acres
plotting TPR against the FPR at various threshold settings, find the curve maximize the AUC (area under curve)
III. Bias(underfit) & variance(overfit)
.google и1. Fix variance
1) Try fewer parameters
Introduce regularization parameter in cost function
Ridge: sum of square of parameters; Reduce the magnitude of parameters
Lasso: sum of absolute of parameters; can remove parameters
2) Increase λ in regularization
3) Increase training examples
4) Early stop for tree based model
2. Fix bias
1) Increase model complexity: add more parameter, try polynomial features
2) Decrease λ in regularization
IV. SVM (support vector machine)
1. Find a hyperplane/gap that separates the classes by maximizing the margin
2. Use kernel for non-linear: transfer data into another dimension that has a clear margin between classes
3. SVM V.S. Logistic regression
SVM maximize the margin, LR maximize the likelihood function
SVM predict 0/1, LR predict a probability
V. Unsupervised learning
1. Clustering (K-means). 1point3acres
The process to find K clusters
1) Randomly pick K cluster centroids
2) Index each data to the closest cluster centroids
3) Reassign cluster centroids as the average of each cluster
4) Repeat 2) and 3) until the clusters centroids don’t change
May reach local optimal if the initial K cluster centroids chosen not good. ----
Use “Elbow method” to pick the best number of clusters
2. PCA (Principal component analysis)
Reduce the parameter dimension; project n-dimension to k-dimension; will lose information during the process
3. Anomaly detection
Assume all features following normal distribution
Anomaly detection V.S. surprised learning
Anomaly detection if unlabeled data, future anomaly data look nothing like current anomaly data;
Surprised learning if large # of data; enough historical anomaly data and covers most cases. From 1point 3acres bbs
VI. Other Algorithm
1. Naïve Bayes
Assumption: X are independent of each other for the given Y.google и
2. Tree-based Method
1) Construct tree: top-down/greedy approach; at each step, minimize the RSS error rate; stop until criteria meet(eg: # of observation, node)
2) It will grow a big tree, possible overfit issue; Solution: select subset tree using cross-validation
3) Easy to explain BUT non-robust, overfitting issue: small data change leads to model change
3. Random Forest
Fix the overfitting issue with basic tree method
Randomly with replacement pick data, instead of using all features, randomly use square root features at each step; Average results of all trees
4. Boosting
Each tree is fit on a modified version of the previous tree;
STEPS:.--
Randomly with replacement pick data, build a model, validate on the data and calculate the RSS error rate; for the next tree, put higher weight for the data with higher error in previous model.
To avoid overfitting: don’t construct too many trees, use small learning rate, use small node(less complex tree). check 1point3acres for more.
|