- 博客(96)
- 收藏
- 关注
原创 应用Keras创建Resnet-NeuralNetwork
import numpy as npfrom keras import layersfrom keras.layers import Input, Add, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D, AveragePooling2D, MaxPooling2D, GlobalMaxPooling2Dfrom keras.models import Model, load_modelfrom keras
2020-11-28 14:05:34
296
原创 Keras_tutorial-NeuralNetwork
import numpy as npfrom keras import layersfrom keras.layers import Input, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2Dfrom keras.layers import AveragePooling2D, MaxPooling2D, Dropout, GlobalMaxPooling2D, GlobalAveragePooling2Df
2020-11-27 23:07:08
237
1
原创 卷积正向传播和反向传播2_tensorflow-NeuralNetwork
import mathimport numpy as npimport h5pyimport matplotlib.pyplot as pltimport scipyfrom PIL import Imagefrom scipy import ndimageimport tensorflow as tffrom tensorflow.python.framework import opsfrom cnn_utils import *%matplotlib inlinenp.rando
2020-11-22 21:50:23
250
原创 卷积正向传播和反向传播1-NeuralNetwork
import numpy as npimport h5pyimport matplotlib.pyplot as plt%matplotlib inlineplt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plotsplt.rcParams['image.interpolation'] = 'nearest'plt.rcParams['image.cmap'] = 'gray'%load_ext autorelo
2020-11-22 16:06:32
275
原创 深层神经网络调参5_Tensorflow基础-NeuralNetwork
import mathimport numpy as npimport h5pyimport matplotlib.pyplot as pltimport tensorflow as tffrom tensorflow.python.framework import opsfrom tf_utils import load_dataset, random_mini_batches, convert_to_one_hot, predict%matplotlib inlinenp.random.
2020-11-20 18:02:19
206
原创 深层神经网络调参4_优化方法-NeuralNetwork
import numpy as npimport matplotlib.pyplot as pltimport scipy.ioimport mathimport sklearnimport sklearn.datasetsfrom opt_utils import load_params_and_grads, initialize_parameters, forward_propagation, backward_propagationfrom opt_utils import compu
2020-11-19 16:16:01
317
原创 深层神经网络调参3_梯度检验和dropout-NeuralNetwork
import numpy as npfrom testCases import *from testCases2 import *from gc_utils import sigmoid, relu, dictionary_to_vector, vector_to_dictionary, gradients_to_vectordef forward_propagation_n(X, Y, parameters): m = X.shape[1] W1 = parameters["W1
2020-11-17 18:46:52
235
2
原创 深层神经网络调参2_正则化和dropout-NeuralNetwork
import numpy as npimport matplotlib.pyplot as pltfrom reg_utils import sigmoid, relu, plot_decision_boundary, initialize_parameters, load_2D_dataset, predict_decfrom reg_utils import compute_cost, predict, forward_propagation, backward_propagation, upda
2020-11-17 18:44:28
231
原创 深层神经网络调参1_初始值-NeuralNetwork
import numpy as npimport matplotlib.pyplot as pltimport sklearnimport sklearn.datasetsfrom init_utils import sigmoid, relu, compute_loss, forward_propagation, backward_propagationfrom init_utils import update_parameters, predict, load_dataset, plot_de
2020-11-17 18:34:29
322
1
原创 机器学习--PCA降维3_Review
SVD分解UK中前K个组成的图片原图片保留99%方差性recover后图片import numpy as npimport matplotlib.pyplot as pltimport scipy.io as scioplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsefrom matplotlib import pyplot as pltdef plot
2020-11-16 14:00:29
138
原创 机器学习--PCA降维2_Review
import numpy as npimport matplotlib.pyplot as pltimport scipy.io as scioplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsefrom matplotlib import pyplot as pltdef Feature_normalization(X): u = np.mean(X,axi
2020-11-16 13:20:16
135
原创 机器学习--KMeans、PCA降维_Review
import numpy as npimport matplotlib.pyplot as pltimport scipy.io as scioplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsefrom matplotlib import pyplot as pltimport cv2#计算每个样本距离每个中心的距离,样本就近分配到最近的中心点def Findi
2020-11-16 13:15:27
194
原创 机器学习--神经网络反向传播_Review
import numpy as npimport scipy.io as scioimport scipy.optimize as optimport matplotlib.pyplot as pltdef transform_Y(y_label): m = y_label.size n = np.unique(y_label).size y_mat = np.zeros((n,m)) for j in range(m): y_mat[:,j][.
2020-11-15 23:38:59
119
原创 深层神经网络2__NeuralNetwork
import timeimport numpy as npimport h5pyimport matplotlib.pyplot as pltimport scipyfrom PIL import Imagefrom scipy import ndimagefrom dnn_app_utils_v2 import *%matplotlib inlineplt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plo
2020-11-15 21:51:20
124
原创 深层神经网络1__NeuralNetwork
import numpy as npimport h5pyimport matplotlib.pyplot as pltfrom testCases_v2 import *from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward%matplotlib inlineplt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plotspl
2020-11-15 18:28:35
152
原创 浅层神经网络__NeuralNetwork
import numpy as npimport matplotlib.pyplot as pltfrom testCases import *import sklearnimport sklearn.datasetsimport sklearn.linear_modelfrom planar_utils import plot_decision_boundary, sigmoid, load_planar_dataset, load_extra_datasets%matplotlib inl
2020-11-13 17:54:26
194
原创 Logistic_NeuralNetwork
import numpy as npimport matplotlib.pyplot as pltimport h5pyimport scipyfrom PIL import Imagefrom scipy import ndimagefrom lr_utils import load_dataset%matplotlib inlinetrain_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_da
2020-11-12 15:32:22
147
原创 机器学习-- 线性回归正则化、方差和偏差_Review
import numpy as npimport matplotlib.pyplot as pltimport scipy.io as scioimport scipy.optimize as optplt.rcParams['font.sans-serif'] = ['SimHei'] # 显示中文标签plt.rcParams['axes.unicode_minus'] = Falsedef polyFeatures(X, p): X = X.reshape(X.size)
2020-11-10 21:55:50
286
原创 机器学习--Logistic回归+多分类-Fourth_Chapter_Review
import numpy as npimport matplotlib.pyplot as pltimport scipy.io as scioplt.rcParams['font.sans-serif'] = ['SimHei']plt.rcParams['axes.unicode_minus'] = Falseimport scipy.optimize as optimport randomfrom matplotlib import pyplot as pltdef plot_pi
2020-11-10 20:59:11
159
原创 机器学习--Logistic多元回归-Third_Chapter_Review
import numpy as npimport pandas as pdimport scipy.optimize as optimport matplotlib.pyplot as pltplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsedef X_polyFeatures(X,nums): for sum in range(2,nums+1):
2020-11-10 19:58:27
173
原创 机器学习--Logistic回归-Second_Chapter_Review
import numpy as npimport pandas as pdimport scipy.optimize as optdef X_plusOne(X): X.insert(0,"X1",1) return X.valuesdef Nomalization(X_plusOne): X_n = np.empty((X_plusOne.shape[0],X_plusOne.shape[1])) X_max = X_plusOne[:,1:].max(axis
2020-11-10 19:26:01
142
原创 机器学习--Logistic回归-First_Chapter_Review
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsedef X_plusOne(X): X.insert(0,"X1",1) return X.valuesdef linear_Model(X_plusOne,the
2020-11-10 18:13:22
160
原创 线性回归和梯度下降--Second_Chapter--Review
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsedef autoNorm(dataset,m): #对所有特征进行标准化 meanVals = dataset.mean(0).resh
2020-11-10 17:06:00
102
原创 机器学习--线性回归和梯度下降--First_Chapter_Review
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dplt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['axes.unicode_minus']=Falsedef linear_model(theta,X): return X.dot(theta).
2020-11-10 16:04:50
114
原创 GMM多元混合高斯样本分布预测男女分类
import numpy as npfrom sklearn.mixture import GaussianMixturefrom sklearn.model_selection import train_test_splitimport matplotlib as mplimport matplotlib.colorsimport matplotlib.pyplot as pltmpl.rcParams['font.sans-serif'] = [u'SimHei']mpl.rcPara.
2020-11-09 20:46:57
915
原创 EM算法实现GMM多元混合高斯分布
import numpy as npfrom scipy.stats import multivariate_normalfrom sklearn.mixture import GaussianMixturefrom mpl_toolkits.mplot3d import Axes3Dimport matplotlib as mplimport matplotlib.pyplot as pltfrom sklearn.metrics.pairwise import pairwise_dista.
2020-11-09 15:31:35
1160
原创 二分KMmeans
import numpy as npimport matplotlib.pyplot as pltdef loadDataSet(fileName): dataMat = [] with open(fileName) as fr: for line in fr.readlines(): curLine = line.strip().split('\t') fltLine = list(map(float,curLine)).
2020-10-28 14:26:53
142
原创 SVM实践_MNIST
import numpy as npfrom sklearn import svmimport matplotlib.colorsimport matplotlib.pyplot as pltfrom PIL import Imagefrom sklearn.metrics import accuracy_scoreimport pandas as pdimport osimport csvfrom sklearn.model_selection import train_test_spl
2020-10-26 00:29:07
410
原创 回归树构建
import numpy as np#加载数据def loadDataSet(fileName): dataMat = [] fr = open(fileName) for line in fr.readlines(): curLine = line.strip().split('\t') fltLine = list(map(float,curLine)) dataMat.append(fltLine) return d
2020-10-20 11:59:38
216
原创 AdaBoost案例
import numpy as npdef loadSimData(): dataMat = np.mat([[1,2.1],[2,1.1],[1.3,1],[1,1],[2,1]]) classLabels = [1.0,1.0,-1.0,-1.0,1.0] return dataMat,classLabelsdef stumpClassfify(dataMatrix,dimen,thresVal,threshIneq): retArray = np.ones((d
2020-10-16 21:50:44
298
原创 AdaBoost机器学习实战
import numpy as npdef loadSimData(): dataMat = np.mat([[1,2.1],[2,1.1],[1.3,1],[1,1],[2,1]]) classLabels = [1.0,1.0,-1.0,-1.0,1.0] return dataMat,classLabelsdef stumpClassfify(dataMatrix,dimen,thresVal,threshIneq): retArray =
2020-10-16 20:55:12
143
原创 决策树--信息熵增益
from math import logimport operatordef createDateset(): dataSet = [["青年", "否", "否", "一般", "否"], ["青年", "否", "否", "好", "否"], ["青年", "是", "否", "好", "是"], ["青年", "是", "是", "一般", "是"], ["青年",
2020-10-15 14:14:26
152
原创 GBDT例子
抄的:GBDT原理import numpy as npimport pandas as pdA1 = np.array([0,1,2,3])A2 = np.array([5,7,21,30])A3 = np.array([20,30,70,60])y_label = np.array([1.1,1.3,1.7,1.8])data = {"编号":A1,"年龄":A2,"体重":A3,"身高":y_label}data_used = pd.DataFrame(data)data_used
2020-10-14 23:06:35
252
原创 AdaBoost实现
李航老师书上案例import numpy as npimport pandas as pdimport matplotlib.pyplot as pltnp.set_printoptions(precision=5) #e代表错误率e = np.arange(0.001,0.5,0.001)alpha = 1/2 * np.log2((1-e )/e)plt.plot(e,alpha)plt.show()随着分类器错误率上升,其权重系数alpha下降,0.5处等于0(分类器无用)
2020-10-13 21:03:28
137
原创 提升树案例
import numpy as npimport pandas as pddef Variance_cal(data,split_point,column,value): """ split_point:分裂点列表 data:DataFrame格式数据 column,分裂特征 value:标签值 """ Variance_list = {} for s in split_point:
2020-10-13 16:53:39
264
原创 决策树--鸢尾花
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport matplotlib as mplfrom sklearn import treefrom sklearn.tree import DecisionTreeClassifierfrom sklearn.model_selection import train_test_splitfrom sklearn.pipeline import Pipel
2020-10-12 19:59:40
683
原创 决策树构造
import operatorfrom math import logdef calcShannonEnt(dataSet): #计算信息熵 numEntries = len(dataSet) #数据总条数 labelCounts = {} #建立字典,对每个分类分别计数 for featVec in dataSet: #读取每条数据 currentLabe
2020-10-12 10:51:49
112
原创 决策树--基尼系数实现
def Gini_classification(data,column,label): classfication_feature = data[column].unique() classification_label = data[label].unique() sum1 = len(df) Gini_classification = {} for i in classfication_feature:
2020-10-10 19:58:09
1496
原创 VotingClassifier用法
"""一、Hard Voting 与 Soft Voting 的对比1)使用方式voting = 'hard':表示最终决策方式为 Hard Voting Classifier;voting = 'soft':表示最终决策方式为 Soft Voting Classifier; 2)思想Hard Voting Classifier:根据少数服从多数来定最终结果;Soft Voting Classifier:将所有模型预测样本为某一类别的概率的平均值作为标准,概率最高的对应的类型为最终的预测结
2020-10-09 20:08:31
5606
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人