Machine learning and its MATLAB implementation--from foundation to practice--HW3

Source: Internet
Author: User

Contents
    • I. Emptying environment variables
    • II. Training set/test set generation
    • Iii. Normalization of data
    • Iv. BP neural network creation, training and simulation test
    • V. Performance evaluation
    • VI. Drawing
I. Emptying environment variables
All CLC
II. Training set/test set generation

1. Import data

Concrete_data.mat

2. Randomly generated training sets and test sets

temp = randperm (Size (attributes,2)); % Training Set--80 samples P_train = attributes (:, temp (1:80)); T_train = Strength (:, temp (1:80)); % Test Set--23 samples P_test = attributes (:, temp (81:end)); T_test = Strength (:, temp (81:end)); N = size (p_test,2);
Iii. Normalization of data
[P_train, Ps_input] = Mapminmax (p_train,0,1);p _test = Mapminmax (' Apply ', p_test,ps_input); [T_train,ps_output] = Mapminmax (t_train,0,1);
Iv. BP neural network creation, training and simulation test

1. Create a network

NET = NEWFF (p_train,t_train,11);

2. Set Training parameters

Net.trainParam.epochs = 1000;net.trainparam.goal = 1E-3;NET.TRAINPARAM.LR = 0.01;

3. Training Network

NET = Train (Net,p_train,t_train);

4. Simulation Test

T_sim = Sim (net,p_test);

5. Inversion of data

T_sim = Mapminmax (' reverse ', t_sim,ps_output);
V. Performance evaluation

1. Absolute error errors

Error = ABS (t_sim-t_test)./t_test;

2. Decision Factor r^2

R2 = (n * SUM (t_sim. * t_test)-sum (t_sim) * SUM (t_test)) ^2/((N * SUM ((T_sim). ^2)-(SUM (T_sim)) ^2) * (n * SUM (t_test) . ^2)-(SUM (t_test)) ^2));

3. Comparison of results

result = [t_test ' T_sim ' ERROR ']
result =   28.1600   31.1291    0.1054   52.6500   53.0643    0.0079   30.9700   26.2469    0.1525   38.4600   38.0986    0.0094   41.1400   39.8364    0.0317   30.8300   30.8207    0.0003   36.1900   35.7525    0.0121   32.7100   33.8095    0.0336   41.0100   40.0879    0.0225   32.8400   33.3301    0.0149   33.9100   31.6726    0.0660   38.1900   38.3960    0.0054   26.4200   27.5678    0.0434   17.1900   18.4602    0.0739   35.5200   35.2201    0.0084   49.9700   51.0821    0.0223   48.7700   48.8715    0.0021   46.3600   46.2920    0.0015   31.5000   29.0295    0.0784   42.0800   42.0742    0.0001   36.4600   39.2970    0.0778   44.4800   44.6282    0.0033   58.5300   53.3348    0.0888
VI. Drawing
Figureplot (1:n,t_test,' b:* ', 1:n,t_sim,' R-o ') Legend (' real value ',' predictive value') Xlabel (  ' Prediction Sample ') ylabel (' concrete compressive strength ') string = {' Test set concrete compressive strength prediction result comparison '; [ ' r^2= ' num2str (R2)]};title (String)


Published with MATLAB? r2015a

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Machine learning and its MATLAB implementation--from foundation to practice--HW3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.