Python
文章平均质量分 52
algzjh
这个作者很懒,什么都没留下…
展开
-
Python学习笔记-运算符
python 中的 and 从左到右计算表达式,若所有值均为真,则返回最后一个值,若存在假,返回第一个假值; or 也是从左到有计算表达式,返回第一个为真的值; 其中数字 0 是假,其他都是真; 字符 “” 是假,其他都是真;原创 2017-07-01 01:11:37 · 247 阅读 · 0 评论 -
opencv学习笔记二
Display and Write an imageimport numpy as npimport cv2from matplotlib import pyplot as pltimg = cv2.imread('img.tif', 0)cv2.imshow('image', img)k = cv2.waitKey(0) & 0xFFif k == 27: cv2.destroy转载 2017-09-30 15:58:51 · 272 阅读 · 0 评论 -
opencv学习笔记三
Making Borders for Images (Paddinig)import numpy as npimport cv2import matplotlib.pyplot as pltBLUE = [255,0,0]img1 = cv2.imread('lena_std.tif')replicate = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BOR转载 2017-09-30 16:39:37 · 342 阅读 · 0 评论 -
线性回归
最佳拟合直线from numpy import *import matplotlib.pyplot as pltdef loadDataSet(fileName): # general function to parse tab -delimited floats numFeat = len(open(fileName).readline().split('\t')) - 1 # g转载 2017-09-30 17:06:57 · 255 阅读 · 0 评论 -
opencv学习笔记(四)
Arithmetic Operation on Imagesimport cv2import numpy as npx = np.uint8([250])y = np.uint8([10])print(cv2.add(x,y)) # saturated operationprint(x+y) # modulo operationImage Blendingimport cv2import n转载 2017-10-02 21:44:44 · 363 阅读 · 0 评论 -
opencv学习笔记(五)
Measuring Performance with OpenCVimport cv2import numpy as npimg1 = cv2.imread('messi5.jpg')e1 = cv2.getTickCount()for i in range(5,49,2): img1 = cv2.medianBlur(img1,i)e2 = cv2.getTickCount()t转载 2017-10-02 21:53:35 · 329 阅读 · 0 评论 -
Multidimensional Scaling
import numpy as npimport matplotlib.pyplot as pltD=np.array([[0,411,213,219,296,397], [411,0,204,203,120,152], [213,204,0,73,136,245], [219,203,73,0,90,191], ...转载 2018-07-18 09:27:16 · 581 阅读 · 0 评论 -
Datasets Generator
random.seed(datetime.now()) X, y = make_blobs(n_samples=500, centers=5, n_features=2) print(X.shape) print(y) plt.scatter(X[:, 0], X[:, 1], c=y, alpha=0.5) plt.show()原创 2018-10-10 21:59:17 · 558 阅读 · 0 评论 -
Python学习手册
1、命名空间就是变量(也就是变量名)的封装。它在Python中以一个带有属性的对象的形式出现。每个模块文件自动成为一个命名空间:也就是说,一个对变量的封装,这些变量对应了顶层文件的赋值。from和import很相似,只不过增加了对载入组件的变量名的额外的赋值。从技术上讲,from复制了模块的属性,以便属性能够成为接受者的直接变量。...转载 2019-03-26 16:34:34 · 209 阅读 · 0 评论 -
HackerRank-Mehta and the Typical Supermarket
Mehta and the Typical SupermarketMehta is a very rich guy. He has types of coins, and each type of coin is available in an unlimited supply.So Mehta goes to a supermarket to buy monthly groceries. The转载 2017-07-18 11:44:40 · 398 阅读 · 0 评论 -
K-近邻算法
注意字典排序的使用:# -*- coding: utf-8 -*-'''@File : KNNtest_1.py@desc : kNN: k Nearest NeighborsInput: inX: vector to compare to existing dataset (1xN) dataSet: size m data set of kn转载 2017-07-20 11:30:23 · 217 阅读 · 0 评论 -
Python学习笔记-数字&字符串
1、整型(int)、浮点型(float)、复数( (complex)) 2、数学常量 pi,e 3、可以对已存在的字符串进行修改,并赋值给另一个变量 4、\oyy 八进制数,yy代表的字符,例如:\o12代表换行 5、\xyy 十六进制数,yy代表的字符,例如:\x0a代表换行 6、r/R 原始字符串 - 原始字符串:所有的字符串都是直接按照字面的意思来使用,没有转义特殊或不能打印原创 2017-07-02 01:28:25 · 341 阅读 · 0 评论 -
Python3学习笔记-基本数据类型
1、Python可以同时为多个变量赋值,如a, b = 1, 2。 2、一个变量可以通过赋值指向不同类型的对象。 3、数值的除法(/)总是返回一个浮点数,要获取整数使用//操作符。 4、在混合计算时,Python会把整型转换成为浮点数。 5、Python中的字符串用单引号(‘)或双引号(“)括起来,同时使用反斜杠()转义特殊字符。 6、Python 字符串不能被改变。向一个索引位置赋值,比原创 2017-06-26 21:52:31 · 467 阅读 · 0 评论 -
HackerRank-Arrays - DS
Arrays - DSAn array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, , of size , each memory location has some unique index, (where ), th原创 2017-07-15 10:55:30 · 496 阅读 · 0 评论 -
hackerrank-2D Array - DS
2D Array - DSContext Given a 2D Array, :1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this原创 2017-07-15 11:22:58 · 810 阅读 · 0 评论 -
HackerRank-Left Rotation
Left RotationA left rotation operation on an array of size shifts each of the array’s elements unit to the left. For example, if left rotations are performed on array , then the array would become .G原创 2017-07-15 11:47:16 · 508 阅读 · 0 评论 -
HackerRank-Hash Tables: Ransom Note
Hash Tables: Ransom NoteA kidnapper wrote a ransom note but is worried it will be traced back to him. He found a magazine and wants to know if he can cut out whole words from it and use them to create原创 2017-07-15 12:24:00 · 648 阅读 · 0 评论 -
HackerRank-Tree: Inorder Traversal
Tree: Inorder TraversalComplete the inOrder function in your editor below, which has parameter: a pointer to the root of a binary tree. It must print the values in the tree’s inorder traversal as a si原创 2017-07-16 00:39:07 · 599 阅读 · 0 评论 -
HackerRank-Tree: Level Order Traversal
Tree: Level Order TraversalYou are given a pointer to the root of a binary tree. You need to print the level order traversal of this tree. In level order traversal, we visit the nodes level by level fr原创 2017-07-16 00:42:03 · 461 阅读 · 0 评论 -
Python小技巧
字符串运算>>> my_string = "Hello World!">>> print(my_string*2)Hello World!Hello World!>>> print(my_string[::-1])!dlroW olleH>>> word_list = ['awesome', 'is', 'this...原创 2019-10-06 20:04:17 · 260 阅读 · 0 评论