python
傅晨明
毕业于杭州电子科技大学
展开
-
python scikit-learn中文翻译
scikit-learn转载 2017-05-23 16:22:16 · 1179 阅读 · 0 评论 -
python的seed和tensorflow的seed
1、python seed参考:http://www.runoob.com/python/func-number-seed.html描述 seed() 方法改变随机数生成器的种子,可以在调用其他随机模块函数之前调用此函数。语法 以下是 seed() 方法的语法:import randomrandom.seed ( [x] )注意:seed(()是不能直接访问的,需要导入...原创 2018-04-16 08:52:15 · 4508 阅读 · 0 评论 -
Python List sort()方法
参考:http://www.runoob.com/python/att-list-sort.html描述 sort() 函数用于对原列表进行排序,如果指定参数,则使用比较函数指定的比较函数。语法 sort()方法语法:list.sort([func])参数 func – 可选参数, 如果指定了该参数会使用该参数的方法进行排序。返回值 该方法没有返回值,但是会对列表的...原创 2018-04-03 14:14:18 · 607 阅读 · 0 评论 -
scipy.stats.norm
参考:https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html首先来看下stats模块。Scipy的stats模块包含了多种概率分布的随机变量,随机变量分为连续和离散两种。所有连续随机变量都是rv_continuous的派生类的对象,而所有的离散随机变量都是rv_discrete的派生类的对象。可以...原创 2018-04-03 16:56:07 · 11582 阅读 · 0 评论 -
numpy的linspace使用详解
文档地址: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.htmlParameters(参数): start : 序列的起始点.stop : 序列的结束点num : 生成的样本数,默认是50。必须是非负。endpoint : 如果True,'stop'是最后一个样本。否则,它不包括在内。默认为T...原创 2018-03-20 10:40:49 · 4628 阅读 · 0 评论 -
np.dot()、np.multiply()、tf.matmul()、tf.multiply()
import tensorflow as tfimport numpy as npx1 = ([[1, 2, 3], [1, 2, 3], [1, 2, 3]])x2 = ([[2, 1, 1], [2, 1, 1], [2, 1, 1]])y1 = np.dot(x1, x2)y2 = np.multiply(x1, x2)print('1、np.dot\n', y1)print...原创 2018-06-20 14:42:27 · 3082 阅读 · 1 评论 -
numpy的random模块详解
参考: https://docs.scipy.org/doc/numpy/reference/routines.random.html https://blog.csdn.net/akadiao/article/details/78252840?locationNum=9&fps=1 https://blog.csdn.net/kancy110/article/details/696...原创 2018-04-17 08:37:23 · 547 阅读 · 0 评论 -
numpy.random.normal
文档地址: https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.normal.htmlnumpy.random.normal(loc=0.0, scale=1.0, size=None)loc:float 此概率分布的均值(对应着整个分布的中心centre)scale:float 此概率分布...原创 2018-03-20 14:58:33 · 4153 阅读 · 1 评论 -
np的newaxis使用
import numpy as npprint(type(np.newaxis))print(np.newaxis == None)输出:<class 'NoneType'>True从上面可以看出:np.newaxis 在使用和功能上等价于 None,其实就是 None 的一个别名。x = np.arange(3)print(x)print(x[:...原创 2018-03-20 14:26:19 · 486 阅读 · 0 评论 -
使用matplotlib进行绘画
import numpy as npimport matplotlib.pyplot as pltdef simple_line_plot(x,y,figure_no): plt.figure(figure_no) plt.plot(x,y) plt.xlabel("x values") plt.ylabel("y values") plt.title("S原创 2017-06-20 19:04:50 · 303 阅读 · 0 评论 -
python科学计算-数值计算-NumPy
1、NumPy 的基本对象NumPy和SciPy的所有科学计算功能建立在NumPy两种基本类型的对象之上。第一种对象是N维数组对象,即ndarray;第二种对象是通用函数对象,即ufunc。除了这两种对象,还有其他一些对象建立在它们之上。1.1 N 维数组对象原创 2017-06-11 12:48:41 · 1531 阅读 · 0 评论 -
python科学计算-01程序包和API简介
Python对科学计算的支持,是通过不同科学计算功能的程序包和API建立的。对于科学计算的每个方面,我们都有大量的选择以及最佳的选择。 Python科学计算各个方面的可选包如下所示。画图:目前,最流行的二维图制作程序库是matplotlib。还有许多画图包,如Visvis、 Plotly、HippoDraw、 Chaco、 MayaVI、 Biggles、 Pychart、 Bokeh。还有一些画原创 2017-06-11 12:37:24 · 1159 阅读 · 0 评论 -
图像与原始字节之间的转换
import cv2import numpy as npimport os#生成120000个随机字节数组randomByteArray = bytearray(os.urandom(120000))flatNumpyArray = np.array(randomByteArray)#生成400x300的灰色图像grayImage = flatNumpyArray.reshape...原创 2018-04-18 10:36:12 · 259 阅读 · 0 评论 -
OpenCV读写图像文件
OpenCV的imread函数()和imwrite( )函数能支持各种静态图像文件格式。不同系统支 持的文件格式不一样,但都支持BMP格式,通常还应该支持PNG , JPFG和TIFF格式。1、通过二维Numpy数组来简单创建一个黑色的正方形图像:img = np.zeros((3,3),dtype=np.uint8)print(img)打印:[[0 0 0] [...原创 2018-04-18 10:09:26 · 5020 阅读 · 0 评论 -
numpy.full
参考:https://docs.scipy.org/doc/numpy/reference/generated/numpy.full.htmlimport numpy as npa = np.full((2, 2), np.inf)b = np.full((2, 2), 10)print(a)print(b)输出:[[ inf inf] [ inf inf]][[...原创 2018-03-27 18:11:07 · 18776 阅读 · 1 评论 -
Python 字典(Dictionary) get()方法
参考:http://www.runoob.com/python/att-dictionary-get.html描述 Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值。语法 get()方法语法:dict.get(key, default=None)参数 key – 字典中要查找的键。 default – 如果指定键的值...原创 2018-03-27 17:06:02 · 398 阅读 · 0 评论 -
Python 利用字典计算数据中不重复的数量
因为字典的键必须是唯一的,那么将数据作为键值,那么键的数量就是不重复的数量datas = "x1 x2 x2 x3 x4 x5 x6 x7 x7 x8 x9"for data in datas.split(): print(data)dict = {data: None for data in datas.split()}#data为键,None为键对应的值(任意值)pri...原创 2018-03-22 14:58:22 · 3633 阅读 · 0 评论 -
Python set() 函数
参考:http://www.runoob.com/python/python-func-set.html描述 set() 函数创建一个无序不重复元素集,可进行关系测试,删除重复数据,还可以计算交集、差集、并集等。语法 set 语法:class set([iterable])参数说明: iterable – 可迭代对象对象;返回值 返回新的集合对象。实例 以下实例展...原创 2018-03-30 11:10:02 · 2030 阅读 · 0 评论 -
Python index()方法
描述 Python index() 方法检测字符串中是否包含子字符串 str ,如果指定 beg(开始) 和 end(结束) 范围,则检查是否包含在指定范围内,该方法与 python find()方法一样,只不过如果str不在 string中会报一个异常。语法 index()方法语法:str.index(str, beg=0, end=len(string))参数str ...原创 2018-03-30 17:42:21 · 5478 阅读 · 3 评论 -
Python strip 和 split方法
一、strip http://www.runoob.com/python/att-string-strip.html 描述 Python strip() 方法用于移除字符串头尾指定的字符(默认为空格)。语法 strip()方法语法:str.strip([chars]);参数 chars – 移除字符串头尾指定的字符。返回值 返回移除字符串头尾指定的字符生成的新字符串。...原创 2018-03-21 10:11:59 · 904 阅读 · 1 评论 -
python collections.Counter
参考:https://docs.python.org/2/library/collections.html#collections.Counter1、Counter类创建的四种方法:import collectionsc = collections.Counter() # 创建一个空的Counter类print(c)c = collections.Counter('gallaha...原创 2018-03-21 11:02:27 · 214 阅读 · 0 评论 -
Python sorted() 函数
参考:http://www.runoob.com/python/python-func-sorted.html描述 sorted() 函数对所有可迭代的对象进行排序操作。sort 与 sorted 区别: sort 是应用在 list 上的方法,sorted 可以对所有可迭代的对象进行排序操作。 list 的 sort 方法返回的是对已经存在的列表进行操作,而内建函数 sorted ...原创 2018-03-21 11:16:17 · 118 阅读 · 0 评论 -
Python zip() 函数
http://www.runoob.com/python/python-func-zip.html描述 zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。 如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作符,可以将元组解压为列表。语法 zip 语法: zip([iterable, …])...原创 2018-03-21 14:54:59 · 545 阅读 · 0 评论 -
Python 列表(List)
参考:http://www.runoob.com/python/python-lists.html序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。Python有6个序列的内置类型,但最常见的是列表和元组。序列都可以进行的操作包括索引,切片,加,乘,检查成员。此外,Python已经内置确定序列的长度...原创 2018-03-21 15:33:08 · 494 阅读 · 0 评论 -
Python 元组
参考:http://www.runoob.com/python/python-tuples.htmlPython 元组 Python的元组与列表类似,不同之处在于元组的元素不能修改。元组使用小括号,列表使用方括号。元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可。如下实例:tup1 = ('physics', 'chemistry', 1997, 2000)t...原创 2018-03-21 17:02:40 · 200 阅读 · 0 评论 -
Python 字典(Dictionary)
参考:http://www.runoob.com/python/python-dictionary.htmlPython 字典(Dictionary) 字典是另一种可变容器模型,且可存储任意类型对象。 字典的每个键值 key=>value 对用冒号 : 分割,每个键值对之间用逗号 , 分割,整个字典包括在花括号 {} 中 ,格式如下所示:d = {key1 : value1,...原创 2018-03-21 17:45:26 · 156 阅读 · 0 评论 -
简单爬虫获取排列三开奖号码
直接上代码import requestsfrom bs4 import BeautifulSoupclass Spider: def getHtmlData(self): url = "http://datachart.500.com/pls/history/inc/history.php?limit=100" response = request...原创 2018-03-26 15:33:44 · 1788 阅读 · 1 评论 -
Python open() 函数
参考:http://www.runoob.com/python/python-func-open.htmlpython open() 函数用于打开一个文件,创建一个 file 对象,相关的方法才可以调用它进行读写。 更多文件操作可参考:Python 文件I/O。 函数语法open(name[, mode[, buffering]])参数说明:name : 一个包含了你要访...原创 2018-03-22 11:25:24 · 1054 阅读 · 0 评论 -
Python map() 函数
参考:http://www.runoob.com/python/python-func-map.html描述 map() 会根据提供的函数对指定序列做映射。 第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。语法 map() 函数语法:map(function, iterable, ...)...原创 2018-03-27 16:39:53 · 2950 阅读 · 0 评论 -
线性回归例子(Linear Regression Example)
原文地址: http://sklearn.lzjqsdd.com/auto_examples/linear_model/plot_ols.html#example-linear-model-plot-ols-pyThis example uses the only the first feature of the diabetes dataset, in order to illustrat...翻译 2017-06-10 20:39:50 · 6715 阅读 · 0 评论