【Machine Learning】Supervised Learning

本笔记基于清华大学《机器学习》的课程讲义监督学习相关部分,基本为笔者在考试前一两天所作的Cheat Sheet。内容较多,并不详细,主要作为复习和记忆的资料。

Linear Regression

Perceptron

  • f ( x ) = s i g n ( w ⊤ x + b ) f(x)=sign(w^\top x+b) f(x)=sign(wx+b)
  • convergence

Logistic Regression

  • output probability instead of labels.
  • Loss: Cross entropy X E ( y , p ) = − ∑ i y i log ⁡ p i XE(y,p)=-\sum_iy_i\log p_i XE(y,p)=iyilogpi. y i y_i yi is the actual probability

Ridge Regression

  • l 2 l_2 l2 regularization λ 2 ∥ w ∥ 2 2 \frac{\lambda}{2}\|w\|^2_2 2λw22
  • Shrink every coordinate: w ′ = w ⋅ ( 1 − η λ ) w'=w\cdot (1-\eta \lambda) w=w(1ηλ)
    • weight decay

LASSO Regression

  • Find sparse features: Want ∥ w ∥ 0 ≤ c \|w\|_0\le c w0c
  • l 1 l_1 l1 regularization λ ∥ w ∥ 1 \lambda\|w\|_1 λw1
  • Gradient: add or minus η λ \eta \lambda ηλ to pull w w w into 0 0 0.

Compressed Sensing*

  • Compare with LASSO: pick X t r a i n X_{train} Xtrain, observe Y t r a i n Y_{train} Ytrain, and learn w w w. Instead of given X t r a i n , Y t r a i n X_{train},Y_{train} Xtrain,Ytrain.
  • RIP condition: A matrix A A A is ( ϵ , s ) (\epsilon,s) (ϵ,s)-RIP if ∥ A x ∥ ≈ ∥ x ∥ \|Ax\|\approx \|x\| Axx for s s s-sparse x x x.
  • Application: reconstruct x x x on a RIP matrix is easy.
    • For sparse x x x
    • For spase x x x + some noise
    • Lemma: RIP implies almost orthogonality
    • Proof*
  • How to find RIP matrix: Random
  • Non-linear sparse: X = G ( Z ) X=G(Z) X=G(Z), Z Z Z is sparse, G G G is non-linear.

SVM

  • Minimize ∥ w ∥ 2 + λ ∑ i ξ i \|w\|_2+\lambda \sum_{i}\xi_i w2+λiξi.
    • Soft version: y i w ⊤ x i ≥ 1 − ξ i , ξ i ≥ 0 y_iw^\top x_i\ge 1-\xi_i,\xi_i\ge 0 yiwxi1ξi,ξi0.
    • maximize margin 1 / ∥ w ∥ 2 1/\|w\|_2 1/∥w2.

Dual derivation

  • Primal problem
    min ⁡ x x 2 x ≥ b \min_x x^2\\ x\ge b xminx2xb

  • Lagrangian L ( x , α ) = x 2 − α ( x − b ) s.t.  α ≥ 0 L(x,\alpha)=x^2-\alpha(x-b)\text{ s.t. }\alpha\ge 0 L(x,α)=x2α(xb) s.t. α0

    • Solution in primal problem correponds to a L ( x , α ) ≤ x 2 L(x,\alpha)\le x^2 L(x,α)x2. Thus min ⁡ x L ( x , α ) \min_x L(x,\alpha) minxL(x,α) is lower bound of the primal solution.
    • Dual: We want to find the maximum lowerbound max ⁡ α d ( α ) = max ⁡ α min ⁡ x L ( x , a ) \max_\alpha d(\alpha)=\max_\alpha \min_xL(x,a) maxαd(α)=maxαminxL(x,a).
    • Strong duality p ∗ = d ∗ p^*=d^* p=d
  • For SVM(hard version)

    • Primal: min ⁡ ∥ w ∥ 2 2 \min\frac{\|w\|_2}{2} min2w2, y i w ⊤ x i ≥ 1 y_iw^\top x_i\ge 1 yiwxi1.

    • Dual: maximize(solved by taking derivative)
      L ( w , α ) = ∥ w ∥ 2 2 − ∑ i α ( y i w ⊤ x i − 1 ) = ∑ i α i − 1 2 ∑ i ∑ j y i y j α i α j ⟨ x i , x j ⟩ α ≥ 0 w = ∑ i α i y i x i L(w,\alpha)=\frac{\|w\|_2}{2}-\sum_i\alpha (y_iw^\top x_i-1)\\ =\sum_{i}\alpha _i-\frac{1}{2}\sum_i\sum_jy_iy_j\alpha_i\alpha_j\langle x_i,x_j\rangle\\ \alpha\ge 0\\ w=\sum_{i}\alpha_iy_ix_i L(w,α)=2w2iα(yiwxi1)=iαi21ijyiyjαiαjxi,xjα0w=iαiyixi

