【1】机器学习实战 第二章 k近邻算法

1.tile函数的用法

tile函数的用法  tile函数是numpy中用来重复数组的函数,比如tile(A,n),功能是将数组A重复n次,构成一个新的数组。其中n可以是一个数字或一个数组。

2.sum函数

sum(a, axis=None, dtype=None, out=None, keepdims=False)

axis决定数组相加的形式

Examples
--------
>>> np.sum([0.5, 1.5])
2.0
>>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
1
>>> np.sum([[0, 1], [0, 5]])
6
>>> np.sum([[0, 1], [0, 5]], axis=0)
array([0, 6])
>>> np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])

3.字典的get函数

dict.get(key, default=None)

Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值

参数

  • key -- 字典中要查找的键。
  • default -- 如果指定键的值不存在时,返回该默认值。

eg:

dict = {'Name': 'Zara', 'Age': 27}

print "Value : %s" %  dict.get('Age')
print "Value : %s" %  dict.get('Sex', "Never")

%Value : 27
%Value : Never
4.scatter函数作图

matplotlib.pyplot.scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, hold=None, data=None, **kwargs)

x, y : array_like, shape (n, )

Input data 坐标向量

s : scalar or array_like, shape (n, ), optional, default: 20

size in points^2.标记大小

c : color or sequence of color, optional, default标记颜色

5.raw_input()与input()的区别

点击打开链接


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值