-
绘制图表,进行数据可视化
查看全部 -
常用的操作
查看全部 -
axis越大,深入的就越大,反之深入的越小
查看全部 -
numpy.array中只可以有一种数据类型
查看全部 -
List每次处理对象会判断数据类型,可存放多种类数据,但维护成本较高
查看全部 -
数据分析工具
查看全部 -
数据分析工具
查看全部 -
import numpy as np print('FFT:') print(np.fft.fft(np.array([1,1,1,1,1,1,1,1,1]))) print('Coef:') print(np.corrcoef([1,0,1],[0,2,1])) print('Poly:') print(np.poly1d([2,1,3]))
查看全部 -
# Set s1=pd.Series(list(range(10,18)),index=pd.date_range("20170301",periods=8)) df["F"]=s1 print(df) df.at[dates[0],"A"]=0 print(df) df.iat[1,1]=1 df.loc[:,"D"]=np.array([4]*len(df)) print(df) df2=df.copy() df2[df2>0]=-df2 print(df2)
查看全部 -
# Select切片 print(df["A"]) print(type(df["A"])) print(df[:3]) print(df["20170301":"20170304"]) print(df.loc[dates[0]]) print(df.loc["20170301":"20170304",["B","D"]]) print(df.at[dates[0],"C"]) print(df.at["20170301","C"]) print(df.iloc[1:3,2:4]) print(df.iloc[1,4]) print(df.iat[1,4]) print(df[df.B>0][df.A<0]) print(df[df>0.1]) print(df[df["E"].isin([1,2])])
查看全部 -
def main(): # Data Structure s=pd.Series([i*2 for i in range(1,11)]) print(type(s)) dates=pd.date_range("20170301",periods=8) df=pd.DataFrame(np.random.rand(8,5),index=dates,columns=list("ABCDE")) print(df) df = pd.DataFrame({"A": 1, "B": pd.Timestamp("20170301"), "C": pd.Series(1, index=list(range(4)), dtype="float32"), "D": np.array([3]*4, dtype="float32"), "E": pd.Categorical(["police", "student", "teacher", "doctor"])}) print(df)
查看全部 -
#导包 import numpy as np import matplotlib.pyplot as plt
#横轴设置 x = np.linspace(-np.pi,np.pi,512,endpoint=True)
#构建sin,cos函数 c, s = np.cos(x), np.sin(x)
#绘图 plt.figure() plt.plot(x,s) plt.plot(x,c)
plt.show()
查看全部 -
#2-Optimizer from scipy.optimize import minimize def rosen(x): #hansu return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1]**2.0)) x0=np.array([1.3,0.7,0.8,1.9,1.2]) res = minimize(rosen,x0,method="nelder-mead",options={"xtol":1e-8,"disp":True}) print("ROSE MINI:",res.x) def func(x): return -(2*x[0]*x[1]+2*x[0]-x[0]**2-2*x[1]**2) def func_deriv(x): dfdx0 = -(-2*x[0] + 2*x[1] + 2) dfdx1 = -(2*x[0] - 4*x[1]) return np.array([dfdx0,dfdx1]) cons = ({"type":"eq","fun":lambda x:np.array([x[0]**3.0-x[1]]),"jac":lambda x:np.array([3.0*(x[0]**2.0),-1.0])}, {"type":"ineq","fun":lambda x:np.array([x[1]-1]),"jac":lambda x:np.array([0.0,1.0])}) res=minimize(func,[-1.0,1.0],jac = func_deriv,constraints=cons,method='SLSQP',options = {'disp':True}) print("RESTRICT:",res) from scipy.optimize import root def fun(x): return x+2*np.cos(x) sol=root(fun,0.1) print ("ROOT:",sol.x,sol.fun)
有结果不对的可以自己比对一下,视频可能有点模糊和拖动
查看全部 -
给你们代码,写的啥咱也不知道,咱也不敢问 # __author__ = 'aaron' __date__ = '7/20/2019 11:19 AM' import numpy from keras.models import Sequential from keras.layers import Dense, Activation from keras.optimizers import SGD def main(): from sklearn.datasets import load_iris iris = load_iris() print(iris["target"]) from sklearn.preprocessing import LabelBinarizer print(LabelBinarizer().fit_transform(iris["target"])) from sklearn.model_selection import train_test_split train_data, test_data, train_target, test_target = train_test_split(iris.data, iris.target, test_size=0.2, random_state=1) labels_train = LabelBinarizer().fit_transform(train_target) labels_test = LabelBinarizer().fit_transform(test_target) model = Sequential( [ Dense(5, input_dim=4), Activation("relu"), Dense(3), Activation("sigmoid"), ] ) sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) model.compile(optimizer=sgd, loss="categorical_crossentropy") model.fit(train_data, labels_train, nb_epoch=200, batch_size=40) print(model.predict_classes(test_data)) if __name__ == "__main__": main()
查看全部 -
sklearn(scikit-learn)主要用于数据挖掘与机器学习
机器学习:由数据经过一个过程获得结果,本质是一个函数
查看全部
举报
0/150
提交
取消