load water_data.mat attributes = mapminmax(attributes); P_train = attributes(:,1:35); T_train = classes(:,1:35); P_test = attributes(:,36:end); T_test = classes(:,36:end); net = newsom(P_train,[4 4]); net.trainParam.epochs = 200; net = train(net,P_tr…
load water_data.mat attributes = mapminmax(attributes); P_train = attributes(:,1:35); T_train = classes(:,1:35); P_test = attributes(:,36:end); T_test = classes(:,36:end); net = newc(minmax(P_train),4,0.01,0.01); w=net.iw{1,1}; b=net.b{1} net.trainPa…
import tensorflow as tf import numpy as np def add_layer(inputs, in_size, out_size, n_layer, activation_function=None): # add one more layer and return the output of this layer layer_name = 'layer%s' % n_layer with tf.name_scope(layer_name): with tf.…
理论以前写过:https://www.cnblogs.com/fangxiaoqi/p/11306545.html,这里根据天气.是否周末.有无促销的情况,来预测销量情况. function [ matrix,attributes ] = bp_preprocess( inputfile ) %% BP神经网络算法数据预处理,把字符串转换为0,1编码 % inputfile: 输入数据文件: % output: 转换后的0,1矩阵: % attributes: 属性和Label: %% 读取数据…
BP神经网络 百度百科:传送门 BP(back propagation)神经网络:一种按照误差逆向传播算法训练的多层前馈神经网络,是目前应用最广泛的神经网络 #设置文件工作区间 setwd('D:\\dat') #读入数据 Gary=read.csv("sales_data.csv")[,2:5] #数据命名 library(nnet) colnames(Gary)<-c("x1","x2","x3","y&q…
load concrete_data.mat n = randperm(size(attributes,2)); p_train = attributes(:,n(1:80))'; t_train = strength(:,n(1:80))'; p_test = attributes(:,n(81:end))'; t_test = strength(:,n(81:end))'; [pn_train,inputps] = mapminmax(p_train'); pn_train = pn_tra…
load spectra; temp = randperm(size(NIR, 1)); P_train = NIR(temp(1:50),:); T_train = octane(temp(1:50),:); P_test = NIR(temp(51:end),:); T_test = octane(temp(51:end),:); k = 2; [Xloadings,Yloadings,Xscores,Yscores,betaPLS,PLSPctVar,MSE,stats] = plsreg…
load spectra; temp = randperm(size(NIR, 1)); P_train = NIR(temp(1:50),:); T_train = octane(temp(1:50),:); P_test = NIR(temp(51:end),:); T_test = octane(temp(51:end),:); [PCALoadings,PCAScores,PCAVar] = princomp(NIR); figure percent_explained = 100 *…
%RF:RF实现根据乳腺肿瘤特征向量高精度(better)预测肿瘤的是恶性还是良性 load data.mat a = randperm(569); Train = data(a(1:500),:); Test = data(a(501:end),:); P_train = Train(:,3:end); T_train = Train(:,2); P_test = Test(:,3:end); T_test = Test(:,2); model = classRF_train(P_train,…
load iris_data.mat P_train = []; T_train = []; P_test = []; T_test = []; for i = 1:3 temp_input = features((i-1)*50+1:i*50,:); temp_output = classes((i-1)*50+1:i*50,:); n = randperm(50); P_train = [P_train temp_input(n(1:40),:)']; T_train = [T_train…