七、逻辑回归项目实战---音乐分类器

一、项目需求

训练集数据为六类音乐([“classical”, “jazz”, “country”, “pop”, “rock”, “metal”]),格式为.wav,每类音乐都有100首
音乐分类器项目,主要运用到了傅里叶变换函数
很多东西越在高维空间处理起来就会变得越是简单
例如:书本上的文字是一维,漫画图像是二维,视频是三维(加上了时间维度),你喜欢看书还是看图画书还是看电影?
很显然,视频更容易让人们所接受

一条直线,你从正面看是一条直线,当你从侧面看时,则变成了一个点,这就是观察方向的不同导致的结果不同,但是有影响吗?这根直线还是这根直线,没有变,只不过观察方向角度变了而已。
音乐是有多个频率所构成的,傅里叶公式可以简单的理解为从另一个角度进行观察音乐频率
正常的我们是通过前方(时间维度)进行观察聆听音乐的,而傅里叶则是从右侧(频域)进行观察的
大家都知道,任何一个连续函数都可以用正弦函数叠加,故音乐则可以理解为多个正弦函数的叠加
当你从傅里叶的角度(右侧)进行观察时,就会发现实则是多个峰或者说是多条直线而已,问题瞬间变得简单了

在这里插入图片描述

二、数据集

这里的音乐使用的都是单声道的音乐(.wav),通过傅里叶变换将音频进行转化为频谱(.fft.npy)
若其他同学手边有数据也可以自己进行转换
可以参考该篇博文:.wav音乐文件转换为.fft.npy频谱格式文件
若不想自己动手转换,可以直接使用这个数据集:.fft.npy格式音乐经过傅里叶变换得到的频谱数据集

训练集:在这里插入图片描述
测试集:在这里插入图片描述

三、完整代码

需要修改的地方:
rad = "G:/PyCharm/workspace/machine_learning/trainset/"+g+"."+str(n).zfill(5)+ ".fft"+".npy"训练集路径
wavfile.read("G:/PyCharm/workspace/machine_learning/trainset/sample/heibao-wudizirong-remix.wav")测试集路径

