![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
机器学习
zhglinux
这个作者很懒,什么都没留下…
展开
-
python 通过对索引 取反 获得中位数
def get_median(data): data.sort() # print data half = len(data)//2 # // 取整除 - 返回商的整数部分 9//2 输出结果 4 , 9.0//2.0 输出结果 4.0 # print data[half] # print data[~half] return (data[ha原创 2017-10-07 18:38:21 · 1191 阅读 · 1 评论 -
python sort、sorted高级排序技巧
http://www.jb51.net/article/57678.htmPython list内置sort()方法用来排序,也可以用python内置的全局sorted()方法来对可迭代的序列排序生成新的序列。1)排序基础简单的升序排序是非常容易的。只需要调用sorted()方法。它返回一个新的list,新的list的元素基于小于运算符(__lt__)来排序。转载 2017-10-07 17:28:49 · 380 阅读 · 0 评论 -
calculate and return the accuracy on the test data
def NBAccuracy(features_train, labels_train, features_test, labels_test): """ compute the accuracy of your Naive Bayes classifier """ ### import the sklearn module for GaussianNB from skle原创 2017-10-18 17:32:18 · 364 阅读 · 0 评论 -
Mac OS X 上如何切换默认的 Python 版本?
转载于: https://www.zhihu.com/question/30941329 知乎Mac OS X 上如何切换默认的 Python 版本?系统版本OS X Yosemite 10.10.3,自带的Python版本是2.7.9。python3.4已经成功安装,在Terminal里输入命令python3.4可以正常用3.4.3工作,但是输入命令pytho转载 2017-10-11 09:59:16 · 1762 阅读 · 0 评论 -
python: ValueError: math domain error
import mathtmp3 = math.log((1/3), 2)#print tmp3错误提示:File "/self/_UDACity/pythonLearning/mathTest.py", line 28, in tmp3 = math.log((1/3), 2)#ValueError: math domain er原创 2017-10-26 13:53:57 · 61239 阅读 · 1 评论