Locally weighted linear regression (LWLR) 的原理及其 normal equation 的证明

本文详细介绍了局部加权线性回归(LWLR)的基本原理,强调了它如何通过提高训练数据中查询点附近点的权重来估计目标变量。相比于普通线性回归,LWLR的运算量更大,不适合大规模数据,并且学习速度较慢。此外,还提供了正规方程的证明过程,用于找到最小化损失函数的参数θ。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原理讲解

caimouse 在他的关于 Locally weighted linear regression 的文章中指出了一些基本原理的 python 代码实现。

引用他的代码是这样的

#python 3.5.3  蔡军生    
#http://edu.youkuaiyun.com/course/detail/2592    
#  计算加权回归
 
import numpy as np
import random
import matplotlib.pyplot as plt
 
 
def gaussian_kernel(x, x0, c, a=1.0):
    """
    Gaussian kernel.
    :Parameters:
      - `x`: nearby datapoint we are looking at.
      - `x0`: data point we are trying to estimate.
      - `c`, `a`: kernel parameters.
    """
    # Euclidian distance
    diff = x - x0
    dot_product = diff * diff.T
    return a * np.exp(dot_product / (-2.0 * c**2))
 
 
def get_weights(training_inputs, datapoint, c=1.0):
    """
    Function that calculates weight matrix for a given data point and training
    data.
    :Parameters:
      - 	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值