in:name example 名字中有“example”
in:readme example readme中有“example”
in:description example 描述中有“example”
stars:>1000 star>1000
forks:>1000 fork>1000
pushed:>2019-09-01 2019年9月1日后有更新的
language:java 用Java编写的项目
Python内置数据结构
List(列表) Tuple(元组)
都是序列结构 a=[1,2,3] --list b=(4,5,6)--tuple 访问列表和元组中的元素的方式是一样的,如a[1],b[1]
list中的元素可以被修改,tuple中的不可以
list的复制方法: b=a[:] https://blog.csdn.net/qq_43230540/article/details/84788151
list,tuple函数 将某个对象转换成列表/元组 list('ab')得结果是['a', 'b'] tuple([1,2])的结果是(1,2)
list和tuple其他的一些常见函数
cmp(a,b) len(a) min(a) max(a) sum(a) sorted(a)--对列表中的元素进行升序排列
列表本身自带的其他实用方法
a.append(1) 将1添加到列表a的末尾
a.count(1) 统计列表a中元素1出现的次数
a.extend([1,2]) 将列表的类容追加到列表a的末尾中
a.index(1) 从列表中找到第一个1的索引位置
a.insert(2,1) 将1插入到列表a的索引为2的位置
a.pop(1) 移除列表a中索引为1的元素
Dictionary(字典)
它也相当于一个列表,但他的下标是让自己定义的key开始的
d={'today':20,'tomorrow':30} --创建一个字典
d['todat'y] d['tomorrow']
其他创建字典打方式,如通过dict函数转换,或者通过dict.fromkeys()来创建
dict([['today',20],['tomorrow',30]]) dict.fromkeys(['today','tomorrow'],20)
其他函数和方法与列表是一样的
set(集合)
元素不重复,而且是无序的,不支持索引。通过花括号或者set函数来创建一个集合
s={1,12,2} s=set([1,2,2,3])
集合的特殊运算
a=t|s t和s的并集
b=t&s t和s的交集
c=t-s 求差集
d=t^s 对称差集(项在t或s中,但不是同时出现在两者中)
函数式编程
b= map(lambda x: x+2,a)
b=list(b)
python数据挖掘相关扩展库
numpy 提供数组支持,以及相应的高效的处理函数
Scipy 提供矩阵支持,以及矩阵相关的数值计算模块
Matplotlib 强大的数据可视化工具,做图库
Pandas 强大。灵活的数据分析和探索工具
statsmodels 统计建模和计量经济学,包括描述统计,统计模型估计和推断
Scikit-learn 支持回归、分类、聚类等的强大机器学习库
keras 深度学习库,用于建立神经网络以及深度学习模型
gensim 用来做文本主题模型的库,文本挖掘可能用到
Numpy
import numpy as np
a=np.array([2,0,1,5])
print(a)
print(a[:3])
print(a.min())
a.sort()
b=np.array([[1,2,3],[4,5,6]])
print (b*b)
scipy
from scipy.optimize import fsolve
def f(x):
x1=x[0]
x2=x[1]
return [2*x1-x2**2-1,x1**2-x2-2]
result = fsolve(f,[1,1]) #[1,1]表示其结果的大致范围
print result
Matplotlib (Matplotlib画廊 https://matplotlib.org/gallery.html)
#-*- coding:utf-8
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,1000)
y=np.sin(x)+1
z=np.cos(x**2)+1
plt.figure(figsize=(8,4))
plt.plot(x,y,label = '$\sin x + 1$',color = 'red',linewidth = 2)
plt.plot(x,z,'b--',label = '$\cos x^2 + 1$')
plt.xlabel('Time(s)')
plt.ylabel('Vlot')
plt.title('A simple Example')
plt.ylim(0,2.2)
plt.legend()
plt.show()
pandas
#-*- coding:utf-8
import pandas as pd
s=pd.Series([1,2,3],index=['a','b','c'])
d = pd.DataFrame([[1,2,3],[4,5,6]],columns=['a','b','c'])
d2 = pd.DataFrame(s)
d.head()
d.describe()
pd.read_excel('data.xls')
pd.read_csv('data.csv',encoding='utf-8')
Scikit-learn
提供了完善的机器学习工具箱,包括数据预处理。分类,回归,聚类,预测和模型分析
#-*- coding:utf-8 from sklearn.linear_model import LinearRegression model = LinearRegression() print model
#-*- coding:utf-8 from sklearn import datasets from sklearn import svm iris = datasets.load_iris() print iris.data.shape clf = svm.LinearSVC() clf.fit(iris.data,iris.target) clf.predict([[5.0,3.6,1.3,0.25]]) clf.coef_
来源:CSDN
作者:木头不说话
链接:https://blog.csdn.net/urbeen/article/details/103578813