Kernel Method

  • Replace ⟨ x i , x j ⟩ \langle x_i,x_j\rangle xi,xj with ⟨ ϕ ( x i ) , ϕ ( x j ) ⟩ \langle \phi(x_i),\phi(x_j)\rangle ϕ(xi),ϕ(xj)⟩ to embed x x x into a high dimension space.
  • Use k ( x i , x j ) k(x_i,x_j) k(xi,xj) to compute $\langle \phi(x_i),\phi(x_j)\rangle $. Usually gaussian kernel e − ∣ x i − x j ∣ 2 σ 2 e^{-\frac{|x_i-x_j|}{2\sigma^2}} e2σ2xixj
  • Mercer’s theorem: positive semidefinite kernel matrix has a corresponding embedding ϕ \phi ϕ.

Decision Tree

Boolean funcional analysis

  • X S ( x ) = ∏ i ∈ S x i \mathcal{X}_S(x)=\prod_{i\in S}x_i XS(x)=iSxi

  • f ( x ) = ∑ S f S ^ X S ( x ) f(x)=\sum_{S}\hat{f_S}\mathcal{X}_S(x) f(x)=SfS^XS(x)

  • f S ^ = ⟨ f , X S ⟩ = E x ∼ D [ f ( x ) X S ( x ) ] \hat{f_S}=\langle f,\mathcal{X}_S\rangle=\mathbb{E}_{x\sim D}[f(x)\mathcal{X}_S(x)] fS^=f,XS=ExD[f(x)XS(x)]

  • E x ∼ D [ f ( x ) 2 ] = ∑ S f S 2 ^ \mathbb{E}_{x\sim D}[f(x)^2]=\sum_{S}\hat{f_S^2} ExD[f(x)2]=SfS2^

  • Decision tree with s s s leaf nodes can be converted into log ⁡ ( s ϵ ) \log(\frac{s}{\epsilon}) log(ϵs)-degree, sparsity- s 2 ϵ \frac{s^2}{\epsilon} ϵs2 function that 2 ϵ 2\epsilon 2ϵ-appoximates T T T.

    • log depth
    • Combination of AND term
    • Take the bases S S S with big f S ^ \hat{f_S} fS^
  • Estimation

    • LMN: f S ^ = E x ∼ D [ f ( x ) X S ( x ) ] = 1 m ∑ i = 1 m f ( x i ) X S ( x i ) \hat{f_S}=\mathbb{E}_{x\sim D}[f(x)\mathcal{X}_S(x)]=\frac{1}{m}\sum_{i=1}^m f(x_i)\mathcal{X}_{S}(x_i) fS^=ExD[f(x)XS(x)]=m1i=1mf(xi)XS(xi)
      • Not work well in practice. Have not guarantees in noisy setting
    • Compressed Sensing
      • y = A x + e y=Ax+e y=Ax+e: x x x contains f S ^ \hat{f_S} fS^, A A A and y y y are from samples.
      • Lasso find x ∗ x^* x with bounded error.

Splitting variables

  • Greedy: Gini index*

Random forest

  • overfitting problem
  • Construct B B B trees, every tree is trained by n n n samples, which is from { ( x i , y i ) } i = 1 n \{(x_i,y_i)\}_{i=1}^n {(xi,yi)}i=1n with replacement(可重复), each element will miss with probability ( 1 − 1 n ) n = 1 e (1-\frac{1}{n})^n=\frac{1}{e} (1n1)n=e1
  • Output the average of B B B trees
  • Can also bag the features

Adaboost*

  • Combine weak learners. Make hard cases more likely.

  • Sample distribution D t ( i ) D_t(i) Dt(i) in t t t round. ϵ t = Pr ⁡ i ∼ D t [ h t ( x i ) ≠ y i ] \epsilon_t=\Pr_{i\sim D_t}[h_t(x_i)\neq y_i] ϵt=PriDt[ht(xi)=yi].

  • D 1 ( i ) = 1 m D_1(i)=\frac{1}{m} D1(i)=m1Learn h t h_t ht from D t ( i ) D_t(i) Dt(i)
    D t + 1 ( i ) = { 1 Z t D t ( i ) e − α t y i = h t ( x i ) 1 Z t D t ( i ) e α t y i ≠ h t ( x i ) α = 1 2 ln ⁡ ( 1 − ϵ t ϵ t ) D_{t+1}(i)=\begin{cases} \frac{1}{Z_t}D_t(i)e^{-\alpha_t} && y_i=h_t(x_i)\\ \frac{1}{Z_t}D_t(i)e^{\alpha_t} && y_i\neq h_t(x_i) \end{cases}\\ \alpha=\frac{1}{2}\ln\left(\frac{1-\epsilon_t}{\epsilon_t}\right) Dt+1(i)={Zt1Dt(i)eαtZt1Dt(i)eαtyi=ht(xi)yi=ht(xi)α=21ln(ϵt1ϵt)

  • H f i n a l = s i g n ( ∑ α t h t ) H_{final}=sign(\sum \alpha_t h_t) Hfinal=sign(αtht)

  • ϵ t = 1 2 − γ t \epsilon_t=\frac{1}{2}-\gamma_t ϵt=21γt.

    • γ t \gamma_t γt means how better this weak learner is than random classifier.

    e r r o r ( H f i n a l ) ≤ ∏ t 2 ϵ t ( 1 − ϵ t ) ≤ ∏ t 1 − 4 γ t 2 ≤ exp ⁡ ( − 2 ∑ t γ t 2 ) error(H_{final})\le \prod _{t}2\sqrt{\epsilon_t(1-\epsilon_t)}\le \prod_t\sqrt{1-4\gamma_t^2}\le \exp\left(-2\sum_t\gamma_t^2\right) error(Hfinal)t2ϵt(1ϵt) t14γt2 exp(2tγt2)

  • Proof:

    • D T ( i ) = 1 m exp ⁡ ( − y i ∑ t α t h t ( x i ) ∏ t Z t D_T(i)=\frac{1}{m}\frac{\exp(-y_i\sum_{t}\alpha _th_t(x_i)}{\prod_tZ_t} DT(i)=m1tZtexp(yitαtht(xi)

    • e r r o r ( H f i n a l ) = 1 m ∑ i = 1 m 1 y i f ( x i ) ≤ 0 = 1 m ∑ i = 1 m exp ⁡ ( − y i f ( x i ) ) = ∑ i = 1 m D T ( i ) ∏ t Z t = ∏ t Z t \begin{align*} error(H_{final})&=\frac{1}{m}\sum_{i=1}^m 1_{y_if(x_i)\le 0}\\ &=\frac{1}{m}\sum_{i=1}^m \exp(-y_if(x_i))\\ &=\sum_{i=1}^m D_T(i)\prod_t Z_t\\ &=\prod_t Z_t \end{align*} error(Hfinal)=m1i=1m1yif(xi)0=m1i=1mexp(yif(xi))=i=1mDT(i)tZt=tZt

    • Z t = ∑ i D t ( i ) exp ⁡ ( − α t y i h ( x i ) ) = ( 1 − ϵ t ) e − α t + ϵ t e α t Z_t=\sum_{i}D_t(i)\exp(-\alpha_ty_ih(x_i))=(1-\epsilon_t)e^{-\alpha_t}+\epsilon_te^{\alpha_t} Zt=iDt(i)exp(αtyih(xi))=(1ϵt)eαt+ϵteαt

      To minimize Z t Z_t Zt, α t = 1 2 ln ⁡ ( 1 − ϵ t ϵ t ) \alpha_t=\frac{1}{2}\ln(\frac{1-\epsilon_t}{\epsilon_t}) αt=21ln(ϵt1ϵt), then Z t = 2 ϵ t ( 1 − ϵ t ) Z_t=2\sqrt{\epsilon_t(1-\epsilon_t)} Zt=2ϵt(1ϵt)

  • Generalization

  • Drawback: Only binary classification

  • Extension: Gradient boosting: Regression, minimize 1 2 ∑ i ( F ( x i ) − y i ) 2 \frac{1}{2}\sum_i(F(x_i)-y_i)^2 21i(F(xi)yi)2

    • Adaboost use Coordinate descent: change α t \alpha_t αt from 0 0 0 to α t \alpha_t αt in round t t t. Only change one coordinate since the dimension is too large.
    • learn a new regression tree h ( x ) h(x) h(x) to fit ∂ L / ∂ F ( x i ) = F ( x i ) − y \partial L/\partial F(x_i)=F(x_i)-y L/F(xi)=F(xi)y for square loss. Then update F ′ ( x ) = F ( x ) + η h ( x ) F'(x)=F(x)+\eta h(x) F(x)=F(x)+ηh(x)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/609540.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MySQL8.0 升级

将 MySQL8.0.30 升级到 MySQL8.0.32 备份旧数据 rootLAPTOP-FPIQJ438:/data/backup# xtrabackup --backup --userroot --password123456 --socket/tmp/mysql.sock --target-dir/data/backup/ 2024-01-08T16:46:38.98768708:00 0 [Note] [MY-011825] [Xtrabackup] recognized s…

CPU控制的独立式键盘扫描实验

#include<reg51.h> //包含51单片机寄存器定义的头文件 sbit S1P1^4; //将S1位定义为P1.4引脚 sbit S2P1^5; //将S2位定义为P1.5引脚 sbit S3P1^6; //将S3位定义为P1.6引脚 sbit S4P1^7; //将S4位定义为P1.7引脚 unsigned char keyval; /…

连接服务器Mysql出现“Host ‘xxx‘ is not allowed to connect to this MySQL server“解决方法

远程连接提示&#xff1a;Host xxx is not allowed to connect to this MySQL server。是mysql未开启mysql远程访问权限导致。 登录mysql&#xff0c;发现出现了 Access denied for user ‘root’ T’localhost (using password: YES) 此时先找到my.cnf文件,使用命令mysql --…

http跟https有什么区别?

HTTPS和HTTP的概念&#xff1a; HTTP&#xff1a;是互联网上应用最为广泛的一种网络协议&#xff0c;是一个客户端和服务器端请求和应答的标准&#xff08;TCP&#xff09;&#xff0c;用于从WWW服务器传输超文本到本地浏览器的传输协议&#xff0c;它可以使浏览器更加高效&am…

智慧灌溉解决方案(基于物联网的智能灌溉系统)

​ 详情&#xff1a;智慧水务数字孪生安全监测解决方案提供商-星创 (key-iot.com.cn) 随着农业IOT的快速发展,智慧灌溉正成为提高农业水资源利用效率,实现精准灌溉的重要技术手段。完整的智慧灌溉系统由实地各类传感设备以及后台管理软件平台组成,可以实现对整个灌区的监测和精…

python(17)--文件的输入/输出

前言 在Python中&#xff0c;文件文本操作是非常重要的&#xff0c;主要有以下几个原因&#xff1a; 数据持久性&#xff1a;当你需要长期存储数据&#xff0c;如用户的个人信息、交易记录或数据库元数据等&#xff0c;将数据保存在文件中是一种常见的方法。文件系统提供了持…

非线性最小二乘问题的数值方法 —— 从高斯-牛顿法到列文伯格-马夸尔特法 (I)

Title: 非线性最小二乘问题的数值方法 —— 从高斯-牛顿法到列文伯格-马夸尔特法 (I) 文章目录 前言I. 从高斯-牛顿法II. 到阻尼高斯-牛顿法III. 再到列文伯格-马夸尔特法1. 列文伯格-马夸尔特法的由来2. 列文伯格-马夸尔特法的说明说明一. 迭代方向说明二. 近似于带权重的梯度…

步进电机介绍

一、什么是步进电机&#xff1a; 步进电机是一种将电脉冲信号转换成相应角位移或线位移的电动机。每输入一个脉冲信号&#xff0c;转子就转动一个角度或前进一步&#xff0c;其输出的角位移或线位移与输入的脉冲数成正比&#xff0c;转速与脉冲频率成正比。因此&#xff0c;步…

通付盾受邀出席2024安全市场年度大会,荣获“数字安全产业杰出贡献奖”!

1月5日&#xff0c;由国内数字产业独立的第三方调研咨询机构数世咨询主办&#xff0c;以“数字安全&#xff0c;未来可期”为主题的2024安全市场年度大会在北京举办。来自国内网络安全厂商300多人以线上线下方式参加本次大会&#xff0c;通过4个多小时高能演讲&#xff0c;聚焦…

线性代数_同济第七版

contents 前言第1章 行列式1.1 二阶与三阶行列式1.1.1 二元线性方程组与二阶行列所式1.1.2 三阶行列式 1.2 全排列和对换1.2.1 排列及其逆序数1.2.2 对换 1.3 n 阶行列式的定义1.4 行列式的性质1.5 行列式按行&#xff08;列&#xff09;展开1.5.1 引理1.5.2 定理1.5.3 推论 * …

【Vue】项目使用px2rem

使用方法 1.安装包 npm i postcss-px2rem2.编写配置文件 编写核心代码&#xff0c;命名随意&#xff0c;我这里命名为px2rem并放在src/utils文件夹内 // 基准大小 const baseSize 100 // 设置 rem 函数 function setRem() {// 当前页面宽度相对于 1920 宽的缩放比例&#xf…

RK3568平台开发系列讲解(驱动篇)pinctrl 函数操作集结构体讲解

🚀返回专栏总目录 文章目录 一、pinctrl_ops二、pinmux_ops三、pinconf_ops沉淀、分享、成长,让自己和他人都能有所收获!😄 pinctrl_ops:提供有关属于引脚组的引脚的信息。pinmux_ops:选择连接到该引脚的功能。pinconf_ops:设置引脚属性(上拉,下拉,开漏,强度等)。…

安全防御之可信计算技术

可信计算技术是一种计算机安全体系结构&#xff0c;旨在提高计算机系统在面临各种攻击和威胁时的安全性和保密性。它通过包括硬件加密、受限访问以及计算机系统本身的完整性验证等技术手段&#xff0c;确保计算机系统在各种攻击和威胁下保持高度安全和保密性。 一、可信计算基…

WPS Office找回丢失的工作文件

WPS office恢复办公文件方法有两种. 1.通过备份中心可以查看近期编辑 office 历史版本进行恢复. 2.缓存备份目录可以查看编辑过的 office 文件的历史版本&#xff0c;新版本 WPS 可以在配置工具-备份清理找到&#xff0c;2019 年旧版本 WPS 可以在新建任意 office 文件-文件-选…

【Java 设计模式】设计原则之单一职责原则

文章目录 1. 定义2. 好处3. 应用4. 示例结语 在面向对象设计中&#xff0c;单一职责原则是一个重要的设计原则之一。它提倡一个类应该只有一个原因引起变化&#xff0c;即一个类应该只有一个职责。在本文中&#xff0c;我们将深入研究单一职责原则&#xff0c;了解它的定义、优…

有信息搜索、最佳优先搜索、贪心搜索、A_搜索详解

文章目录 【人工智能】— 有信息搜索、最佳优先搜索、贪心搜索、A*搜索无/有信息的搜索Informed Search AlgorithmsBest-first search(最佳优先搜索)Greedy SearchA* Search解释说明A*搜索是代价最优的和完备的对搜索等值线如何理解【人工智能】— 有信息搜索、最佳优先搜索、贪…

异构微服务远程调用如何打jar包

1.服务提供方打 jar 包 RemoteUserService.java package com.finance.system.api;import com.finance.system.api.domain.dto.Enterprise; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springfra…

项目-新闻头条-数据管理平台-ajax综合案例

愿许秋风知我意&#xff0c;解我心中意难平。 项目介绍 项目准备 推荐使用&#xff0c; 每个程序员都有自己的管理方式。 验证码登录 HTML结构&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><met…

Linux网络的命令和配置

目录 一、网络配置命令 1、配置和管理网络接口 1.1 ifconfig 1.2 ip 1.2.1 ip link 1.2.2 ip addr 1.3 修改网络接口名 1.3.1 临时修改网络接口名 1.3.2 永久修改网络接口名 1.4 永久配置单网卡 1.5 永久配置双网卡 1.6 ethtool 2、查看和设置主机中路由表信息…

国芯科技荣膺高工智能汽车“年度车规MCU高成长供应商”,加速产品精准化系列化布局

2023年12月13—15日&#xff0c;2023&#xff08;第七届&#xff09;高工智能汽车年会在上海召开&#xff0c;大会以“寻找拐点”为主题&#xff0c;通过超80场主题演讲及多场圆桌对话&#xff0c;为智能汽车赛道参与者「备战2024」提供全方位的决策支持。 作为汽车电子芯片领…