Machine Learning Foundations(NTU) 第一次作业

Machine Learning Foundations(NTU) 第一次作业

PLA

DATA: https://d396qusza40orc.cloudfront.net/ntumlone%2Fhw1%2Fhw1_15_train.dat
Each line of the data set contains one (xn,yn) with xn∈R4. T
he first 4 numbers of the line contains the components of xn orderly, the last number is yn.
Please initialize your algorithm with w=0 and take sign(0) as −1

  • Question 15:

    Implement a version of PLA by visiting examples in the naive cycle using the
    order of examples in the data set. Run the algorithm on the data set.
    What is the number of updates before the algorithm halts?

  • Question 16:

    Implement a version of PLA by visiting examples in fixed, pre-determined random
    cycles throughout the algorithm. Run the algorithm on the data set. Please repeat
    your experiment for 2000 times, each with a different random seed. What is the average
    number of updates before the algorithm halts?

  • Question 17:

    Implement a version of PLA by visiting examples in fixed, pre-determined random cycles
    throughout the algorithm, while changing the update rule to be:
    wt+1 = wt + alpha * yn(t)xn(t)
    with alpha =0.5. Note that your PLA in the previous Question corresponds to alpha=1.
    Please repeat your experiment for 2000 times, each with a different random seed.
    What is the average number of updates before the algorithm halts?

import urllib2
import numpy as np
import random

# url = 'https://d396qusza40orc.cloudfront.net/ntumlone%2Fhw1%2Fhw1_15_train.dat'
# f = urllib2.urlopen(url)
# with open("hw1_15_train.dat", "wb") as code:
#    code.write(f.read())

def train_PLA():
    code = open("hw1_15_train.dat", "r")
    lines = code.readlines()
    xn = np.zeros((len(lines), 5)).astype(np.float)
    yn = np.zeros((len(lines),)).astype(np.int)
    learn_rate = 0.5

    for i in range(0, len(lines)):
        
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习是计算机科学中的一个重要分支,旨在通过设计和分析算法,使计算机系统能够从数据中自动学习和提高,并对未见过的数据提出准确的预测。在机器学习中,数据是关键。该领域利用计算方法对大量数据进行处理和分析,以发现数据中的模式和趋势。通过对这些数据模式进行建模和预测,机器学习使计算机系统能够自动地改进自己的决策和表现。 “基础机器学习”(Foundations of Machine Learning)是机器学习领域中的一个重要概念。它涵盖了机器学习的基本原理和算法,包括如何构建、评估和优化机器学习模型。这些基础理论和方法对于开发和使用先进的机器学习系统至关重要。 在基础机器学习中,重要的概念包括监督学习、无监督学习、半监督学习和强化学习。监督学习是一种从已知的训练数据中构建模型的方法,用于对新数据进行预测。无监督学习是一种从未标记的数据中挖掘模式的方法,而半监督学习则是两者的结合。强化学习则是一种通过与环境交互来学习的方法,根据奖励信号调整模型。 此外,基础机器学习还包括模型评估和选择、特征选择和提取、优化方法等。这些技术和方法使机器学习更加健壮和可靠,并为开发新的机器学习算法提供基础。 总的来说,基础机器学习是机器学习领域的核心概念之一,对于发展高级机器学习和人工智能系统至关重要。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值