Machine Learning:Model and Cost Function

Model Representation

x(i) to denote the “input” variables (living area in this example), also called input features

y(i) to denote the “output” or target variable that we are trying to predict (price)

A pair (x(i) , y(i) ) is called a training example, and the dataset that we’ll be using to learn—a list of m training examples (x(i),y(i));i=1,…,m——is called a training set.

"(i)” in the notation is simply an index into the training set

To describe the supervised learning problem slightly more formally, our goal is, given a training set, to learn a function h : X -> Y so that h(x) is a “good” predictor for the corresponding value of y. For historical reasons, this function h is called a hypothesis. Seen pictorially, the process is therefore like this:
在这里插入图片描述When the target variable that we’re trying to predict is continuous, such as in our housing example, we call the learning problem a regression problem. When y can take on only a small number of discrete values (such as if, given the living area, we wanted to predict if a dwelling is a house or an apartment, say), we call it a classification problem.

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.
在这里插入图片描述
在这里插入图片描述

假设h(x)=θ1x,则代价函数J(θ1)只有一个参数

当θ1=1时,J(1)=0
在这里插入图片描述
当θ1=0.5时,J(0.5)=0.58333
在这里插入图片描述
将其他点都描绘出来可得下图,作为目标,我们要最小化代价函数,所以当θ1=1时,有最小值为0
在这里插入图片描述

假设h(x)=θ1+θ0x,则代价函数J(θ0,θ1)有两个参数

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.

当θ0=800,θ1=-0.15时
在这里插入图片描述
当θ0=360,θ1=0时
在这里插入图片描述
当θ0在250左右,θ1在0.12左右时,有接近最小值的J(θ0,θ1),最小值位于最里面圆的中心
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿S先森丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值