Sunday, January 26, 2020

Machine Learning



https://developers.google.com/machine-learning/crash-course/ml-intro
  • ML systems learn how to combine input to produce useful predictions on never-before-seen data.

Models

A model defines the relationship between features and label. For example, a spam detection model might associate certain features strongly with "spam". Let's highlight two phases of a model's life:
  • Training means creating or learning the model. That is, you show the model labeled examples and enable the model to gradually learn the relationships between features and label.
  • Inference means applying the trained model to unlabeled examples. That is, you use the trained model to make useful predictions (y'). For example, during inference, you can predict medianHouseValue for new unlabeled examples.

Regression vs. classification

A regression model predicts continuous values. For example, regression models make predictions that answer questions like the following:
  • What is the value of a house in California?
  • What is the probability that a user will click on this ad?
A classification model predicts discrete values. For example, classification models make predictions that answer questions like the following:

Good features are concrete and quantifiable
Linear regression is a method for finding the straight line or hyperplane that best fits a set of points.
L2 Loss for a given example is also called squared error
= Square of the difference between prediction and label
= (observation - prediction)2
= (y - y')2

The linear regression models we'll examine here use a loss function called squared loss (also known as L2 loss). The squared loss for a single example is as follows:
  = the square of the difference between the label and the prediction
  = (observation - prediction(x))2
  = (y - y')2
Mean square error (MSE) is the average squared loss per example over the whole dataset. To calculate MSE, sum up all the squared losses for individual examples and then divide by the number of examples:
MSE=1N(x,y)D(yprediction(x))2
where:
  • (x,y) is an example in which
    • x is the set of features (for example, chirps/minute, age, gender) that the model uses to make predictions.
    • y is the example's label (for example, temperature).
  • prediction(x) is a function of the weights and bias in combination with the set of features x.
  • D is a data set containing many labeled examples, which are (x,y) pairs.
  • N is the number of examples in D.
Although MSE is commonly-used in machine learning, it is neither the only practical loss function nor the best loss function for all circumstances.
Convex problems have only one minimum; that is, only one place where the slope is exactly 0. That minimum is where the loss function converges.
The gradient descent algorithm then calculates the gradient of the loss curve at the starting point. Here in Figure 3, the gradient of the loss is equal to the derivative (slope) of the curve, and tells you which way is "warmer" or "colder." When there are multiple weights, the gradient is a vector of partial derivatives with respect to the weights.
The partial derivative f with respect to x, denoted as follows:
fx
is the derivative of f considered as a function of x alone. To find the following:
fx
you must hold y constant (so f is now a function of one variable x), and take the regular derivative of f with respect to x


Intuitively, a partial derivative tells you how much the function changes when you perturb one variable a bit. In the preceding example:
fx(0,1)=e27.4
So when you start at (0,1), hold y constant, and move x a little, f changes by about 7.4 times the amount that you changed x.

In machine learning, partial derivatives are mostly used in conjunction with the gradient of a function.
Instead of predicting exactly 0 or 1, logistic regression generates a probability—a value between 0 and 1, exclusive

https://zhuanlan.zhihu.com/p/36902908
真正的飞跃发生在大学时,微积分为我们求函数的极值提供了一个统一的思路:找函数的导数等于0的点,因为在极值点处,导数必定为0。这样,只要函数的可导的,我们就可以用这个万能的方法解决问题,幸运的是,在实际应用中我们遇到的函数基本上都是可导的。





Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts