优达机器学习:朴素贝叶斯迷你项目2

练习:计算

  • 1
  • 0.0454545454545
  • 0.0454545454545
data = "So if you could just go ahead and pack up your stuff and move it down there, that would be terrific, OK?"
words = data.split(' ')
word_you = filter(lambda x:x=='you',words)
word_if = filter(lambda x:x=='if',words)
print float(len(word_you))/len(words)
print float(len(word_if))/len(words)

练习:最大可能性

sample_memo = '''
Milt, we're gonna need to go ahead and move you downstairs into storage B. We have some new people coming in, and we need all the space we can get. So if you could just go ahead and pack up your stuff and move it down there, that would be terrific, OK?
Oh, and remember: next Friday... is Hawaiian shirt day. So, you know, if you want to, go ahead and wear a Hawaiian shirt and jeans.
Oh, oh, and I almost forgot. Ahh, I'm also gonna need you to go ahead and come in on Sunday, too...
Hello Peter, whats happening? Ummm, I'm gonna need you to go ahead and come in tomorrow. So if you could be here around 9 that would be great, mmmk... oh oh! and I almost forgot ahh, I'm also gonna need you to go ahead and come in on Sunday too, kay. We ahh lost some people this week and ah, we sorta need to play catch up.
'''

def NextWordProbability(sampletext,word):
    words = sampletext.split(' ')
    res = {}
    for index,item in enumerate(words):
        if item == word:
            if words[index+1] not in res.keys():
                res[words[index+1]] = 1
            else:
                res[words[index+1]] += 1
    return res

练习:最佳分类器 示例

这里写图片描述

练习:最佳分类器练习

这里写代码片

练习:联合分布分析

  • 没搞懂

练习:区间知识填入

  • need
  • ahead
  • and
  • go
  • great
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值