# coding:utf-8import numpy as np
from sklearn import linear_model, datasets
import matplotlib.pyplot as plt
from scipy.stats import norm
from scipy.fftpack import fft
from scipy.io import wavfile"""
n = 40
# hstack使得十足拼接
# rvs是Random Variates随机变量的意思
# 在模拟X的时候使用了两个正态分布,分别制定各自的均值,方差,生成40个点
X = np.hstack((norm.rvs(loc=2, size=n, scale=2), norm.rvs(loc=8, size=n, scale=3)))
# zeros使得数据点生成40个0,ones使得数据点生成40个1
y = np.hstack((np.zeros(n),np.ones(n)))
# 创建一个 10 * 4 点(point)的图,并设置分辨率为 80
plt.figure(figsize=(10, 4),dpi=80)
# 设置横轴的上下限
plt.xlim((-5, 20))
# scatter散点图
plt.scatter(X, y, c=y)
plt.xlabel("feature value")
plt.ylabel("class")
plt.grid(True, linestyle='-', color='0.75')
plt.savefig("D:/workspace/scikit-learn/logistic_classify.png", bbox_inches="tight")
""""""
# linspace是在-5到15的区间内找10个数
xs=np.linspace(-5,15,10)#---linear regression----------
from sklearn.linear_model import LinearRegression
clf = LinearRegression()
# reshape重新把array变成了80行1列二维数组,符合机器学习多维线性回归格式
clf.fit(X.reshape(n * 2, 1), y)
def lin_model(clf, X):return clf.intercept_ + clf.coef_ * X#---logistic regression--------
from sklearn.linear_model import LogisticRegression
logclf = LogisticRegression()
# reshape重新把array变成了80行1列二维数组,符合机器学习多维线性回归格式
logclf.fit(X.reshape(n * 2, 1), y)
def lr_model(clf, X):return 1.0 / (1.0 + np.exp(-(clf.intercept_ + clf.coef_ * X)))#----plot---------------------------    
plt.figure(figsize=(10, 5))
# 创建一个一行两列子图的图像中第一个图
plt.subplot(1, 2, 1)
plt.scatter(X, y, c=y)
plt.plot(X, lin_model(clf, X),"o",color="orange")
plt.plot(xs, lin_model(clf, xs),"-",color="green")
plt.xlabel("feature value")
plt.ylabel("class")
plt.title("linear fit")
plt.grid(True, linestyle='-', color='0.75')
# 创建一个一行两列子图的图像中第二个图
plt.subplot(1, 2, 2)
plt.scatter(X, y, c=y)
plt.plot(X, lr_model(logclf, X).ravel(),"o",color="c")
plt.plot(xs, lr_model(logclf, xs).ravel(),"-",color="green")
plt.xlabel("feature value")
plt.ylabel("class")
plt.title("logistic fit")
plt.grid(True, linestyle='-', color='0.75')plt.tight_layout(pad=0.4, w_pad=0, h_pad=1.0)     
plt.savefig("D:/workspace/scikit-learn/logistic_classify2.png", bbox_inches="tight")
""""""
使用logistic regression处理音乐数据,音乐数据训练样本的获得和使用快速傅里叶变换(FFT)预处理的方法需要事先准备好
1. 把训练集扩大到每类100个首歌而不是之前的10首歌,类别仍然是六类:jazz,classical,country, pop, rock, metal
2. 同时使用logistic回归和KNN作为分类器
3. 引入一些评价的标准来比较Logistic和KNN在测试集上的表现 
"""# 准备音乐数据
# def create_fft(g, n):
#     rad = "d:/genres/"+g+"/converted/"+g+"."+str(n).zfill(5)+".au.wav"#音乐文件的路径,这里的音乐文件都是.wav格式
#     sample_rate, X = wavfile.read(rad)#sample_rate采样率;X为音乐文件本身
#     fft_features = abs(fft(X)[:1000])#对音乐文件本身进行fft快速傅里叶变化,取前1000赫兹数据,进行取绝对值,得到fft_features傅里叶变换的特征
#     sad = "d:/trainset/"+g+"."+str(n).zfill(5) + ".fft"#将特征存储到这个路径下
#     np.save(sad, fft_features)#存储特征,存储的是.fft格式,但是最终生成的是.fft.npy格式,这是numpy自动生成的
#
# # -------create fft--------------
#
#
# genre_list = ["classical", "jazz", "country", "pop", "rock", "metal"]
# for g in genre_list:
#     for n in range(100):
#         create_fft(g, n)# 加载训练集数据,分割训练集以及测试集,进行分类器的训练
# 构造训练集!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# -------read fft--------------
genre_list = ["classical", "jazz", "country", "pop", "rock", "metal"]
X = []#矩阵
Y = []#标签
for g in genre_list:for n in range(100):#六类音乐,每类100首rad = "G:/PyCharm/workspace/machine_learning/trainset/"+g+"."+str(n).zfill(5)+ ".fft"+".npy"fft_features = np.load(rad)X.append(fft_features)Y.append(genre_list.index(g))X = np.array(X)#把列表转化为array数组类型
Y = np.array(Y)
"""
# 首先我们要将原始数据分为训练集和测试集,这里是随机抽样80%做测试集,剩下20%做训练集 
import random
randomIndex=random.sample(range(len(Y)),int(len(Y)*8/10))
trainX=[];trainY=[];testX=[];testY=[]
for i in range(len(Y)):if i in randomIndex:trainX.append(X[i])trainY.append(Y[i])else:testX.append(X[i])testY.append(Y[i])
"""# 接下来,我们使用sklearn,来构造和训练我们的两种分类器 
# ------train logistic classifier--------------
from sklearn.linear_model import LogisticRegression
#multi_class='ovr'表示使用逻辑回归的多分类,若为multinomial则使用softmax进行多分类;solver='sag'使用随机梯度下降法,若不传则默认使用liblinear;max_iter=10000最大迭代次数
model = LogisticRegression()#创建逻辑回归对象
model.fit(X, Y)#传入数据进行训练模型,这里的model是在内存里面
# predictYlogistic=map(lambda x:logclf.predict(x)[0],testX)# 可以采用Python内建的持久性模型 pickle 来保存scikit的模型,下面的代码是将model存到硬盘里面
# import pickle
# s = pickle.dumps(model)
# clf2 = pickle.loads(s)
# clf2.predict(X[0])"""
#----train knn classifier-----------------------
from sklearn.neighbors import NearestNeighbors
neigh = NearestNeighbors(n_neighbors=1)
neigh.fit(trainX) 
predictYknn=map(lambda x:trainY[neigh.kneighbors(x,return_distance=False)[0][0]],testX)# 将predictYlogistic以及predictYknn与testY对比,我们就可以知道两者的判定正确率 
a = np.array(predictYlogistic)-np.array(testY)
print a, np.count_nonzero(a), len(a)
accuracyLogistic = 1-np.count_nonzero(a)/(len(a)*1.0)
b = np.array(predictYknn)-np.array(testY)
print b, np.count_nonzero(b), len(b)
accuracyKNN = 1-np.count_nonzero(b)/(len(b)*1.0)print "%f" % (accuracyLogistic)
print "%f" % (accuracyKNN)
"""print('Starting read wavfile...')
# prepare test data-------------------
# sample_rate, test = wavfile.read("d:/trainset/sample/outfile.wav")
sample_rate, test = wavfile.read("G:/PyCharm/workspace/machine_learning/trainset/sample/heibao-wudizirong-remix.wav")
# sample_rate, test = wavfile.read("d:/genres/metal/converted/metal.00080.au.wav")
testdata_fft_features = abs(fft(test))[:1000]
print(sample_rate, testdata_fft_features, len(testdata_fft_features))
type_index = model.predict([testdata_fft_features])[0]
print(type_index)
print(genre_list[type_index])"""
from sklearn.metrics import confusion_matrix
cmlogistic = confusion_matrix(testY, predictYlogistic)
cmknn = confusion_matrix(testY, predictYknn)def plotCM(cm,title,colorbarOn,givenAX):ncm=cm/cm.max()plt.matshow(ncm, fignum=False, cmap='Blues', vmin=0, vmax=2.0)if givenAX=="":ax=plt.axes()else:ax = givenAXax.set_xticks(range(len(genre_list)))ax.set_xticklabels(genre_list)ax.xaxis.set_ticks_position("bottom")ax.set_yticks(range(len(genre_list)))ax.set_yticklabels(genre_list)plt.title(title,size=12)if colorbarOn=="on":plt.colorbar()plt.xlabel('Predicted class')plt.ylabel('True class')for i in range(cm.shape[0]):for j in range(cm.shape[1]):plt.text(i,j,cm[i,j],size=15)plt.figure(figsize=(10, 5))  
fig1=plt.subplot(1, 2, 1)          
plotCM(cmlogistic,"confusion matrix: FFT based logistic classifier","off",fig1.axes)   
fig2=plt.subplot(1, 2, 2)     
plotCM(cmknn,"confusion matrix: FFT based KNN classifier","off",fig2.axes) 
plt.tight_layout(pad=0.4, w_pad=0, h_pad=1.0)     plt.savefig("d:/confusion_matrix.png", bbox_inches="tight")
"""

输出结果如下:
其中44100为采样率

"""
44100 [2.62963968e+08 4.46200714e+06 5.15395385e+06 4.43376757e+063.74566845e+06 4.70186729e+06 5.33935836e+06 4.61999477e+064.15225785e+06 3.30594588e+06 4.31103082e+06 5.05558675e+065.32297672e+06 4.85506026e+06 5.19126496e+06 4.14585787e+063.62846270e+06 4.75147337e+06 3.91082781e+06 4.62259775e+064.48238357e+06 3.23787122e+06 2.22014030e+06 3.78805307e+062.14269906e+06 3.13617469e+06 3.12430918e+06 4.46836068e+062.74392608e+06 3.78402588e+06 1.87577534e+06 3.49203803e+062.33558316e+06 3.81553507e+06 2.63688151e+06 3.02667708e+062.04674785e+06 2.22072034e+06 1.91995398e+06 1.98927890e+061.68224240e+06 1.35139077e+06 2.30549645e+06 6.03046897e+051.31438823e+06 1.95087823e+06 8.49833030e+05 1.19171948e+061.23251661e+06 1.89390106e+06 5.80352061e+05 1.50388290e+061.25938435e+06 1.02978969e+06 2.36614610e+05 3.01560843e+051.27662352e+06 1.49221129e+06 5.17213388e+05 8.00948818e+057.65561994e+05 3.62419277e+05 1.50979436e+06 3.85068213e+056.41942889e+05 3.61144502e+05 6.85268116e+05 1.00144583e+066.46261080e+05 1.40845476e+06 6.62866166e+05 6.91106024e+051.23208363e+06 1.36027432e+06 3.62846259e+05 5.72218147e+057.75993152e+05 9.14515445e+05 1.18571572e+06 9.02475526e+054.98999881e+05 1.74914232e+06 3.94735421e+05 1.22194083e+069.44511346e+05 5.64374132e+05 1.76153158e+06 1.92086536e+061.23147054e+06 3.62420572e+05 5.19808732e+05 1.34346298e+067.21219553e+05 8.88950439e+05 1.75325706e+06 2.29355413e+061.08391025e+06 9.30282476e+05 1.10235851e+06 3.67805257e+055.77443645e+05 5.94086277e+05 1.19729395e+06 5.34697818e+053.88725959e+05 7.87438862e+05 1.77019327e+06 1.66520041e+062.07569988e+06 7.36173308e+05 6.56954650e+05 1.61943917e+068.67054883e+05 1.26014326e+06 1.61921808e+06 1.54533344e+067.07774874e+05 1.62786750e+05 2.97020086e+05 1.13388210e+065.63030498e+05 9.58680710e+05 1.16377079e+06 9.77142004e+058.99557347e+05 4.93741261e+05 1.99306708e+05 1.20241539e+067.47989489e+04 1.67983186e+06 6.79762302e+05 8.65937699e+055.50519377e+05 1.72907596e+06 2.93786505e+05 7.75062173e+059.68810309e+05 1.43654854e+06 8.08623022e+05 2.59287374e+054.57334088e+05 9.85646332e+05 1.38921416e+06 1.17264490e+067.41666163e+05 2.05204503e+06 8.05602385e+05 7.40724129e+059.05423650e+05 4.47600257e+05 9.70026356e+05 1.19707145e+068.66600040e+05 9.09215043e+05 6.38983412e+05 6.24539950e+052.30489745e+05 9.49711853e+05 1.62124067e+06 1.33000213e+067.49378742e+05 4.94629349e+05 2.53593993e+05 8.26687520e+057.83442269e+05 1.10375179e+06 7.42007345e+05 5.10356938e+054.41047858e+05 8.81833105e+05 2.42540213e+06 3.30401795e+058.80062590e+05 6.49905701e+05 3.47149964e+05 1.05602066e+061.18980862e+06 1.96891139e+05 1.14120246e+06 8.02951614e+056.00111367e+05 6.69160363e+05 1.89491761e+05 5.95679660e+051.38204166e+06 1.21312932e+06 1.00683336e+06 1.71907045e+061.47929539e+06 1.05542669e+06 2.36641708e+06 9.33510819e+057.48075310e+05 1.77764553e+06 4.21246379e+05 7.90733672e+051.39589725e+06 7.09737413e+05 7.30502934e+05 1.25361964e+066.19123157e+05 6.88892351e+05 6.26028154e+05 8.54795006e+057.06965041e+05 1.21987749e+06 7.52060331e+05 4.71848433e+052.36098779e+05 8.47966863e+05 4.01129984e+05 1.27542408e+067.14220047e+05 5.18027090e+05 5.58925060e+05 2.79974210e+057.62875042e+05 1.84079472e+06 1.42550029e+06 1.14811203e+061.30128360e+06 1.24869130e+06 3.52352404e+05 4.21421728e+051.18173485e+06 5.10136084e+05 3.75560127e+05 4.79102195e+051.10333151e+06 2.05555702e+06 7.23702249e+05 3.61178799e+057.04851219e+05 1.44012108e+06 9.26402727e+05 2.02821056e+054.45325652e+05 7.90522874e+05 8.26436685e+05 1.17563229e+068.43867568e+05 4.01048078e+05 9.26085978e+05 6.44995771e+053.53685137e+05 8.34366832e+05 1.23386512e+06 7.02375781e+054.58931591e+05 8.43526489e+05 1.10676720e+06 7.68521715e+051.62269410e+06 1.58265455e+06 1.03200640e+06 4.64795983e+059.90089422e+05 5.24337673e+05 3.66658840e+05 6.55805698e+055.70752207e+05 2.76033608e+05 3.23297345e+05 1.33078141e+066.16117851e+05 3.63376716e+05 1.22034305e+06 1.87348103e+068.18691165e+05 2.43489854e+05 1.06339848e+06 1.38161299e+057.08259014e+05 1.32420185e+06 3.73634708e+05 4.74188119e+058.56522386e+05 1.18141641e+06 1.52211708e+06 4.07008939e+058.35340660e+05 6.40881238e+05 1.09076459e+06 1.21963072e+067.56369038e+05 1.14117511e+06 1.39389976e+06 5.10490203e+057.00735069e+05 2.37107675e+05 8.94992427e+05 1.53159359e+065.24539638e+05 7.88949376e+04 8.78275390e+05 1.68422430e+068.09255981e+05 4.57182807e+05 1.17241872e+06 2.09394245e+059.77952748e+04 8.97739813e+05 1.08742141e+06 9.69384074e+059.81838586e+05 5.07041429e+05 1.15578207e+06 3.49371827e+056.20229249e+05 3.60935229e+05 1.03026311e+06 3.46570750e+051.08685762e+06 1.66151632e+06 9.47736790e+05 4.26436467e+051.13526476e+06 5.84625497e+05 1.51928634e+06 9.70060181e+051.62523526e+06 6.11541462e+05 4.29298422e+05 4.61724329e+055.66555319e+05 1.29364175e+06 1.01953071e+06 1.94211951e+062.72120805e+05 1.14321213e+06 5.67287402e+05 1.94838376e+068.23364882e+05 1.62185476e+06 1.12559716e+06 4.55413724e+053.94762550e+05 9.96679018e+05 8.64137068e+05 9.73976199e+055.00463157e+05 5.05326117e+05 7.18463504e+05 3.00032365e+051.29926845e+06 9.28358383e+05 4.51525493e+05 4.65797885e+056.70108099e+05 1.00455574e+06 1.22544843e+05 7.84409036e+052.52051242e+06 1.13223858e+06 8.64798855e+05 7.61259423e+059.48682621e+05 5.33148975e+05 3.99035609e+05 1.47581282e+062.39172803e+06 6.02291705e+05 9.12335511e+05 1.10007913e+063.88451743e+05 3.18750364e+05 1.12384444e+06 5.00540271e+051.60319399e+05 7.27587480e+05 6.17185073e+05 1.35890728e+061.56238108e+06 9.65851067e+05 1.07019478e+06 1.63850864e+066.47843129e+05 2.65218848e+05 1.17738892e+06 1.19611403e+062.75522201e+05 1.34222981e+06 2.75771621e+05 1.98303864e+057.81263330e+05 3.26290246e+05 1.74968242e+06 7.61635689e+057.82203438e+05 4.37269114e+05 4.94924240e+05 4.04790850e+056.06235962e+05 1.14968590e+06 9.01138935e+05 3.87643407e+051.25101978e+06 1.25419381e+06 1.35912365e+06 1.10417253e+062.56006176e+05 1.68242848e+05 6.92147285e+05 5.62794655e+054.93718498e+05 5.32081292e+05 1.27889173e+06 1.07027869e+061.10223160e+06 1.21005716e+06 8.85081307e+05 9.54022330e+051.09599439e+06 1.00597502e+06 1.32263178e+06 9.81496867e+051.34961613e+06 9.75037511e+05 6.85154265e+05 2.74366226e+051.50605422e+06 1.24630822e+06 1.16136322e+06 5.19311262e+051.63678378e+06 1.00376123e+06 1.62954572e+06 5.53658511e+051.47319245e+06 1.16738338e+06 8.38245719e+05 1.09516870e+064.70652165e+05 4.84287731e+05 1.07054018e+06 1.51727656e+065.68360369e+05 1.13788710e+06 1.11524639e+06 5.50195476e+052.54789570e+06 6.70319933e+05 5.94055329e+05 1.40070839e+061.12209139e+06 6.66737961e+05 1.12603699e+06 7.59905686e+051.28043310e+06 1.73220091e+06 1.62539809e+06 1.43598424e+062.44608474e+05 9.76455920e+05 1.65895428e+06 4.74288051e+051.10317841e+06 7.60719720e+05 1.10148269e+06 1.22954150e+063.90806811e+05 7.68896458e+05 1.12202274e+06 1.20163265e+061.22283285e+05 3.95298481e+05 1.44100987e+06 1.13628142e+065.47027791e+05 1.44282330e+06 1.51116579e+06 2.94764054e+051.98303470e+06 6.60890367e+05 1.74400473e+05 3.43742919e+051.32702565e+06 9.70334589e+05 1.44755428e+06 1.19220440e+051.05416292e+06 7.65688495e+05 9.26620871e+05 1.05452545e+063.45971006e+05 1.38729419e+06 9.25768093e+05 5.78718349e+054.97405435e+05 6.38795336e+05 4.69704768e+05 1.08195127e+061.16430563e+06 1.12494833e+06 4.95913198e+05 1.77315771e+061.03099010e+06 4.83720528e+05 3.21831897e+06 2.89220027e+056.79691208e+05 5.54079998e+05 4.93231507e+05 6.97124088e+057.70214750e+05 3.41919222e+05 9.71853585e+05 3.02895802e+051.60873623e+06 1.19824400e+06 7.22427028e+05 7.13426231e+051.02447104e+05 7.53407279e+05 1.41847030e+06 1.17125187e+054.90554481e+05 2.22813151e+06 1.81816145e+06 2.00108016e+069.88524222e+05 6.66761214e+05 1.41700184e+06 1.73091718e+051.27497266e+06 8.84137125e+05 6.78333314e+05 1.25807940e+066.10437456e+05 6.18501388e+05 8.10004665e+05 1.52737362e+069.48293718e+05 8.16537529e+05 6.56080065e+05 2.61681911e+053.09335595e+05 1.61035190e+06 6.71864447e+05 7.03677274e+051.44948054e+06 1.33119383e+06 2.64438246e+06 8.99604614e+055.90471091e+05 1.99137527e+05 1.03576680e+06 2.36999135e+061.09501221e+06 2.70689106e+05 3.76008484e+05 2.13801101e+061.72034321e+06 1.03344188e+06 8.55742897e+05 5.82042271e+051.85276639e+06 8.23264426e+05 1.22193431e+06 6.48059124e+051.72918335e+06 1.45109304e+06 8.33139569e+05 1.05104656e+061.01674950e+06 1.49288532e+05 1.20247840e+06 4.39570274e+051.79832395e+06 9.98752681e+05 9.54955398e+05 4.28114058e+051.58621395e+05 9.38163338e+05 1.11554619e+06 7.80633423e+055.13067795e+05 5.03253676e+05 2.36904360e+05 4.99709843e+056.21949993e+05 2.25802159e+06 9.39527797e+05 1.23773463e+061.15677145e+06 6.43416576e+05 1.47631874e+06 5.80764306e+051.40761056e+05 6.16162073e+05 1.42090316e+06 2.47591155e+068.58620247e+05 7.11971890e+05 1.09890188e+06 2.79107673e+061.45876445e+06 1.12196751e+06 1.38826076e+06 8.28682888e+055.07527103e+05 1.05698761e+06 9.96337472e+05 9.74189758e+051.40487992e+06 3.70140740e+05 1.19378682e+06 2.54631763e+054.53796268e+05 1.44369582e+06 1.37487873e+06 1.33689697e+061.19280267e+06 1.13395796e+06 1.27007970e+06 2.57351451e+058.82385435e+05 1.82934432e+06 1.00658762e+06 1.65859345e+065.92281619e+05 8.42457890e+05 9.79791964e+05 7.08269013e+051.23456666e+06 1.39433050e+06 8.43614328e+05 1.04659730e+061.71332770e+05 1.27208163e+06 4.12933744e+05 1.19368294e+061.01983378e+06 1.14148324e+06 1.82837589e+06 2.17376752e+061.15679073e+06 9.52035769e+05 2.46305964e+06 1.64439928e+061.24728170e+06 1.68959811e+06 7.22742065e+05 1.33941200e+069.36138845e+05 1.08803636e+06 4.56648829e+05 1.46120228e+067.85178694e+05 1.03316831e+06 1.02764622e+06 1.15405102e+068.27220784e+05 8.50158280e+05 9.65043821e+05 1.23654857e+064.99115388e+05 1.94305570e+06 1.21088371e+06 1.30802627e+067.70917391e+05 1.17759305e+06 1.30818276e+06 1.62957354e+063.23667488e+06 8.67097278e+05 8.58457212e+05 2.72089170e+069.08574562e+05 2.04681724e+06 1.58712952e+06 8.40103134e+051.14604332e+06 1.16037077e+06 1.00681060e+06 7.75054827e+051.23125645e+06 1.53232299e+06 1.27156373e+06 9.17246636e+063.29590600e+06 2.05453011e+06 2.02744927e+06 2.04618268e+062.32258974e+06 2.15913282e+06 1.65675095e+06 7.94574368e+054.14347532e+05 1.34996904e+06 1.28450160e+06 1.70713907e+062.53389774e+06 7.53067108e+05 2.92109765e+06 1.35891954e+064.54258355e+05 9.69501203e+05 8.60747492e+05 1.25164114e+069.52457948e+05 1.41437482e+06 1.92057969e+06 1.93124142e+055.84525516e+05 1.02859923e+06 1.47588480e+06 2.11134185e+061.65883558e+06 1.83035726e+06 1.40076106e+06 1.68206907e+061.18123607e+06 2.46259139e+06 1.89125390e+06 5.48837412e+057.18930209e+05 1.57502106e+06 3.66499377e+05 2.68878538e+061.31642030e+06 3.74088262e+06 1.18170765e+06 1.32040737e+061.31853822e+06 2.69033216e+06 1.84839762e+06 4.25735850e+055.51234171e+05 1.09019441e+06 1.62550524e+06 6.57396223e+051.27844897e+06 5.16691913e+05 2.73157674e+06 6.23682863e+051.10991453e+06 2.27380293e+06 2.57710006e+06 2.31701722e+061.56106910e+06 2.77372354e+05 1.58545730e+06 7.49283564e+057.03092728e+05 8.22247656e+05 3.55201948e+05 2.82427331e+062.37488521e+06 1.02221032e+06 3.34250229e+05 1.76831695e+061.73407355e+06 1.01221178e+06 1.30767170e+06 2.06582328e+061.30939774e+06 9.02271429e+05 1.55282000e+06 2.66791517e+061.46070663e+06 2.36855447e+06 2.47778462e+06 1.65150285e+062.86038028e+06 2.11331093e+06 1.03168160e+06 4.20297050e+061.37391280e+06 1.75552249e+06 1.42466104e+06 2.02248038e+061.21328124e+06 1.47561521e+06 1.13083699e+06 1.99081397e+063.09330360e+06 2.30924547e+06 1.83329091e+06 8.09051867e+051.70263848e+06 1.10090664e+06 1.85819900e+06 2.38946190e+051.95820740e+06 1.52776711e+06 1.43756932e+06 1.85151140e+069.35115322e+05 1.53739367e+06 2.30774990e+06 1.12081960e+062.65094331e+06 2.91169399e+06 4.91570496e+05 1.37162558e+063.83845234e+06 2.79701207e+05 2.23682020e+06 2.85867756e+061.49590828e+06 2.75865210e+06 1.71068052e+06 3.17879941e+062.21070867e+06 1.25671294e+06 2.07236085e+06 8.59636914e+053.33143651e+06 2.82114412e+06 3.62873617e+06 2.30389801e+066.23386608e+05 1.14024549e+06 1.42623320e+06 2.94519898e+062.08760517e+06 2.12760802e+06 1.07203047e+06 2.72068954e+062.01460828e+06 1.46703960e+06 1.05998485e+06 1.90473064e+062.03451257e+06 8.09722707e+05 2.13045612e+06 1.62661941e+069.49332627e+05 1.84730206e+06 1.36601889e+06 2.20125544e+068.21619750e+05 2.45818166e+06 2.13201457e+06 1.65595139e+064.79679482e+06 3.51013300e+06 2.98771178e+06 1.26291467e+063.49019552e+06 2.52078746e+06 1.27835388e+06 1.91240226e+063.69107173e+06 2.30183493e+06 8.17798057e+05 7.77947217e+052.19533562e+06 6.88382070e+06 2.53170163e+06 1.50392284e+064.01454559e+06 1.66508164e+06 3.03868030e+06 4.26670365e+061.66979802e+06 5.97165928e+06 2.55894914e+06 2.30273943e+062.10731316e+06 3.13332555e+06 2.70468729e+06 1.16442579e+061.46038845e+06 2.46001200e+06 3.02604152e+06 2.30646781e+061.71304428e+06 2.54375702e+06 1.38768714e+06 1.06188052e+061.72130167e+06 1.38045148e+06 1.85959525e+06 1.72060287e+061.86311648e+06 1.97971883e+06 1.58367654e+06 1.57559405e+061.86531133e+06 1.26524498e+06 1.34270543e+06 1.87778217e+061.76837457e+06 2.91085940e+06 1.13059030e+06 2.17543391e+068.25995368e+05 1.21550029e+06 1.72464645e+06 5.32765444e+052.97267051e+06 2.80904696e+06 2.27706903e+06 2.45531515e+063.14674682e+06 2.77241682e+05 3.59494379e+06 4.70111975e+053.31343742e+05 1.05652740e+06 1.94506705e+06 2.54990736e+067.65698308e+05 2.91493658e+06 8.01963983e+05 1.72021815e+066.02022592e+05 1.04332293e+06 9.62060816e+05 3.36197104e+062.68663806e+06 1.13708602e+06 3.96654483e+06 2.81562282e+062.42820317e+05 8.35760918e+04 1.64158835e+06 3.30249874e+061.37157771e+06 2.12389794e+06 3.23269416e+06 8.45912977e+051.35140210e+06 5.35804806e+05 1.36545428e+06 1.30407902e+061.29210339e+06 1.52951059e+06 1.17959961e+06 1.33435273e+061.71725020e+06 4.32548267e+06 2.42964008e+06 1.09615191e+062.38000150e+06 2.08306149e+05 1.61729929e+06 1.69213408e+062.17676494e+06 1.32419195e+06 2.35247695e+06 1.22927245e+062.45801927e+06 2.54130142e+06 1.10460223e+06 2.83483470e+062.25941505e+06 1.26583137e+06 2.15877447e+06 5.32025563e+058.10206574e+05 1.21008066e+06 2.56992726e+05 7.78186822e+051.57350690e+06 2.42269187e+06 3.34769234e+06 7.14373786e+051.73231035e+06 1.85696403e+06 2.42095050e+06 3.28998084e+061.28149279e+06 2.59963754e+06 4.55552548e+05 2.40412906e+061.67189223e+06 1.89699896e+06 1.33405479e+06 3.33878299e+064.37661776e+05 2.09006809e+06 2.44695877e+06 1.65368993e+062.88437983e+06 5.02961252e+06 1.84002601e+06 2.26181835e+064.38511790e+05 6.49497481e+05 9.39676571e+05 1.74998019e+061.61242901e+06 2.62123426e+06 7.66639670e+05 1.56210836e+062.86459639e+06 5.66697186e+05 3.54691073e+06 2.69370989e+053.82912388e+06 3.37837033e+06 1.98066407e+06 3.18225345e+069.74247473e+05 1.75306814e+06 1.55180915e+06 2.91568266e+06] 1000
4
rock
"""

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/377775.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

仿京东左侧栏目导航

效果图&#xff1a; 查看效果&#xff1a;http://www.miiceic.org.cn/eg/eg10/abzc.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns"http:…

python创建矩阵_在Python中创建矩阵的Python程序

python创建矩阵There is no specific data type in Python to create a matrix, we can use list of list to create a matrix. Python中没有特定的数据类型来创建矩阵&#xff0c;我们可以使用list列表来创建矩阵 。 Consider the below example, 考虑下面的示例&#xff0c;…

函数定义

//表达式定义函数 var squarefunction(x){return x*x;}//只有变量声明(var square;)提前了&#xff0c;初始化代码仍然在原处。 //函数声明语句 function f(x){return x*x;}//整个函数体被显式的“提前”到了脚本或函数的顶部。 //因此他们在整个脚本和函数内都是可见的。此种方…

leetcode 491. 递增子序列 思考分析

题目 给定一个整型数组, 你的任务是找到所有该数组的递增子序列&#xff0c;递增子序列的长度至少是2。 说明: 给定数组的长度不会超过15。 数组中的整数范围是 [-100,100]。 给定数组中可能包含重复数字&#xff0c;相等的数字应该被视为递增的一种情况。 思考 这一题和le…

八、神经网络

一、为啥要有神经网络&#xff1f; 在前面的几篇博客中&#xff0c;很容易知道我们处理的都是线性的数据&#xff0c;例如&#xff1a;线性回归和逻辑回归&#xff0c;都是线性的算法 但是&#xff0c;实际上日常生活中所遇到的数据或者问题绝大多数还是非线性的 一般面对非线…

scale up 和 scale out

目前在调研sheepdog的时候&#xff0c;看到scale up和scale out的术语&#xff0c;理解了一下&#xff1a; 这两个词汇均是存储系统方面的概念 scale up: 纵向扩展 购买更大的存储&#xff0c;迁移原有数据到大的存储中 &#xff08;添加新一个新的机器&#xff09; scale out…

icse ccf_ICSE的完整形式是什么?

icse ccfICSE&#xff1a;印度中学教育证书 (ICSE: Indian Certificate of Secondary Education) ICSE is an abbreviation of the Indian Certificate of Secondary Education (ICSE). It is an educational board of the school in India for class 10th which is private an…

Delphi XE2 之 FireMonkey 入门(18) - TLang(多语言切换的实现)

一个小小的 TLang 类, 实现多语言切换, 挺好的. 它的工作思路是:1、首先通过 AddLang(语言代码) 添加语言类别, 如: AddLang(en)、AddLang(cn).2、每个语言代码对应一个 TStrings 列表, 获取方式如: LangStr[en]、LangStr[cn].3、可以手动填充这些数据、可以通过 LoadFromFile(…

leetcode 46. 全排列 思考分析

目录1、题目2、思考3、优化1、题目 给定一个 没有重复 数字的序列&#xff0c;返回其所有可能的全排列。 2、思考 老规矩&#xff0c;先画出给出的例子的解空间树&#xff1a; 观察我们可以发现&#xff1a; 1、深度向下一层深入时&#xff0c;出现过的元素不能再出现&…

Arduino UNO R3开发板+MQ-2烟雾浓度传感器+火焰传感器+舵机+无源蜂鸣器+风扇+步进电机+WIFI模块+RGB三色LED灯+SIM900A所构成的室内安全报警模块

该系统模块主要由Arduino UNO R3开发板MQ-2烟雾浓度传感器火焰传感器舵机无源蜂鸣器风扇步进电机WIFI模块RGB三色LED灯SIM900A所组成&#xff0c;MQ-2烟雾浓度传感器达到不同的阈值的时候&#xff0c;LED灯会通过不同的颜色来进行警示。烟雾浓度增大&#xff0c;LED灯依次显示绿…

highcharts中series带参数的赋值问题

需要得到的代码如下&#xff1a; series: [{name: 棒号1,data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]}, {name: 棒号2,data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]}, {name: 棒号3,data: [-0.9, 0.6, 3.5, …

可编程ic卡 通用吗_8255可编程IC

可编程ic卡 通用吗Introduction 介绍 An 8255 programmable integrated circuit (IC) is an IC used for interfacing the microprocessor with the peripheral devices. It is a 40 pin IC which was introduced by INTEL to use with its 8085 and 8086 microprocessors. 82…

POJ 1944 Fiber Communications (枚举 + 并查集 OR 线段树)

题意 在一个有N&#xff08;1 ≤ N ≤ 1,000&#xff09;个点环形图上有P&#xff08;1 ≤ P ≤ 10,000&#xff09;对点需要连接。连接只能连接环上相邻的点。问至少需要连接几条边。 思路 突破点在于最后的结果一定不是一个环&#xff01;所以我们枚举断边&#xff0c;则对于…

九、逻辑回归多分类和softmax多分类

一、逻辑回归多分类 假设激活函数使用的是sigmoid函数 逻辑回归多分类其实是多个二分类而已&#xff0c;若求三分类问题需要对训练的数据样本进行适当的修改调整即可&#xff0c;如何修改样本数据可以参考逻辑回归二分类和多分类本质区别&#xff0c;内容都一样&#xff0c…

【C++grammar】继承与构造test1代码附录

目录1、main.cpp2、circle.cpp3、circle.h4、rectangle.cpp5、rectangle.h6、Shape.h1、main.cpp #include <iostream> #include <string> #include "Shape.h" #include "circle.h" #include "rectangle.h"//创建Shape/Circle/Rect…

hdu 4747 mex 线段树+思维

http://acm.hdu.edu.cn/showproblem.php?pid4747 题意&#xff1a; 我们定义mex(l,r)表示一个序列a[l]....a[r]中没有出现过得最小的非负整数&#xff0c; 然后我们给出一个长度为n的序列&#xff0c;求他所有的连续的子序列的mex(l,r)的和。 思路&#xff1a; 首先因为n的最大…

十、评估指标

我看过很多课程&#xff0c;不过内容都大差不差&#xff0c;也可以参考这篇模型评估方法 一、K折交叉验证 一般情况&#xff0c;我们得到一份数据集&#xff0c;会分为两类&#xff0c;一类是trainset训练集&#xff0c;另一类十testset测试集。通俗一点也就是训练集相当于平…

leetcode 47. 全排列 II 思考分析

题目 给定一个可包含重复数字的序列 nums &#xff0c;按任意顺序 返回所有不重复的全排列。 思考分析以及代码 这一题和前面的做过的两个题目有所关联&#xff1a; leetcode 46. 全排列 思考分析 再加上leetcode 491. 递增子序列 思考分析类似的去重操作。 先画出解空间树…

python添加数组元素_在Python中向数组添加元素

python添加数组元素An array can be declared by using "array" module in Python. 可以通过在Python中使用“数组”模块来声明数组 。 Syntax to import "array" module: 导入“数组”模块的语法&#xff1a; import array as array_alias_nameHere, im…

hdu 4472 Count(递推即dp)

题目链接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid4472 代码&#xff1a; #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> …