Introduction

What is machine learning? 

Tom Mitchell provides a more modern definition: "A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E."

Example: playing checkers.

E = the experience of playing many games of checkers

T = the task of playing checkers.

P = the probability that the program will win the next game.

In general, any machine learning problem can be assigned to one of two broad classifications:

Supervised learning and Unsupervised learning.

Supervised Learning

In supervised learning, we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.

Supervised learning problems are categorized into "regression" and "classification" problems.

Regression-> a continuous output

Classification-> a discrete output

Example:

Given data about the size of houses on the real estate market, try to predict their price. Price as a function of size is a continuous output, so this is a regression problem.

We
could turn this example into a classification problem by instead
making our output about whether the house "sells for more or
less than the asking price." Here we are classifying the houses
based on price into two discrete categories.

Unsupervised Learning

Unsupervised learning allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don't necessarily know the effect of the variables.

We can derive this structure by clustering the data based on relationships among the variables in the data.

With unsupervised learning there is no feedback based on the prediction results.

Example:

Clustering: Take a collection of 1,000,000 different genes, and find a way to automatically group these genes into groups that are somehow similar or related by different variables, such as lifespan, location, roles, and so on.

Non-clustering: The "Cocktail Party Algorithm", allows you to find structure in a chaotic environment.

Linear Regression with One Variable

Model Representation

X(i)-> “input” variables, also called input features.

Y(i)->“output” or target variable

(X(i),Y(i)) -> a training example

the superscript “(i)” -> an index into the training set, and has nothing to do with exponentiation.

X-> the space of input values

Y-> the space of output values.

m-> the number of samples

function h : X → Y so that h(x) is a “good” predictor for the corresponding value of y.

When the target variable that we’re trying to predict is continuous,we call the learning problem a regression problem. When y can take on only a small number of discrete values, we call it a classification problem.

Cost Function

We can measure the accuracy of our hypothesis function by using a cost function.

This function is otherwise called the "Squared error function", or "Mean squared error(MSE)".

Cost Function - Intuition I

Our objective is to get the best possible line. The best possible line will be such so that the average squared vertical distances of the scattered points from the line will be the least. Ideally, the line should pass through all the points of our training data set. In such a case, the value of J(θ01) will be 0.

When θ1=1, we get a slope of 1 which goes through every single data point in our model. Conversely, when θ1=0.5, we see the vertical distance from our fit to the data points increase.

This increases our cost function to 0.58. Plotting several other points yields to the following graph:

Thus as a goal, we should try to minimize the cost function. In this case, θ1=1 is our global minimum.

Cost Function - Intuition II

A contour plot is a graph that contains many contour lines. A contour line of a two variable function has a constant value at all points of the same line. An example of such a graph is the one to the right below.

Taking any color and going along the 'circle', one would expect to get the same value of the cost function. For example, the three green points found on the green line above have the same value for J(θ01) and as a result, they are found along the same line. The circled x displays the value of the cost function for the graph on the left when θ0 = 800 and θ1= -0.15. Taking another h(x) and plotting its contour plot, one gets the following graphs:

When θ0 = 360 and θ1 = 0, the value of J(θ01) in the contour plot gets closer to the center thus reducing the cost function error. Now giving our hypothesis function a slightly positive slope results in a better fit of the data.

The graph above minimizes the cost function as much as possible and consequently, the result of θ1 and θ0 tend to be around 0.12 and 250 respectively. Plotting those values on our graph to the right seems to put our point in the center of the inner most 'circle'.

Gradient Descent

Now we need to estimate the parameters in the hypothesis function. That's where gradient descent comes in.

The gradient descent algorithm is:

repeat until convergence:

where

j=0,1 represents the feature index number.

At each iteration j, one should simultaneously update the parameters θ12,...,θn.

The size of each step is determined by the parameter α, which is called the learning rate.

Gradient Descent Intuition

The following graph shows that when the slope is negative, the value of θ1 increases and when it is positive, the value of θ1 decreases.

On a side note, we should adjust our parameter α to ensure that the gradient descent algorithm converges in a reasonable time.

How does gradient descent converge with a fixed step size α? approaches 0 as we approach the bottom of our convex function. At the minimum, the derivative will always be 0 and thus we get:

Gradient Descent For Linear Regression

This method looks at every example in the entire training set on every step, and is called batch gradient descent.

where m is the size of the training set, θ0 a constant that will be changing simultaneously with θ1 and xi, yi are values of the given training set (data).

The following is a derivation of for a single example :








最新文章

  1. Spring BeanNameAutoProxyCreator 与 ProxyFactoryBean区别
  2. Spring实现IOC
  3. Python简明语法
  4. 【javascript基础】4、原型与原型链
  5. PHP7安装笔记
  6. ASP.NET多线程下使用HttpContext.Current
  7. 总结mysql服务器查询慢原因与解决方法
  8. ssh 调优参数
  9. Sublime Text 添加到右键菜单 带菜单图标
  10. PHP学习笔记十四【面向对象】
  11. 正确释放Vector的内存
  12. jpgraph 折线图--解决中文乱码的问题(标题和图例)
  13. 通过LRU实现通用高效的超时连接探测
  14. 新建一个self hosted Owin+ SignalR Project(1)
  15. 交换左Ctrl键和Caps lock键
  16. JetBrains Goland 2018.2.1最新版破解
  17. Eclipse和Intel idea的常用技巧
  18. ArcGIS案例学习笔记_3_2_CAD数据导入建库
  19. c语言const和c++const
  20. 堆排序之Java实现

热门文章

  1. binary-tree-maximum-path-sum——二叉树任意一条路径上的最大值
  2. 定义自己的代码风格CheckStyle简单使用
  3. Python+Selenium框架 ---一个类文件多个测试方法情况下测试固件的写法
  4. 阿里云OSS对象存储 简单上传文件
  5. Sublime Text 3相关配置和设置
  6. UVA11770 - Lighting Away
  7. sed系列:行或者模式匹配删除特定行
  8. 平滑的滚动listview到一个指定位
  9. iOS不用上架就能下载安装ipa应用内测:使用FIR.im发布自己的移动端APP
  10. React-Router4按需加载