- 博客(36)
- 资源 (8)
- 收藏
- 关注
原创 专利撰写教程网站合集
专利检索网站:http://www.soopat.com/专利模板:关注公众号“小黑黑的栖息地”回复“专利模板”链接:https://pan.baidu.com/s/1VgtTJDHHsv6F5PZs2W5pKg 提取码:70kg[必备]专利撰写讲解 发明专利实用新型外观设计专利20200505科学研究入门讲座-I 专利撰写与申请-西南交大...
2020-07-24 12:10:30 554
原创 sklearn距离度量metrics.pairwise_distances
本文的csdn链接:sklearn.metrics.pairwise_distanceshaversine distance:查询链接cosine distance:查询链接minkowski distance:查询链接chebyshev distance:查询链接hamming distance:查询链接correlation distance:查询链接correlation distance:查询链接Return the standardized Eucli
2020-07-23 22:55:34 6281 1
原创 sklearn核函数additive_chi2_kernel
sklearn.metrics.pairwise.additive_chi2_kernel>>> X = [[0, 1], [1, 0], [.2, .8], [.7, .3]]>>> y = [0, 1, 0, 1]>>> K = chi2_kernel(X, gamma=.5)>>> Karray([[1. , 0.36787944, 0.89483932, 0.58364548],[0.36787944, 1. ,
2020-07-23 22:48:05 625
原创 numpy.zeros_like和numpy.ones_like
生成一个和原来的array形状相同,但是是用0或1填充的arraynumpy.zeros_like参考文档numpy.ones_like参考文档>>> import numpy as np>>> x = np.arange(6).reshape(3,2)>>> xarray([[0, 1], [2, 3], [4, 5]])>>> np.zeros_like(x)array([[0, 0],
2020-07-23 16:50:57 449
原创 sklearn聚类方法hierarchical clustering
两个点集之间距离的方法有三种度量方式:Single LinkageThe distance between two clusters is defined as the shortest distance between two points in each cluster. For example, the distance between clusters “r” and “s” to the left is equal to the length of the arrow between thei
2020-07-18 16:40:37 1246
原创 numpy随机数 numpy.random
numpy.random模块快速入门(更新中)文章目录简单快速的随机数生成numpy.random.rand(d0, d1, ..., dn)numpy.random.randn(d0, d1, ..., dn)randint(low[, high, size, dtype])常见分布率的随机数生成不常用分布率的随机数生成简单快速的随机数生成numpy.random.rand(d0, d1, …, dn)Random values in a given shape.Create an array
2020-07-15 11:32:54 256
原创 numpy中的常数constants
numpy.Inf(inf)IEEE 754 floating point representation of (positive) infinity.See Alsonumpy.InfinityIEEE 754 floating point representation of (positive) infinity.Use inf because Inf, Infinity, PINF and infty are aliases for inf. For more details, see inf.n
2020-07-15 11:12:40 1146
原创 numpy找非零元素并计数 numpy.nonzero 和 numpy.count_nonzero
numpy.nonzero(a)Return the indices of the elements that are non-zero.示例x = np.array([[3, 0, 0], [0, 4, 0], [5, 6, 0]])np.nonzero(x)(array([0, 1, 2, 2], dtype=int64), array([0, 1, 0, 1], dtype=int64))也就是 [0 0], [1 1], [2 0], [2 1]位置的元素不为0numpy.coun
2020-07-14 20:13:47 23844
原创 numpy选取满足特定条件的元素numpy.extract
numpy.extract(condition, arr)Return the elements of an array that satisfy some condition.等价于:extractis equivalent to arr[condition].Parameterscondition [array_like]An array whose nonzero or True entries indicate the elements of arr to extract.arr [ar
2020-07-14 20:06:57 2774
原创 numpy中的元素替换numpy.place
numpy.place(arr, mask, vals)Change elements of an array based on conditional and input values.arr [ndarray]Array to put data into.mask [array_like]Boolean mask array. Must have the same size as a.vals [1-D sequence]Values to put into a.示例import nu
2020-07-14 19:59:35 10691
原创 numpy排序 numpy.sort/argsort, numpy.lexsort,numpy.sort_complex,numpy.partition/argpartition
numpy.sort(a, axis=-1, kind=None)Return a sorted copy of an array.a [array_like]Array to be sorted.axis [int or None, optional]Axis along which to sort. If None, the array is flattened beforesorting. The default is -1, which sorts along the last axis.
2020-07-14 18:22:25 383
原创 sklearn评价分类结果 sklearn.metrics
accuracy_scorefrom sklearn.metrics import accuracy_scorey_pred = [0, 2, 1, 3]y_true = [0, 1, 2, 3]accuracy_score(y_true, y_pred)结果0.5average_accuracy_scorefrom sklearn.metrics import average_precision_scorey_true = np.array([0, 0, 1, 1])y_sco
2020-07-10 23:13:39 1176
原创 numpy business day 相关函数
The function busday_offsetallows you to apply offsets specified in business days to datetimes with a unit of ‘D’ (day).np.busday_offset('2011-06-23', 1)numpy.datetime64('2011-06-24')When an input date falls on the weekend or a holiday, busday_offset firs
2020-07-09 18:03:31 396
原创 numpy 实现矩阵插入行或列 numpy.insert
numpy.insert(arr, obj, values, axis=None)Official Documentarr: array_likeInput array.obj: int, slice or sequence of intsObject that defines the index or indices before which values is inserted.values: array_likeValues to insert into arr. If the type
2020-07-09 14:43:21 3067
原创 numpy 找到矩阵中值为nan的元素 numpy.isnan
numpy.isnan(a,axis=None,keepdims=no value)官方文档Test element-wise for NaN and return result as a boolean array.示例import numpy as npa = np.array([[1, 2], [3, np.nan]])print(np.isnan(a))结果[[False False] [False True]]
2020-07-09 14:19:51 4655
原创 numpy寻找矩阵最大和最小的元素 nanmax,nanmin
numpy.nanmax(a, axis=None, out=None, keepdims=no value)官方文档Return the maximum of an array or maximum along an axis, ignoring any NaNs.示例1.import numpy as npa = np.array([[1, 2], [3, np.nan]])print(np.nanmax(a))结果3.0示例2. 指定 axis,返回没一行或每一列的最大值原理可
2020-07-09 14:09:29 1645
原创 numpy阶跃函数 numpy.heaviside
numpy.heaviside(x1,x2)Compute the Heaviside step function.官方链接x1 [array_like] Input values.x2 [array_like] The value of the function when x1 is 0.示例:np.heaviside([-1.5, 0, 2.0], 0.5)array([ 0. , 0.5, 1. ])np.heaviside([-1.5, 0, 2.0], 1)array([
2020-07-09 13:49:28 4579 1
原创 numpy符号函数 numpy.sign
numpy.sign官方链接示例:np.sign([1,-5])Out[7]: array([ 1, -1])
2020-07-09 13:43:42 918
原创 numpy弧度制和角度制转换deg2rad, rad2deg
把45°转化为π4\frac{\pi}{4}4πnp.deg2rad(45)Out[4]: 0.7853981633974483把π4\frac{\pi}{4}4π转化为45°np.rad2deg(np.pi/4)Out[6]: 45.0
2020-07-09 13:39:42 14832
原创 numpy.ndarray 常用运算符操作
示例:import numpy as npmat= np.array([1, -3, 5])print('mat<4',mat<4)print('mat<4',mat.__lt__(4))print('mat<=4',mat.__le__(4))print('mat>',mat>4)print('mat>',mat.__gt__(4))print('mat>=',mat.__ge__(4))print('mat==4',mat.__eq__(
2020-07-09 11:47:25 504
原创 numpy.real 和 numpy.image
示例:import numpy as npmat= np.array([1+2j, 3+4j, 5+6j])print('mat=',mat)print('实部:',np.real(mat))print('虚部:',np.imag(mat))结果:mat= [1.+2.j 3.+4.j 5.+6.j]实部: [1. 3. 5.]虚部: [2. 4. 6.]相当于mat.realmat.imag...
2020-07-09 11:12:25 4979
原创 numpy 删除矩阵中的部分数据 numpy.delete
numpy.delete官方链接Return a new array with sub-arrays along an axis deleted.示例:import numpy as npmat= np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])print('mat=',mat)print('删除第0行:',np.delete(mat,0,axis=0))print('删除第0列:',np.delete(mat,0,axis=1))结果:ma
2020-07-09 10:59:38 3527
原创 numpy 改变矩阵形状numpy.reshape和ndarray.reshape
numpy.reshape官方链接下面展示实现reshape的两种方法示例:import numpy as npmat= np.array([[1,2,3,4],[5,6,7,8]])print('方法1:',mat.reshape(1,mat.size))print('方法2:',np.reshape(mat,(1,mat.size)))结果:方法1: [[1 2 3 4 5 6 7 8]]方法2: [[1 2 3 4 5 6 7 8]]...
2020-07-09 10:44:57 701
原创 numpy.ndarray实现扁平化numpy.ndarray.flatten
numpy.ndarray.flatten()官方链接a = np.array([[1,2], [3,4]])print(np.flatten())结果[1 2 3 4 5 6 7 8]相当于print(mat.reshape(1,mat.size))
2020-07-09 10:40:48 1780
原创 numpy中实现循环位移 numpy.roll
numpy.roll官方链接对于向量:实现向左和向右的循环位移示例:import numpy as npmat= np.array([1,2,3,4,5,6])print(np.roll(mat,-1))print(np.roll(mat,1))正数是向index大的方向循环位移,负数是向index小的方向循环位移:[2 3 4 5 6 1][6 1 2 3 4 5]对于矩阵:不指定axis,则相当于先把矩阵flatten,然后进行循环位移,最后再reshape到原来的形状
2020-07-09 10:22:46 7897
原创 numpy计算矩阵元素相乘 numpy.prod
numpy.prod 实现元素相乘官方链接示例1. 把向量或矩阵中所有元素相乘import numpy as npmat= np.array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])print(np.prod(mat))结果:216示例2. 指定 axisAxis or axes along which a product is performed.示例:axis=0代表行,axis=1代表列,如果要计算mat= np.array([[1, 2, 3],
2020-07-09 09:58:34 5009
原创 numpy去除重复出现的元素 numpy.unique
函数官方链接numpy.unique(ar, return_index=False,return_counts=False, axis=None)ar: Input array. Unless axis is specified, this will be flattened if it is not already 1-D.return_index (optional): If True, also return the indices of ar (along the specified axi
2020-07-09 09:34:10 8543
原创 numpy.linalg.matrix_power 计算矩阵的次方
numpy.linalg.matrix_power(a, n)官方说明示例import numpy as npmat= np.array([[2, 0], [0, 2]])np.linalg.matrix_power(mat, 3)结果[[8 0] [0 8]]
2020-07-07 18:10:54 6371
原创 numpy.outer 计算向量外积
numpy 中的外积定义和数学中是不同的,其定义如下示例import numpy as npr=np.outer(np.arange(1,4), [5,2,1,4])结果array([[ 5, 2, 1, 4], [10, 4, 2, 8], [15, 6, 3, 12]])
2020-07-07 17:55:22 4172
原创 numpy中的乘法函数 np.dot, np.matmul, np.multiply
numpy.dot既可以计算两个向量的内积也可以计算两个矩阵的乘法情况1:If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).示例np.dot([2j, 3j], [2j, 3j])结果(-13+0j)情况2:If both a and b are 2-D arrays, it is matrix multiplication.示例c=np.arr
2020-07-07 17:43:39 978
Linear Algebra Pure & Applied
2018-12-03
Vector Calculus
2018-11-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人