BP神经网络在双色球彩票上的预测实验及实现

人工智能和人工神经网络,提到这些可能有很多人都觉得很高深,很高级。但其实也有简单的,比如BP神经网络,就目前的人工神经网络发展看,除了深度学习算法的人工神经网络以外,应用最广泛的就是BP神经网络,BP神经网络能够快速发现并学习具备线性回归特征的问题。相信也有很多人想把它用在彩票分析上,处于爱好和玩的原因,我就来做一个实现。

BP神经网络的关键参数一般有3个,输入节点个数,隐藏节点个数,输出节点个数。双色球,自然输入输出都是7了。基本想法是,根据前一期的号码,推算下一期的号码。这样训练样本也很丰富,历史的中奖号码按照出奖顺序,依次传入作为训练样本即可。比较容易操作。

接下来,就是组织数据格式,要符合BP网络的算法要求了,BP神经网络训练时,只能接受小数作为输入,也就是输入数据的单向必须小于1.这好办,只需要将双色球的中奖号码除以100,形成一个2位小数,输出结果也是2位小数。甚至不需要乘100的操作,想必也能直接看懂结果大笑

                说动手就动手,先搞个BP神经网络的实现。如下:

  1. package ghost.writer.logic;  
  2.   
  3. import java.io.File;  
  4. import java.io.FileInputStream;  
  5. import java.io.FileOutputStream;  
  6. import java.io.IOException;  
  7. import java.io.ObjectInputStream;  
  8. import java.io.ObjectOutputStream;  
  9.   
  10. public class BPFactory {  
  11.     /** 
  12.      * BP神经网络元 
  13.      */  
  14.     private static BP bp;  
  15.       
  16.     /** 
  17.      * 初始化一个全新的bp神经网络 
  18.      * @param inputSize 
  19.      * @param hiddenSize  
  20.      * @param outputSize 
  21.      */  
  22.     public static void initialization(int inputSize,int hiddenSize,int outputSize) {  
  23.         bp=new BP(inputSize, hiddenSize, outputSize);  
  24.     }  
  25.       
  26.     /** 
  27.      * 从文件数据中读取bp神经网络 
  28.      * @param file 
  29.      * @throws IOException 
  30.      * @throws ClassNotFoundException 
  31.      */  
  32.     public static void initialization(File file) throws IOException, ClassNotFoundException {  
  33.         FileInputStream fi = new FileInputStream(file);  
  34.         ObjectInputStream si = new ObjectInputStream(fi);   
  35.         bp = (BP) si.readObject();   
  36.         si.close();  
  37.     }  
  38.       
  39.     /** 
  40.      * 将目前的神经网络储存在指定文件 
  41.      * @param file 
  42.      * @throws IOException 
  43.      */  
  44.     public static void save(File file) throws IOException {  
  45.         FileOutputStream fo = new FileOutputStream(file);  
  46.         ObjectOutputStream so = new ObjectOutputStream(fo);  
  47.         so.writeObject(bp);  
  48.         so.close();  
  49.     }  
  50.       
  51.     /** 
  52.      * 训练BP神经网络 
  53.      * @param trainData 
  54.      * @param target 
  55.      */  
  56.     public static void train(double[] trainData, double[] target) {  
  57.         bp.train(trainData, target);  
  58.     }  
  59.       
  60.     /** 
  61.      * 要求bp神经网络返回预测值 
  62.      * @param inData 
  63.      * @return 
  64.      */  
  65.     public static double[] test(double[] inData) {  
  66.         return bp.test(inData);  
  67.     }  
  68. }  

聪明的同学可能已经发现了,上面只是个工厂类,我们继续:

  1. package ghost.writer.logic;  
  2.   
  3. import java.io.Serializable;  
  4. import java.util.Random;  
  5.   
  6. /** 
  7.  * BPNN. 
  8.  *  
  9.  * @author RenaQiu 
  10.  *  
  11.  */  
  12. public class BP implements Serializable {  
  13.     /** 
  14.      *  
  15.      */  
  16.     private static final long serialVersionUID = 1L;  
  17.     /** 
  18.      * input vector. 
  19.      */  
  20.     private final double[] input;  
  21.     /** 
  22.      * hidden layer. 
  23.      */  
  24.     private final double[] hidden;  
  25.     /** 
  26.      * output layer. 
  27.      */  
  28.     private final double[] output;  
  29.     /** 
  30.      * target. 
  31.      */  
  32.     private final double[] target;  
  33.   
  34.     /** 
  35.      * delta vector of the hidden layer . 
  36.      */  
  37.     private final double[] hidDelta;  
  38.     /** 
  39.      * output layer of the output layer. 
  40.      */  
  41.     private final double[] optDelta;  
  42.   
  43.     /** 
  44.      * learning rate. 
  45.      */  
  46.     private final double eta;  
  47.     /** 
  48.      * momentum. 
  49.      */  
  50.     private final double momentum;  
  51.   
  52.     /** 
  53.      * weight matrix from input layer to hidden layer. 
  54.      */  
  55.     private final double[][] iptHidWeights;  
  56.     /** 
  57.      * weight matrix from hidden layer to output layer. 
  58.      */  
  59.     private final double[][] hidOptWeights;  
  60.   
  61.     /** 
  62.      * previous weight update. 
  63.      */  
  64.     private final double[][] iptHidPrevUptWeights;  
  65.     /** 
  66.      * previous weight update. 
  67.      */  
  68.     private final double[][] hidOptPrevUptWeights;  
  69.   
  70.     public double optErrSum = 0d;  
  71.   
  72.     public double hidErrSum = 0d;  
  73.   
  74.     private final Random random;  
  75.   
  76.     /** 
  77.      * Constructor. 
  78.      * <p> 
  79.      * <strong>Note:</strong> The capacity of each layer will be the parameter 
  80.      * plus 1. The additional unit is used for smoothness. 
  81.      * </p> 
  82.      *  
  83.      * @param inputSize 
  84.      * @param hiddenSize 
  85.      * @param outputSize 
  86.      * @param eta 
  87.      * @param momentum 
  88.      * @param epoch 
  89.      */  
  90.     public BP(int inputSize, int hiddenSize, int outputSize, double eta,  
  91.             double momentum) {  
  92.   
  93.         input = new double[inputSize + 1];  
  94.         hidden = new double[hiddenSize + 1];  
  95.         output = new double[outputSize + 1];  
  96.         target = new double[outputSize + 1];  
  97.   
  98.         hidDelta = new double[hiddenSize + 1];  
  99.         optDelta = new double[outputSize + 1];  
  100.   
  101.         iptHidWeights = new double[inputSize + 1][hiddenSize + 1];  
  102.         hidOptWeights = new double[hiddenSize + 1][outputSize + 1];  
  103.   
  104.         random = new Random(20140106);  
  105.         randomizeWeights(iptHidWeights);  
  106.         randomizeWeights(hidOptWeights);  
  107.   
  108.         iptHidPrevUptWeights = new double[inputSize + 1][hiddenSize + 1];  
  109.         hidOptPrevUptWeights = new double[hiddenSize + 1][outputSize + 1];  
  110.   
  111.         this.eta = eta;  
  112.         this.momentum = momentum;  
  113.     }  
  114.   
  115.     private void randomizeWeights(double[][] matrix) {  
  116.         for (int i = 0, len = matrix.length; i != len; i++)  
  117.             for (int j = 0, len2 = matrix[i].length; j != len2; j++) {  
  118.                 double real = random.nextDouble();  
  119.                 matrix[i][j] = random.nextDouble() > 0.5 ? real : -real;  
  120.             }  
  121.     }  
  122.   
  123.     /** 
  124.      * Constructor with default eta = 0.25 and momentum = 0.3. 
  125.      *  
  126.      * @param inputSize 
  127.      * @param hiddenSize 
  128.      * @param outputSize 
  129.      * @param epoch 
  130.      */  
  131.     public BP(int inputSize, int hiddenSize, int outputSize) {  
  132.         this(inputSize, hiddenSize, outputSize, 0.9980.001);  
  133.     }  
  134.   
  135.     /** 
  136.      * Entry method. The train data should be a one-dim vector. 
  137.      *  
  138.      * @param trainData 
  139.      * @param target 
  140.      */  
  141.     public void train(double[] trainData, double[] target) {  
  142.         loadInput(trainData);  
  143.         loadTarget(target);  
  144.         forward();  
  145.         calculateDelta();  
  146.         adjustWeight();  
  147.     }  
  148.   
  149.     /** 
  150.      * Test the BPNN. 
  151.      *  
  152.      * @param inData 
  153.      * @return 
  154.      */  
  155.     public double[] test(double[] inData) {  
  156.         if (inData.length != input.length - 1) {  
  157.             throw new IllegalArgumentException("Size Do Not Match.");  
  158.         }  
  159.         System.arraycopy(inData, 0, input, 1, inData.length);  
  160.         forward();  
  161.         return getNetworkOutput();  
  162.     }  
  163.   
  164.     /** 
  165.      * Return the output layer. 
  166.      *  
  167.      * @return 
  168.      */  
  169.     private double[] getNetworkOutput() {  
  170.         int len = output.length;  
  171.         double[] temp = new double[len - 1];  
  172.         for (int i = 1; i != len; i++)  
  173.             temp[i - 1] = output[i];  
  174.         return temp;  
  175.     }  
  176.   
  177.     /** 
  178.      * Load the target data. 
  179.      *  
  180.      * @param arg 
  181.      */  
  182.     private void loadTarget(double[] arg) {  
  183.         if (arg.length != target.length - 1) {  
  184.             throw new IllegalArgumentException("Size Do Not Match.");  
  185.         }  
  186.         System.arraycopy(arg, 0, target, 1, arg.length);  
  187.     }  
  188.   
  189.     /** 
  190.      * Load the training data. 
  191.      *  
  192.      * @param inData 
  193.      */  
  194.     private void loadInput(double[] inData) {  
  195.         if (inData.length != input.length - 1) {  
  196.             throw new IllegalArgumentException("Size Do Not Match.");  
  197.         }  
  198.         System.arraycopy(inData, 0, input, 1, inData.length);  
  199.     }  
  200.   
  201.     /** 
  202.      * Forward. 
  203.      *  
  204.      * @param layer0 
  205.      * @param layer1 
  206.      * @param weight 
  207.      */  
  208.     private void forward(double[] layer0, double[] layer1, double[][] weight) {  
  209.         // threshold unit.  
  210.         layer0[0] = 1.0;  
  211.         for (int j = 1, len = layer1.length; j != len; ++j) {  
  212.             double sum = 0;  
  213.             for (int i = 0, len2 = layer0.length; i != len2; ++i)  
  214.                 sum += weight[i][j] * layer0[i];  
  215.             layer1[j] = sigmoid(sum);  
  216.             // layer1[j] = tansig(sum);  
  217.         }  
  218.     }  
  219.   
  220.     /** 
  221.      * Forward. 
  222.      */  
  223.     private void forward() {  
  224.         forward(input, hidden, iptHidWeights);  
  225.         forward(hidden, output, hidOptWeights);  
  226.     }  
  227.   
  228.     /** 
  229.      * Calculate output error. 
  230.      */  
  231.     private void outputErr() {  
  232.         double errSum = 0;  
  233.         for (int idx = 1, len = optDelta.length; idx != len; ++idx) {  
  234.             double o = output[idx];  
  235.             optDelta[idx] = o * (1d - o) * (target[idx] - o);  
  236.             errSum += Math.abs(optDelta[idx]);  
  237.         }  
  238.         optErrSum = errSum;  
  239.     }  
  240.   
  241.     /** 
  242.      * Calculate hidden errors. 
  243.      */  
  244.     private void hiddenErr() {  
  245.         double errSum = 0;  
  246.         for (int j = 1, len = hidDelta.length; j != len; ++j) {  
  247.             double o = hidden[j];  
  248.             double sum = 0;  
  249.             for (int k = 1, len2 = optDelta.length; k != len2; ++k)  
  250.                 sum += hidOptWeights[j][k] * optDelta[k];  
  251.             hidDelta[j] = o * (1d - o) * sum;  
  252.             errSum += Math.abs(hidDelta[j]);  
  253.         }  
  254.         hidErrSum = errSum;  
  255.     }  
  256.   
  257.     /** 
  258.      * Calculate errors of all layers. 
  259.      */  
  260.     private void calculateDelta() {  
  261.         outputErr();  
  262.         hiddenErr();  
  263.     }  
  264.   
  265.     /** 
  266.      * Adjust the weight matrix. 
  267.      *  
  268.      * @param delta 
  269.      * @param layer 
  270.      * @param weight 
  271.      * @param prevWeight 
  272.      */  
  273.     private void adjustWeight(double[] delta, double[] layer,  
  274.             double[][] weight, double[][] prevWeight) {  
  275.   
  276.         layer[0] = 1;  
  277.         for (int i = 1, len = delta.length; i != len; ++i) {  
  278.             for (int j = 0, len2 = layer.length; j != len2; ++j) {  
  279.                 double newVal = momentum * prevWeight[j][i] + eta * delta[i]  
  280.                         * layer[j];  
  281.                 weight[j][i] += newVal;  
  282.                 prevWeight[j][i] = newVal;  
  283.             }  
  284.         }  
  285.     }  
  286.   
  287.     /** 
  288.      * Adjust all weight matrices. 
  289.      */  
  290.     private void adjustWeight() {  
  291.         adjustWeight(optDelta, hidden, hidOptWeights, hidOptPrevUptWeights);  
  292.         adjustWeight(hidDelta, input, iptHidWeights, iptHidPrevUptWeights);  
  293.     }  
  294.   
  295.     /** 
  296.      * Sigmoid. 
  297.      *  
  298.      * @param val 
  299.      * @return 
  300.      */  
  301.     private double sigmoid(double val) {  
  302.         return 1d / (1d + Math.exp(-val));  
  303.     }  
  304.   
  305.     private double tansig(double val) {  
  306.         return 2d / (1d + Math.exp(-2 * val)) - 1;  
  307.     }  
  308. }  

上面就是BP神经网络的核心实现类了,看上去很简单吧。注意哦,它可是有线性学习能力的!工具有了,还是先把训练数据准备好吧,读数据库什么的太隐晦,先用个数组做简单点,即使要改以后也很容易。毕竟是做实验嘛,如果成功了,中了个二等奖,精度不够,要更进一步训练,我想也就不用俺多说了~~~

  1. package ghost.writer.data;  
  2.   
  3. public class Data {  
  4.     public static double[][] trainData_89feibo = {  
  5.             { 0.100.130.170.280.300.320.04 },  
  6.             { 0.100.130.140.160.210.320.14 },  
  7.             { 0.030.070.130.180.220.250.03 },  
  8.             { 0.080.120.150.190.280.290.02 },  
  9.             { 0.060.070.140.210.220.240.13 },  
  10.             { 0.030.120.130.220.300.330.14 },  
  11.             { 0.030.040.080.140.210.280.14 },  
  12.             { 0.080.180.190.220.270.320.06 },  
  13.             { 0.030.120.250.260.280.290.16 },  
  14.             { 0.130.160.190.230.260.280.05 },  
  15.             { 0.080.110.170.210.230.240.05 },  
  16.             { 0.030.100.180.240.270.290.09 },  
  17.             { 0.050.070.100.130.190.200.15 },  
  18.             { 0.050.060.070.120.130.180.12 },  
  19.             { 0.010.060.070.190.220.270.02 },  
  20.             { 0.100.150.180.200.230.310.12 },  
  21.             { 0.010.090.130.220.250.320.12 },  
  22.             { 0.070.180.190.230.290.300.02 },  
  23.             { 0.010.030.160.170.200.320.07 },  
  24.             { 0.010.040.090.150.220.300.06 },  
  25.             { 0.020.070.130.200.250.270.06 },  
  26.             { 0.070.160.170.180.300.330.06 },  
  27.             { 0.020.030.090.100.280.300.06 },  
  28.             { 0.050.120.210.230.260.280.09 },  
  29.             { 0.020.080.110.140.190.330.09 },  
  30.             { 0.020.090.130.170.200.280.11 },  
  31.             { 0.030.060.080.140.190.320.03 },  
  32.             { 0.040.060.090.250.300.330.14 },  
  33.             { 0.140.230.240.260.290.300.03 },  
  34.             { 0.090.140.230.240.260.290.03 },  
  35.             { 0.030.050.170.180.260.270.15 },  
  36.             { 0.070.130.170.190.220.260.13 },  
  37.             { 0.100.110.120.230.280.320.16 },  
  38.             { 0.010.040.100.130.210.310.13 },  
  39.             { 0.040.130.140.200.220.300.06 },  
  40.             { 0.050.060.120.140.190.230.09 },  
  41.             { 0.050.070.090.110.200.210.03 },  
  42.             { 0.020.080.120.140.160.320.16 },  
  43.             { 0.020.040.110.130.160.260.11 },  
  44.             { 0.020.130.190.230.240.280.05 },  
  45.             { 0.090.150.200.210.220.240.14 },  
  46.             { 0.040.080.120.190.210.250.13 },  
  47.             { 0.020.050.110.230.240.290.08 },  
  48.             { 0.040.140.240.250.280.310.10 },  
  49.             { 0.070.110.150.210.260.310.06 },  
  50.             { 0.010.020.080.260.290.310.14 },  
  51.             { 0.020.040.140.180.200.220.07 },  
  52.             { 0.010.060.150.190.280.290.10 },  
  53.             { 0.010.020.220.280.290.300.15 },  
  54.             { 0.050.140.170.220.230.250.07 },  
  55.             { 0.070.150.180.190.200.260.14 },  
  56.             { 0.050.110.200.210.260.310.03 },  
  57.             { 0.040.080.110.140.160.200.11 },  
  58.             { 0.050.070.090.230.270.320.01 },  
  59.             { 0.020.040.050.060.080.160.03 },  
  60.             { 0.020.040.090.130.180.200.07 },  
  61.             { 0.010.020.040.150.170.280.11 },  
  62.             { 0.010.110.230.270.310.320.09 },  
  63.             { 0.090.110.230.300.310.320.06 },  
  64.             { 0.070.090.110.170.280.310.11 },  
  65.             { 0.160.210.220.280.310.320.05 },  
  66.             { 0.090.230.240.270.290.320.08 },  
  67.             { 0.150.170.180.210.290.320.13 },  
  68.             { 0.010.020.030.060.080.330.13 },  
  69.             { 0.010.060.120.130.220.310.07 },  
  70.             { 0.040.070.110.170.240.330.09 },  
  71.             { 0.040.060.170.210.230.330.07 },  
  72.             { 0.030.120.160.170.180.270.08 },  
  73.             { 0.120.150.210.260.320.330.07 },  
  74.             { 0.040.170.190.230.240.270.10 },  
  75.             { 0.040.150.160.240.270.280.03 },  
  76.             { 0.070.080.110.130.210.270.08 },  
  77.             { 0.010.050.120.130.210.220.10 },  
  78.             { 0.030.040.050.250.300.310.04 },  
  79.             { 0.110.120.140.200.220.290.14 },  
  80.             { 0.120.180.210.220.270.320.11 },  
  81.             { 0.050.070.120.190.270.310.02 },  
  82.             { 0.060.100.130.160.230.240.15 },  
  83.             { 0.080.200.250.300.320.330.01 },  
  84.             { 0.020.150.160.170.190.300.08 },  
  85.             { 0.060.110.120.140.170.220.01 },  
  86.             { 0.090.180.250.260.300.320.11 },  
  87.             { 0.010.150.160.250.260.290.10 },  
  88.             { 0.030.090.100.190.280.330.09 },  
  89.             { 0.040.060.140.160.180.290.05 },  
  90.             { 0.080.110.130.180.280.330.10 },  
  91.             { 0.070.110.140.190.240.290.05 },  
  92.             { 0.030.090.150.200.270.290.01 },  
  93.             { 0.040.210.230.310.320.330.04 },  
  94.             { 0.060.100.110.280.300.330.12 },  
  95.             { 0.010.040.190.220.240.250.15 },  
  96.             { 0.150.180.230.270.320.330.04 },  
  97.             { 0.030.040.070.170.210.270.14 },  
  98.             { 0.080.100.120.140.180.280.14 },  
  99.             { 0.050.140.160.210.290.300.12 },  
  100.             { 0.080.090.190.200.250.320.16 },  
  101.             { 0.050.070.080.200.310.330.11 },  
  102.             { 0.090.100.130.140.210.320.02 },  
  103.             { 0.010.080.110.190.210.240.08 },  
  104.             { 0.050.090.130.150.170.210.13 },  
  105.             { 0.040.090.190.220.250.290.15 } };  
  106.   
  107.     public static double[][] target_89feibo = {  
  108.             { 0.100.130.140.160.210.320.14 },  
  109.             { 0.030.070.130.180.220.250.03 },  
  110.             { 0.080.120.150.190.280.290.02 },  
  111.             { 0.060.070.140.210.220.240.13 },  
  112.             { 0.030.120.130.220.300.330.14 },  
  113.             { 0.030.040.080.140.210.280.14 },  
  114.             { 0.080.180.190.220.270.320.06 },  
  115.             { 0.030.120.250.260.280.290.16 },  
  116.             { 0.130.160.190.230.260.280.05 },  
  117.             { 0.080.110.170.210.230.240.05 },  
  118.             { 0.030.100.180.240.270.290.09 },  
  119.             { 0.050.070.100.130.190.200.15 },  
  120.             { 0.050.060.070.120.130.180.12 },  
  121.             { 0.010.060.070.190.220.270.02 },  
  122.             { 0.100.150.180.200.230.310.12 },  
  123.             { 0.010.090.130.220.250.320.12 },  
  124.             { 0.070.180.190.230.290.300.02 },  
  125.             { 0.010.030.160.170.200.320.07 },  
  126.             { 0.010.040.090.150.220.300.06 },  
  127.             { 0.020.070.130.200.250.270.06 },  
  128.             { 0.070.160.170.180.300.330.06 },  
  129.             { 0.020.030.090.100.280.300.06 },  
  130.             { 0.050.120.210.230.260.280.09 },  
  131.             { 0.020.080.110.140.190.330.09 },  
  132.             { 0.020.090.130.170.200.280.11 },  
  133.             { 0.030.060.080.140.190.320.03 },  
  134.             { 0.040.060.090.250.300.330.14 },  
  135.             { 0.140.230.240.260.290.300.03 },  
  136.             { 0.090.140.230.240.260.290.03 },  
  137.             { 0.030.050.170.180.260.270.15 },  
  138.             { 0.070.130.170.190.220.260.13 },  
  139.             { 0.100.110.120.230.280.320.16 },  
  140.             { 0.010.040.100.130.210.310.13 },  
  141.             { 0.040.130.140.200.220.300.06 },  
  142.             { 0.050.060.120.140.190.230.09 },  
  143.             { 0.050.070.090.110.200.210.03 },  
  144.             { 0.020.080.120.140.160.320.16 },  
  145.             { 0.020.040.110.130.160.260.11 },  
  146.             { 0.020.130.190.230.240.280.05 },  
  147.             { 0.090.150.200.210.220.240.14 },  
  148.             { 0.040.080.120.190.210.250.13 },  
  149.             { 0.020.050.110.230.240.290.08 },  
  150.             { 0.040.140.240.250.280.310.10 },  
  151.             { 0.070.110.150.210.260.310.06 },  
  152.             { 0.010.020.080.260.290.310.14 },  
  153.             { 0.020.040.140.180.200.220.07 },  
  154.             { 0.010.060.150.190.280.290.10 },  
  155.             { 0.010.020.220.280.290.300.15 },  
  156.             { 0.050.140.170.220.230.250.07 },  
  157.             { 0.070.150.180.190.200.260.14 },  
  158.             { 0.050.110.200.210.260.310.03 },  
  159.             { 0.040.080.110.140.160.200.11 },  
  160.             { 0.050.070.090.230.270.320.01 },  
  161.             { 0.020.040.050.060.080.160.03 },  
  162.             { 0.020.040.090.130.180.200.07 },  
  163.             { 0.010.020.040.150.170.280.11 },  
  164.             { 0.010.110.230.270.310.320.09 },  
  165.             { 0.090.110.230.300.310.320.06 },  
  166.             { 0.070.090.110.170.280.310.11 },  
  167.             { 0.160.210.220.280.310.320.05 },  
  168.             { 0.090.230.240.270.290.320.08 },  
  169.             { 0.150.170.180.210.290.320.13 },  
  170.             { 0.010.020.030.060.080.330.13 },  
  171.             { 0.010.060.120.130.220.310.07 },  
  172.             { 0.040.070.110.170.240.330.09 },  
  173.             { 0.040.060.170.210.230.330.07 },  
  174.             { 0.030.120.160.170.180.270.08 },  
  175.             { 0.120.150.210.260.320.330.07 },  
  176.             { 0.040.170.190.230.240.270.10 },  
  177.             { 0.040.150.160.240.270.280.03 },  
  178.             { 0.070.080.110.130.210.270.08 },  
  179.             { 0.010.050.120.130.210.220.10 },  
  180.             { 0.030.040.050.250.300.310.04 },  
  181.             { 0.110.120.140.200.220.290.14 },  
  182.             { 0.120.180.210.220.270.320.11 },  
  183.             { 0.050.070.120.190.270.310.02 },  
  184.             { 0.060.100.130.160.230.240.15 },  
  185.             { 0.080.200.250.300.320.330.01 },  
  186.             { 0.020.150.160.170.190.300.08 },  
  187.             { 0.060.110.120.140.170.220.01 },  
  188.             { 0.090.180.250.260.300.320.11 },  
  189.             { 0.010.150.160.250.260.290.10 },  
  190.             { 0.030.090.100.190.280.330.09 },  
  191.             { 0.040.060.140.160.180.290.05 },  
  192.             { 0.080.110.130.180.280.330.10 },  
  193.             { 0.070.110.140.190.240.290.05 },  
  194.             { 0.030.090.150.200.270.290.01 },  
  195.             { 0.040.210.230.310.320.330.04 },  
  196.             { 0.060.100.110.280.300.330.12 },  
  197.             { 0.010.040.190.220.240.250.15 },  
  198.             { 0.150.180.230.270.320.330.04 },  
  199.             { 0.030.040.070.170.210.270.14 },  
  200.             { 0.080.100.120.140.180.280.14 },  
  201.             { 0.050.140.160.210.290.300.12 },  
  202.             { 0.080.090.190.200.250.320.16 },  
  203.             { 0.050.070.080.200.310.330.11 },  
  204.             { 0.090.100.130.140.210.320.02 },  
  205.             { 0.010.080.110.190.210.240.08 },  
  206.             { 0.050.090.130.150.170.210.13 },  
  207.             { 0.040.090.190.220.250.290.15 },  
  208.             { 0.020.110.190.300.320.330.09 }};  
  209.   
  210.     // 输入1期,输出1期,输入参数7个,减少输入的期数,长期无趋势短期也许会有  
  211.     public static double[][] trainData_5num = {  
  212.             { 0.090.180.250.260.300.320.11 },  
  213.             { 0.010.150.160.250.260.290.10 },  
  214.             { 0.030.090.100.190.280.330.09 },  
  215.             { 0.040.060.140.160.180.290.05 },  
  216.             { 0.080.110.130.180.280.330.10 },  
  217.             { 0.070.110.140.190.240.290.05 },  
  218.             { 0.030.090.150.200.270.290.01 },  
  219.             { 0.040.210.230.310.320.330.04 } };  
  220.   
  221.     // 输入1期,输出1期,输出参数7个  
  222.     public static double[][] target_5num = {  
  223.             { 0.010.150.160.250.260.290.10 },  
  224.             { 0.030.090.100.190.280.330.09 },  
  225.             { 0.040.060.140.160.180.290.05 },  
  226.             { 0.080.110.130.180.280.330.10 },  
  227.             { 0.070.110.140.190.240.290.05 },  
  228.             { 0.030.090.150.200.270.290.01 },  
  229.             { 0.040.210.230.310.320.330.04 },  
  230.             { 0.060.100.110.280.300.330.12 } };  
  231.   
  232.     // 输入1期,输出1期,输入参数7个  
  233.     public static double[][] trainData = {  
  234.             { 0.050.140.240.250.260.320.01 },  
  235.             { 0.100.120.180.220.280.290.07 },  
  236.             { 0.040.050.110.210.270.280.10 },  
  237.             { 0.050.070.120.160.280.320.04 },  
  238.             { 0.060.080.140.150.240.250.06 },  
  239.             { 0.010.160.180.220.280.300.12 },  
  240.             { 0.220.230.260.270.280.330.09 },  
  241.             { 0.060.100.160.200.270.320.08 },  
  242.             { 0.010.130.140.250.310.320.12 },  
  243.             { 0.090.100.130.170.220.300.13 },  
  244.             { 0.020.090.150.220.260.320.01 },  
  245.             { 0.030.080.170.210.250.320.15 },  
  246.             { 0.010.040.090.130.160.230.02 },  
  247.             { 0.010.090.110.170.320.330.12 },  
  248.             { 0.030.120.170.240.270.290.09 },  
  249.             { 0.060.140.170.220.280.290.02 },  
  250.             { 0.050.060.130.190.220.280.09 },  
  251.             { 0.020.040.050.170.190.200.08 },  
  252.             { 0.050.060.070.110.130.180.15 },  
  253.             { 0.020.050.060.120.140.280.05 },  
  254.             { 0.040.060.120.300.310.320.09 },  
  255.             { 0.020.080.130.280.290.300.05 },  
  256.             { 0.010.020.050.160.200.260.06 },  
  257.             { 0.010.070.080.120.160.210.01 },  
  258.             { 0.010.060.170.190.260.310.11 },  
  259.             { 0.020.040.070.090.150.200.07 },  
  260.             { 0.030.060.150.180.300.320.05 },  
  261.             { 0.040.050.130.230.270.300.09 },  
  262.             { 0.160.170.180.240.250.300.08 },  
  263.             { 0.040.110.140.150.220.310.11 },  
  264.             { 0.010.020.040.120.210.240.12 },  
  265.             { 0.070.080.140.250.260.280.13 },  
  266.             { 0.060.070.100.190.230.290.12 },  
  267.             { 0.070.140.180.250.260.290.06 },  
  268.             { 0.030.130.140.150.210.330.03 },  
  269.             { 0.040.210.250.290.300.330.03 },  
  270.             { 0.050.060.130.170.190.280.01 },  
  271.             { 0.060.150.200.220.260.330.09 },  
  272.             { 0.010.140.150.170.260.300.02 },  
  273.             { 0.040.050.090.270.290.310.13 },  
  274.             { 0.020.150.180.270.280.320.14 },  
  275.             { 0.090.100.120.140.150.190.11 },  
  276.             { 0.010.020.140.150.240.290.06 },  
  277.             { 0.020.040.100.120.170.300.10 },  
  278.             { 0.020.100.120.170.230.240.05 },  
  279.             { 0.010.080.120.130.150.330.03 },  
  280.             { 0.030.060.140.150.170.250.16 },  
  281.             { 0.030.050.110.180.260.280.06 },  
  282.             { 0.060.070.080.140.230.310.12 },  
  283.             { 0.030.160.190.200.240.260.06 },  
  284.             { 0.010.080.110.170.270.300.12 },  
  285.             { 0.100.130.170.280.300.320.04 },  
  286.             { 0.100.130.140.160.210.320.14 },  
  287.             { 0.030.070.130.180.220.250.03 },  
  288.             { 0.080.120.150.190.280.290.02 },  
  289.             { 0.060.070.140.210.220.240.13 },  
  290.             { 0.030.120.130.220.300.330.14 },  
  291.             { 0.030.040.080.140.210.280.14 },  
  292.             { 0.080.180.190.220.270.320.06 },  
  293.             { 0.030.120.250.260.280.290.16 },  
  294.             { 0.130.160.190.230.260.280.05 },  
  295.             { 0.080.110.170.210.230.240.05 },  
  296.             { 0.030.100.180.240.270.290.09 },  
  297.             { 0.050.070.100.130.190.200.15 },  
  298.             { 0.050.060.070.120.130.180.12 },  
  299.             { 0.010.060.070.190.220.270.02 },  
  300.             { 0.100.150.180.200.230.310.12 },  
  301.             { 0.010.090.130.220.250.320.12 },  
  302.             { 0.070.180.190.230.290.300.02 },  
  303.             { 0.010.030.160.170.200.320.07 },  
  304.             { 0.010.040.090.150.220.300.06 },  
  305.             { 0.020.070.130.200.250.270.06 },  
  306.             { 0.070.160.170.180.300.330.06 },  
  307.             { 0.020.030.090.100.280.300.06 },  
  308.             { 0.050.120.210.230.260.280.09 },  
  309.             { 0.020.080.110.140.190.330.09 },  
  310.             { 0.020.090.130.170.200.280.11 },  
  311.             { 0.030.060.080.140.190.320.03 },  
  312.             { 0.040.060.090.250.300.330.14 },  
  313.             { 0.140.230.240.260.290.300.03 },  
  314.             { 0.090.140.230.240.260.290.03 },  
  315.             { 0.030.050.170.180.260.270.15 },  
  316.             { 0.070.130.170.190.220.260.13 },  
  317.             { 0.100.110.120.230.280.320.16 },  
  318.             { 0.010.040.100.130.210.310.13 },  
  319.             { 0.040.130.140.200.220.300.06 },  
  320.             { 0.050.060.120.140.190.230.09 },  
  321.             { 0.050.070.090.110.200.210.03 },  
  322.             { 0.020.080.120.140.160.320.16 },  
  323.             { 0.020.040.110.130.160.260.11 },  
  324.             { 0.020.130.190.230.240.280.05 },  
  325.             { 0.090.150.200.210.220.240.14 },  
  326.             { 0.040.080.120.190.210.250.13 },  
  327.             { 0.020.050.110.230.240.290.08 },  
  328.             { 0.040.140.240.250.280.310.10 },  
  329.             { 0.070.110.150.210.260.310.06 },  
  330.             { 0.010.020.080.260.290.310.14 },  
  331.             { 0.020.040.140.180.200.220.07 },  
  332.             { 0.010.060.150.190.280.290.10 },  
  333.             { 0.010.020.220.280.290.300.15 },  
  334.             { 0.050.140.170.220.230.250.07 },  
  335.             { 0.070.150.180.190.200.260.14 },  
  336.             { 0.050.110.200.210.260.310.03 },  
  337.             { 0.040.080.110.140.160.200.11 },  
  338.             { 0.050.070.090.230.270.320.01 },  
  339.             { 0.020.040.050.060.080.160.03 },  
  340.             { 0.020.040.090.130.180.200.07 },  
  341.             { 0.010.020.040.150.170.280.11 },  
  342.             { 0.010.110.230.270.310.320.09 },  
  343.             { 0.090.110.230.300.310.320.06 },  
  344.             { 0.070.090.110.170.280.310.11 },  
  345.             { 0.160.210.220.280.310.320.05 },  
  346.             { 0.090.230.240.270.290.320.08 },  
  347.             { 0.150.170.180.210.290.320.13 },  
  348.             { 0.010.020.030.060.080.330.13 },  
  349.             { 0.010.060.120.130.220.310.07 },  
  350.             { 0.040.070.110.170.240.330.09 },  
  351.             { 0.040.060.170.210.230.330.07 },  
  352.             { 0.030.120.160.170.180.270.08 },  
  353.             { 0.120.150.210.260.320.330.07 },  
  354.             { 0.040.170.190.230.240.270.10 },  
  355.             { 0.040.150.160.240.270.280.03 },  
  356.             { 0.070.080.110.130.210.270.08 },  
  357.             { 0.010.050.120.130.210.220.10 },  
  358.             { 0.030.040.050.250.300.310.04 },  
  359.             { 0.110.120.140.200.220.290.14 },  
  360.             { 0.120.180.210.220.270.320.11 },  
  361.             { 0.050.070.120.190.270.310.02 },  
  362.             { 0.060.100.130.160.230.240.15 },  
  363.             { 0.080.200.250.300.320.330.01 },  
  364.             { 0.020.150.160.170.190.300.08 },  
  365.             { 0.060.110.120.140.170.220.01 },  
  366.             { 0.090.180.250.260.300.320.11 },  
  367.             { 0.010.150.160.250.260.290.10 },  
  368.             { 0.030.090.100.190.280.330.09 },  
  369.             { 0.040.060.140.160.180.290.05 },  
  370.             { 0.080.110.130.180.280.330.10 },  
  371.             { 0.070.110.140.190.240.290.05 },  
  372.             { 0.030.090.150.200.270.290.01 } };  
  373.     // 输入1期,输出1期,输出参数7个  
  374.     public static double[][] target = {  
  375.             { 0.100.120.180.220.280.290.07 },  
  376.             { 0.040.050.110.210.270.280.10 },  
  377.             { 0.050.070.120.160.280.320.04 },  
  378.             { 0.060.080.140.150.240.250.06 },  
  379.             { 0.010.160.180.220.280.300.12 },  
  380.             { 0.220.230.260.270.280.330.09 },  
  381.             { 0.060.100.160.200.270.320.08 },  
  382.             { 0.010.130.140.250.310.320.12 },  
  383.             { 0.090.100.130.170.220.300.13 },  
  384.             { 0.020.090.150.220.260.320.01 },  
  385.             { 0.030.080.170.210.250.320.15 },  
  386.             { 0.010.040.090.130.160.230.02 },  
  387.             { 0.010.090.110.170.320.330.12 },  
  388.             { 0.030.120.170.240.270.290.09 },  
  389.             { 0.060.140.170.220.280.290.02 },  
  390.             { 0.050.060.130.190.220.280.09 },  
  391.             { 0.020.040.050.170.190.200.08 },  
  392.             { 0.050.060.070.110.130.180.15 },  
  393.             { 0.020.050.060.120.140.280.05 },  
  394.             { 0.040.060.120.300.310.320.09 },  
  395.             { 0.020.080.130.280.290.300.05 },  
  396.             { 0.010.020.050.160.200.260.06 },  
  397.             { 0.010.070.080.120.160.210.01 },  
  398.             { 0.010.060.170.190.260.310.11 },  
  399.             { 0.020.040.070.090.150.200.07 },  
  400.             { 0.030.060.150.180.300.320.05 },  
  401.             { 0.040.050.130.230.270.300.09 },  
  402.             { 0.160.170.180.240.250.300.08 },  
  403.             { 0.040.110.140.150.220.310.11 },  
  404.             { 0.010.020.040.120.210.240.12 },  
  405.             { 0.070.080.140.250.260.280.13 },  
  406.             { 0.060.070.100.190.230.290.12 },  
  407.             { 0.070.140.180.250.260.290.06 },  
  408.             { 0.030.130.140.150.210.330.03 },  
  409.             { 0.040.210.250.290.300.330.03 },  
  410.             { 0.050.060.130.170.190.280.01 },  
  411.             { 0.060.150.200.220.260.330.09 },  
  412.             { 0.010.140.150.170.260.300.02 },  
  413.             { 0.040.050.090.270.290.310.13 },  
  414.             { 0.020.150.180.270.280.320.14 },  
  415.             { 0.090.100.120.140.150.190.11 },  
  416.             { 0.010.020.140.150.240.290.06 },  
  417.             { 0.020.040.100.120.170.300.10 },  
  418.             { 0.020.100.120.170.230.240.05 },  
  419.             { 0.010.080.120.130.150.330.03 },  
  420.             { 0.030.060.140.150.170.250.16 },  
  421.             { 0.030.050.110.180.260.280.06 },  
  422.             { 0.060.070.080.140.230.310.12 },  
  423.             { 0.030.160.190.200.240.260.06 },  
  424.             { 0.010.080.110.170.270.300.12 },  
  425.             { 0.100.130.170.280.300.320.04 },  
  426.             { 0.100.130.140.160.210.320.14 },  
  427.             { 0.030.070.130.180.220.250.03 },  
  428.             { 0.080.120.150.190.280.290.02 },  
  429.             { 0.060.070.140.210.220.240.13 },  
  430.             { 0.030.120.130.220.300.330.14 },  
  431.             { 0.030.040.080.140.210.280.14 },  
  432.             { 0.080.180.190.220.270.320.06 },  
  433.             { 0.030.120.250.260.280.290.16 },  
  434.             { 0.130.160.190.230.260.280.05 },  
  435.             { 0.080.110.170.210.230.240.05 },  
  436.             { 0.030.100.180.240.270.290.09 },  
  437.             { 0.050.070.100.130.190.200.15 },  
  438.             { 0.050.060.070.120.130.180.12 },  
  439.             { 0.010.060.070.190.220.270.02 },  
  440.             { 0.100.150.180.200.230.310.12 },  
  441.             { 0.010.090.130.220.250.320.12 },  
  442.             { 0.070.180.190.230.290.300.02 },  
  443.             { 0.010.030.160.170.200.320.07 },  
  444.             { 0.010.040.090.150.220.300.06 },  
  445.             { 0.020.070.130.200.250.270.06 },  
  446.             { 0.070.160.170.180.300.330.06 },  
  447.             { 0.020.030.090.100.280.300.06 },  
  448.             { 0.050.120.210.230.260.280.09 },  
  449.             { 0.020.080.110.140.190.330.09 },  
  450.             { 0.020.090.130.170.200.280.11 },  
  451.             { 0.030.060.080.140.190.320.03 },  
  452.             { 0.040.060.090.250.300.330.14 },  
  453.             { 0.140.230.240.260.290.300.03 },  
  454.             { 0.090.140.230.240.260.290.03 },  
  455.             { 0.030.050.170.180.260.270.15 },  
  456.             { 0.070.130.170.190.220.260.13 },  
  457.             { 0.100.110.120.230.280.320.16 },  
  458.             { 0.010.040.100.130.210.310.13 },  
  459.             { 0.040.130.140.200.220.300.06 },  
  460.             { 0.050.060.120.140.190.230.09 },  
  461.             { 0.050.070.090.110.200.210.03 },  
  462.             { 0.020.080.120.140.160.320.16 },  
  463.             { 0.020.040.110.130.160.260.11 },  
  464.             { 0.020.130.190.230.240.280.05 },  
  465.             { 0.090.150.200.210.220.240.14 },  
  466.             { 0.040.080.120.190.210.250.13 },  
  467.             { 0.020.050.110.230.240.290.08 },  
  468.             { 0.040.140.240.250.280.310.10 },  
  469.             { 0.070.110.150.210.260.310.06 },  
  470.             { 0.010.020.080.260.290.310.14 },  
  471.             { 0.020.040.140.180.200.220.07 },  
  472.             { 0.010.060.150.190.280.290.10 },  
  473.             { 0.010.020.220.280.290.300.15 },  
  474.             { 0.050.140.170.220.230.250.07 },  
  475.             { 0.070.150.180.190.200.260.14 },  
  476.             { 0.050.110.200.210.260.310.03 },  
  477.             { 0.040.080.110.140.160.200.11 },  
  478.             { 0.050.070.090.230.270.320.01 },  
  479.             { 0.020.040.050.060.080.160.03 },  
  480.             { 0.020.040.090.130.180.200.07 },  
  481.             { 0.010.020.040.150.170.280.11 },  
  482.             { 0.010.110.230.270.310.320.09 },  
  483.             { 0.090.110.230.300.310.320.06 },  
  484.             { 0.070.090.110.170.280.310.11 },  
  485.             { 0.160.210.220.280.310.320.05 },  
  486.             { 0.090.230.240.270.290.320.08 },  
  487.             { 0.150.170.180.210.290.320.13 },  
  488.             { 0.010.020.030.060.080.330.13 },  
  489.             { 0.010.060.120.130.220.310.07 },  
  490.             { 0.040.070.110.170.240.330.09 },  
  491.             { 0.040.060.170.210.230.330.07 },  
  492.             { 0.030.120.160.170.180.270.08 },  
  493.             { 0.120.150.210.260.320.330.07 },  
  494.             { 0.040.170.190.230.240.270.10 },  
  495.             { 0.040.150.160.240.270.280.03 },  
  496.             { 0.070.080.110.130.210.270.08 },  
  497.             { 0.010.050.120.130.210.220.10 },  
  498.             { 0.030.040.050.250.300.310.04 },  
  499.             { 0.110.120.140.200.220.290.14 },  
  500.             { 0.120.180.210.220.270.320.11 },  
  501.             { 0.050.070.120.190.270.310.02 },  
  502.             { 0.060.100.130.160.230.240.15 },  
  503.             { 0.080.200.250.300.320.330.01 },  
  504.             { 0.020.150.160.170.190.300.08 },  
  505.             { 0.060.110.120.140.170.220.01 },  
  506.             { 0.090.180.250.260.300.320.11 },  
  507.             { 0.010.150.160.250.260.290.10 },  
  508.             { 0.030.090.100.190.280.330.09 },  
  509.             { 0.040.060.140.160.180.290.05 },  
  510.             { 0.080.110.130.180.280.330.10 },  
  511.             { 0.070.110.140.190.240.290.05 },  
  512.             { 0.030.090.150.200.270.290.01 },  
  513.             { 0.040.210.230.310.320.330.04 } };  
  514.   
  515.     // 连续2期作为一组输入,输入是14个变量  
  516.     public static double[][] trainData_2 = {  
  517.             { 0.050.140.240.250.260.320.010.100.120.180.22,  
  518.                     0.280.290.07 },  
  519.             { 0.100.120.180.220.280.290.070.040.050.110.21,  
  520.                     0.270.280.10 },  
  521.             { 0.040.050.110.210.270.280.100.050.070.120.16,  
  522.                     0.280.320.04 },  
  523.             { 0.050.070.120.160.280.320.040.060.080.140.15,  
  524.                     0.240.250.06 },  
  525.             { 0.060.080.140.150.240.250.060.010.160.180.22,  
  526.                     0.280.300.12 },  
  527.             { 0.010.160.180.220.280.300.120.220.230.260.27,  
  528.                     0.280.330.09 },  
  529.             { 0.220.230.260.270.280.330.090.060.100.160.20,  
  530.                     0.270.320.08 },  
  531.             { 0.060.100.160.200.270.320.080.010.130.140.25,  
  532.                     0.310.320.12 },  
  533.             { 0.010.130.140.250.310.320.120.090.100.130.17,  
  534.                     0.220.300.13 },  
  535.             { 0.090.100.130.170.220.300.130.020.090.150.22,  
  536.                     0.260.320.01 },  
  537.             { 0.020.090.150.220.260.320.010.030.080.170.21,  
  538.                     0.250.320.15 },  
  539.             { 0.030.080.170.210.250.320.150.010.040.090.13,  
  540.                     0.160.230.02 },  
  541.             { 0.010.040.090.130.160.230.020.010.090.110.17,  
  542.                     0.320.330.12 },  
  543.             { 0.010.090.110.170.320.330.120.030.120.170.24,  
  544.                     0.270.290.09 },  
  545.             { 0.030.120.170.240.270.290.090.060.140.170.22,  
  546.                     0.280.290.02 },  
  547.             { 0.060.140.170.220.280.290.020.050.060.130.19,  
  548.                     0.220.280.09 },  
  549.             { 0.050.060.130.190.220.280.090.020.040.050.17,  
  550.                     0.190.200.08 },  
  551.             { 0.020.040.050.170.190.200.080.050.060.070.11,  
  552.                     0.130.180.15 },  
  553.             { 0.050.060.070.110.130.180.150.020.050.060.12,  
  554.                     0.140.280.05 },  
  555.             { 0.020.050.060.120.140.280.050.040.060.120.30,  
  556.                     0.310.320.09 },  
  557.             { 0.040.060.120.300.310.320.090.020.080.130.28,  
  558.                     0.290.300.05 },  
  559.             { 0.020.080.130.280.290.300.050.010.020.050.16,  
  560.                     0.200.260.06 },  
  561.             { 0.010.020.050.160.200.260.060.010.070.080.12,  
  562.                     0.160.210.01 },  
  563.             { 0.010.070.080.120.160.210.010.010.060.170.19,  
  564.                     0.260.310.11 },  
  565.             { 0.010.060.170.190.260.310.110.020.040.070.09,  
  566.                     0.150.200.07 },  
  567.             { 0.020.040.070.090.150.200.070.030.060.150.18,  
  568.                     0.300.320.05 },  
  569.             { 0.030.060.150.180.300.320.050.040.050.130.23,  
  570.                     0.270.300.09 },  
  571.             { 0.040.050.130.230.270.300.090.160.170.180.24,  
  572.                     0.250.300.08 },  
  573.             { 0.160.170.180.240.250.300.080.040.110.140.15,  
  574.                     0.220.310.11 },  
  575.             { 0.040.110.140.150.220.310.110.010.020.040.12,  
  576.                     0.210.240.12 },  
  577.             { 0.010.020.040.120.210.240.120.070.080.140.25,  
  578.                     0.260.280.13 },  
  579.             { 0.070.080.140.250.260.280.130.060.070.100.19,  
  580.                     0.230.290.12 },  
  581.             { 0.060.070.100.190.230.290.120.070.140.180.25,  
  582.                     0.260.290.06 },  
  583.             { 0.070.140.180.250.260.290.060.030.130.140.15,  
  584.                     0.210.330.03 },  
  585.             { 0.030.130.140.150.210.330.030.040.210.250.29,  
  586.                     0.300.330.03 },  
  587.             { 0.040.210.250.290.300.330.030.050.060.130.17,  
  588.                     0.190.280.01 },  
  589.             { 0.050.060.130.170.190.280.010.060.150.200.22,  
  590.                     0.260.330.09 },  
  591.             { 0.060.150.200.220.260.330.090.010.140.150.17,  
  592.                     0.260.300.02 },  
  593.             { 0.010.140.150.170.260.300.020.040.050.090.27,  
  594.                     0.290.310.13 },  
  595.             { 0.040.050.090.270.290.310.130.020.150.180.27,  
  596.                     0.280.320.14 },  
  597.             { 0.020.150.180.270.280.320.140.090.100.120.14,  
  598.                     0.150.190.11 },  
  599.             { 0.090.100.120.140.150.190.110.010.020.140.15,  
  600.                     0.240.290.06 },  
  601.             { 0.010.020.140.150.240.290.060.020.040.100.12,  
  602.                     0.170.300.10 },  
  603.             { 0.020.040.100.120.170.300.100.020.100.120.17,  
  604.                     0.230.240.05 },  
  605.             { 0.020.100.120.170.230.240.050.010.080.120.13,  
  606.                     0.150.330.03 },  
  607.             { 0.010.080.120.130.150.330.030.030.060.140.15,  
  608.                     0.170.250.16 },  
  609.             { 0.030.060.140.150.170.250.160.030.050.110.18,  
  610.                     0.260.280.06 },  
  611.             { 0.030.050.110.180.260.280.060.060.070.080.14,  
  612.                     0.230.310.12 },  
  613.             { 0.060.070.080.140.230.310.120.030.160.190.20,  
  614.                     0.240.260.06 },  
  615.             { 0.030.160.190.200.240.260.060.010.080.110.17,  
  616.                     0.270.300.12 },  
  617.             { 0.010.080.110.170.270.300.120.100.130.170.28,  
  618.                     0.300.320.04 },  
  619.             { 0.100.130.170.280.300.320.040.100.130.140.16,  
  620.                     0.210.320.14 },  
  621.             { 0.100.130.140.160.210.320.140.030.070.130.18,  
  622.                     0.220.250.03 },  
  623.             { 0.030.070.130.180.220.250.030.080.120.150.19,  
  624.                     0.280.290.02 },  
  625.             { 0.080.120.150.190.280.290.020.060.070.140.21,  
  626.                     0.220.240.13 },  
  627.             { 0.060.070.140.210.220.240.130.030.120.130.22,  
  628.                     0.300.330.14 },  
  629.             { 0.030.120.130.220.300.330.140.030.040.080.14,  
  630.                     0.210.280.14 },  
  631.             { 0.030.040.080.140.210.280.140.080.180.190.22,  
  632.                     0.270.320.06 },  
  633.             { 0.080.180.190.220.270.320.060.030.120.250.26,  
  634.                     0.280.290.16 },  
  635.             { 0.030.120.250.260.280.290.160.130.160.190.23,  
  636.                     0.260.280.05 },  
  637.             { 0.130.160.190.230.260.280.050.080.110.170.21,  
  638.                     0.230.240.05 },  
  639.             { 0.080.110.170.210.230.240.050.030.100.180.24,  
  640.                     0.270.290.09 },  
  641.             { 0.030.100.180.240.270.290.090.050.070.100.13,  
  642.                     0.190.200.15 },  
  643.             { 0.050.070.100.130.190.200.150.050.060.070.12,  
  644.                     0.130.180.12 },  
  645.             { 0.050.060.070.120.130.180.120.010.060.070.19,  
  646.                     0.220.270.02 },  
  647.             { 0.010.060.070.190.220.270.020.100.150.180.20,  
  648.                     0.230.310.12 },  
  649.             { 0.100.150.180.200.230.310.120.010.090.130.22,  
  650.                     0.250.320.12 },  
  651.             { 0.010.090.130.220.250.320.120.070.180.190.23,  
  652.                     0.290.300.02 },  
  653.             { 0.070.180.190.230.290.300.020.010.030.160.17,  
  654.                     0.200.320.07 },  
  655.             { 0.010.030.160.170.200.320.070.010.040.090.15,  
  656.                     0.220.300.06 },  
  657.             { 0.010.040.090.150.220.300.060.020.070.130.20,  
  658.                     0.250.270.06 },  
  659.             { 0.020.070.130.200.250.270.060.070.160.170.18,  
  660.                     0.300.330.06 },  
  661.             { 0.070.160.170.180.300.330.060.020.030.090.10,  
  662.                     0.280.300.06 },  
  663.             { 0.020.030.090.100.280.300.060.050.120.210.23,  
  664.                     0.260.280.09 },  
  665.             { 0.050.120.210.230.260.280.090.020.080.110.14,  
  666.                     0.190.330.09 },  
  667.             { 0.020.080.110.140.190.330.090.020.090.130.17,  
  668.                     0.200.280.11 },  
  669.             { 0.020.090.130.170.200.280.110.030.060.080.14,  
  670.                     0.190.320.03 },  
  671.             { 0.030.060.080.140.190.320.030.040.060.090.25,  
  672.                     0.300.330.14 },  
  673.             { 0.040.060.090.250.300.330.140.140.230.240.26,  
  674.                     0.290.300.03 },  
  675.             { 0.140.230.240.260.290.300.030.090.140.230.24,  
  676.                     0.260.290.03 },  
  677.             { 0.090.140.230.240.260.290.030.030.050.170.18,  
  678.                     0.260.270.15 },  
  679.             { 0.030.050.170.180.260.270.150.070.130.170.19,  
  680.                     0.220.260.13 },  
  681.             { 0.070.130.170.190.220.260.130.100.110.120.23,  
  682.                     0.280.320.16 },  
  683.             { 0.100.110.120.230.280.320.160.010.040.100.13,  
  684.                     0.210.310.13 },  
  685.             { 0.010.040.100.130.210.310.130.040.130.140.20,  
  686.                     0.220.300.06 },  
  687.             { 0.040.130.140.200.220.300.060.050.060.120.14,  
  688.                     0.190.230.09 },  
  689.             { 0.050.060.120.140.190.230.090.050.070.090.11,  
  690.                     0.200.210.03 },  
  691.             { 0.050.070.090.110.200.210.030.020.080.120.14,  
  692.                     0.160.320.16 },  
  693.             { 0.020.080.120.140.160.320.160.020.040.110.13,  
  694.                     0.160.260.11 },  
  695.             { 0.020.040.110.130.160.260.110.020.130.190.23,  
  696.                     0.240.280.05 },  
  697.             { 0.020.130.190.230.240.280.050.090.150.200.21,  
  698.                     0.220.240.14 },  
  699.             { 0.090.150.200.210.220.240.140.040.080.120.19,  
  700.                     0.210.250.13 },  
  701.             { 0.040.080.120.190.210.250.130.020.050.110.23,  
  702.                     0.240.290.08 },  
  703.             { 0.020.050.110.230.240.290.080.040.140.240.25,  
  704.                     0.280.310.10 },  
  705.             { 0.040.140.240.250.280.310.100.070.110.150.21,  
  706.                     0.260.310.06 },  
  707.             { 0.070.110.150.210.260.310.060.010.020.080.26,  
  708.                     0.290.310.14 },  
  709.             { 0.010.020.080.260.290.310.140.020.040.140.18,  
  710.                     0.200.220.07 },  
  711.             { 0.020.040.140.180.200.220.070.010.060.150.19,  
  712.                     0.280.290.10 },  
  713.             { 0.010.060.150.190.280.290.100.010.020.220.28,  
  714.                     0.290.300.15 },  
  715.             { 0.010.020.220.280.290.300.150.050.140.170.22,  
  716.                     0.230.250.07 },  
  717.             { 0.050.140.170.220.230.250.070.070.150.180.19,  
  718.                     0.200.260.14 },  
  719.             { 0.070.150.180.190.200.260.140.050.110.200.21,  
  720.                     0.260.310.03 },  
  721.             { 0.050.110.200.210.260.310.030.040.080.110.14,  
  722.                     0.160.200.11 },  
  723.             { 0.040.080.110.140.160.200.110.050.070.090.23,  
  724.                     0.270.320.01 },  
  725.             { 0.050.070.090.230.270.320.010.020.040.050.06,  
  726.                     0.080.160.03 },  
  727.             { 0.020.040.050.060.080.160.030.020.040.090.13,  
  728.                     0.180.200.07 },  
  729.             { 0.020.040.090.130.180.200.070.010.020.040.15,  
  730.                     0.170.280.11 },  
  731.             { 0.010.020.040.150.170.280.110.010.110.230.27,  
  732.                     0.310.320.09 },  
  733.             { 0.010.110.230.270.310.320.090.090.110.230.30,  
  734.                     0.310.320.06 },  
  735.             { 0.090.110.230.300.310.320.060.070.090.110.17,  
  736.                     0.280.310.11 },  
  737.             { 0.070.090.110.170.280.310.110.160.210.220.28,  
  738.                     0.310.320.05 },  
  739.             { 0.160.210.220.280.310.320.050.090.230.240.27,  
  740.                     0.290.320.08 },  
  741.             { 0.090.230.240.270.290.320.080.150.170.180.21,  
  742.                     0.290.320.13 },  
  743.             { 0.150.170.180.210.290.320.130.010.020.030.06,  
  744.                     0.080.330.13 },  
  745.             { 0.010.020.030.060.080.330.130.010.060.120.13,  
  746.                     0.220.310.07 },  
  747.             { 0.010.060.120.130.220.310.070.040.070.110.17,  
  748.                     0.240.330.09 },  
  749.             { 0.040.070.110.170.240.330.090.040.060.170.21,  
  750.                     0.230.330.07 },  
  751.             { 0.040.060.170.210.230.330.070.030.120.160.17,  
  752.                     0.180.270.08 },  
  753.             { 0.030.120.160.170.180.270.080.120.150.210.26,  
  754.                     0.320.330.07 },  
  755.             { 0.120.150.210.260.320.330.070.040.170.190.23,  
  756.                     0.240.270.10 },  
  757.             { 0.040.170.190.230.240.270.100.040.150.160.24,  
  758.                     0.270.280.03 },  
  759.             { 0.040.150.160.240.270.280.030.070.080.110.13,  
  760.                     0.210.270.08 },  
  761.             { 0.070.080.110.130.210.270.080.010.050.120.13,  
  762.                     0.210.220.10 },  
  763.             { 0.010.050.120.130.210.220.100.030.040.050.25,  
  764.                     0.300.310.04 },  
  765.             { 0.030.040.050.250.300.310.040.110.120.140.20,  
  766.                     0.220.290.14 },  
  767.             { 0.110.120.140.200.220.290.140.120.180.210.22,  
  768.                     0.270.320.11 },  
  769.             { 0.120.180.210.220.270.320.110.050.070.120.19,  
  770.                     0.270.310.02 },  
  771.             { 0.050.070.120.190.270.310.020.060.100.130.16,  
  772.                     0.230.240.15 },  
  773.             { 0.060.100.130.160.230.240.150.080.200.250.30,  
  774.                     0.320.330.01 },  
  775.             { 0.080.200.250.300.320.330.010.020.150.160.17,  
  776.                     0.190.300.08 },  
  777.             { 0.020.150.160.170.190.300.080.060.110.120.14,  
  778.                     0.170.220.01 },  
  779.             { 0.060.110.120.140.170.220.010.090.180.250.26,  
  780.                     0.300.320.11 },  
  781.             { 0.090.180.250.260.300.320.110.010.150.160.25,  
  782.                     0.260.290.10 },  
  783.             { 0.010.150.160.250.260.290.100.030.090.100.19,  
  784.                     0.280.330.09 },  
  785.             { 0.030.090.100.190.280.330.090.040.060.140.16,  
  786.                     0.180.290.05 },  
  787.             { 0.040.060.140.160.180.290.050.080.110.130.18,  
  788.                     0.280.330.10 },  
  789.             { 0.080.110.130.180.280.330.100.070.110.140.19,  
  790.                     0.240.290.05 },  
  791.             { 0.070.110.140.190.240.290.050.030.090.150.20,  
  792.                     0.270.290.01 } };  
  793.   
  794.     // 连续2期作为一组输入的解,输出还是7个  
  795.     public static double[][] target_2 = {  
  796.             { 0.040.050.110.210.270.280.10 },  
  797.             { 0.050.070.120.160.280.320.04 },  
  798.             { 0.060.080.140.150.240.250.06 },  
  799.             { 0.010.160.180.220.280.300.12 },  
  800.             { 0.220.230.260.270.280.330.09 },  
  801.             { 0.060.100.160.200.270.320.08 },  
  802.             { 0.010.130.140.250.310.320.12 },  
  803.             { 0.090.100.130.170.220.300.13 },  
  804.             { 0.020.090.150.220.260.320.01 },  
  805.             { 0.030.080.170.210.250.320.15 },  
  806.             { 0.010.040.090.130.160.230.02 },  
  807.             { 0.010.090.110.170.320.330.12 },  
  808.             { 0.030.120.170.240.270.290.09 },  
  809.             { 0.060.140.170.220.280.290.02 },  
  810.             { 0.050.060.130.190.220.280.09 },  
  811.             { 0.020.040.050.170.190.200.08 },  
  812.             { 0.050.060.070.110.130.180.15 },  
  813.             { 0.020.050.060.120.140.280.05 },  
  814.             { 0.040.060.120.300.310.320.09 },  
  815.             { 0.020.080.130.280.290.300.05 },  
  816.             { 0.010.020.050.160.200.260.06 },  
  817.             { 0.010.070.080.120.160.210.01 },  
  818.             { 0.010.060.170.190.260.310.11 },  
  819.             { 0.020.040.070.090.150.200.07 },  
  820.             { 0.030.060.150.180.300.320.05 },  
  821.             { 0.040.050.130.230.270.300.09 },  
  822.             { 0.160.170.180.240.250.300.08 },  
  823.             { 0.040.110.140.150.220.310.11 },  
  824.             { 0.010.020.040.120.210.240.12 },  
  825.             { 0.070.080.140.250.260.280.13 },  
  826.             { 0.060.070.100.190.230.290.12 },  
  827.             { 0.070.140.180.250.260.290.06 },  
  828.             { 0.030.130.140.150.210.330.03 },  
  829.             { 0.040.210.250.290.300.330.03 },  
  830.             { 0.050.060.130.170.190.280.01 },  
  831.             { 0.060.150.200.220.260.330.09 },  
  832.             { 0.010.140.150.170.260.300.02 },  
  833.             { 0.040.050.090.270.290.310.13 },  
  834.             { 0.020.150.180.270.280.320.14 },  
  835.             { 0.090.100.120.140.150.190.11 },  
  836.             { 0.010.020.140.150.240.290.06 },  
  837.             { 0.020.040.100.120.170.300.10 },  
  838.             { 0.020.100.120.170.230.240.05 },  
  839.             { 0.010.080.120.130.150.330.03 },  
  840.             { 0.030.060.140.150.170.250.16 },  
  841.             { 0.030.050.110.180.260.280.06 },  
  842.             { 0.060.070.080.140.230.310.12 },  
  843.             { 0.030.160.190.200.240.260.06 },  
  844.             { 0.010.080.110.170.270.300.12 },  
  845.             { 0.100.130.170.280.300.320.04 },  
  846.             { 0.100.130.140.160.210.320.14 },  
  847.             { 0.030.070.130.180.220.250.03 },  
  848.             { 0.080.120.150.190.280.290.02 },  
  849.             { 0.060.070.140.210.220.240.13 },  
  850.             { 0.030.120.130.220.300.330.14 },  
  851.             { 0.030.040.080.140.210.280.14 },  
  852.             { 0.080.180.190.220.270.320.06 },  
  853.             { 0.030.120.250.260.280.290.16 },  
  854.             { 0.130.160.190.230.260.280.05 },  
  855.             { 0.080.110.170.210.230.240.05 },  
  856.             { 0.030.100.180.240.270.290.09 },  
  857.             { 0.050.070.100.130.190.200.15 },  
  858.             { 0.050.060.070.120.130.180.12 },  
  859.             { 0.010.060.070.190.220.270.02 },  
  860.             { 0.100.150.180.200.230.310.12 },  
  861.             { 0.010.090.130.220.250.320.12 },  
  862.             { 0.070.180.190.230.290.300.02 },  
  863.             { 0.010.030.160.170.200.320.07 },  
  864.             { 0.010.040.090.150.220.300.06 },  
  865.             { 0.020.070.130.200.250.270.06 },  
  866.             { 0.070.160.170.180.300.330.06 },  
  867.             { 0.020.030.090.100.280.300.06 },  
  868.             { 0.050.120.210.230.260.280.09 },  
  869.             { 0.020.080.110.140.190.330.09 },  
  870.             { 0.020.090.130.170.200.280.11 },  
  871.             { 0.030.060.080.140.190.320.03 },  
  872.             { 0.040.060.090.250.300.330.14 },  
  873.             { 0.140.230.240.260.290.300.03 },  
  874.             { 0.090.140.230.240.260.290.03 },  
  875.             { 0.030.050.170.180.260.270.15 },  
  876.             { 0.070.130.170.190.220.260.13 },  
  877.             { 0.100.110.120.230.280.320.16 },  
  878.             { 0.010.040.100.130.210.310.13 },  
  879.             { 0.040.130.140.200.220.300.06 },  
  880.             { 0.050.060.120.140.190.230.09 },  
  881.             { 0.050.070.090.110.200.210.03 },  
  882.             { 0.020.080.120.140.160.320.16 },  
  883.             { 0.020.040.110.130.160.260.11 },  
  884.             { 0.020.130.190.230.240.280.05 },  
  885.             { 0.090.150.200.210.220.240.14 },  
  886.             { 0.040.080.120.190.210.250.13 },  
  887.             { 0.020.050.110.230.240.290.08 },  
  888.             { 0.040.140.240.250.280.310.10 },  
  889.             { 0.070.110.150.210.260.310.06 },  
  890.             { 0.010.020.080.260.290.310.14 },  
  891.             { 0.020.040.140.180.200.220.07 },  
  892.             { 0.010.060.150.190.280.290.10 },  
  893.             { 0.010.020.220.280.290.300.15 },  
  894.             { 0.050.140.170.220.230.250.07 },  
  895.             { 0.070.150.180.190.200.260.14 },  
  896.             { 0.050.110.200.210.260.310.03 },  
  897.             { 0.040.080.110.140.160.200.11 },  
  898.             { 0.050.070.090.230.270.320.01 },  
  899.             { 0.020.040.050.060.080.160.03 },  
  900.             { 0.020.040.090.130.180.200.07 },  
  901.             { 0.010.020.040.150.170.280.11 },  
  902.             { 0.010.110.230.270.310.320.09 },  
  903.             { 0.090.110.230.300.310.320.06 },  
  904.             { 0.070.090.110.170.280.310.11 },  
  905.             { 0.160.210.220.280.310.320.05 },  
  906.             { 0.090.230.240.270.290.320.08 },  
  907.             { 0.150.170.180.210.290.320.13 },  
  908.             { 0.010.020.030.060.080.330.13 },  
  909.             { 0.010.060.120.130.220.310.07 },  
  910.             { 0.040.070.110.170.240.330.09 },  
  911.             { 0.040.060.170.210.230.330.07 },  
  912.             { 0.030.120.160.170.180.270.08 },  
  913.             { 0.120.150.210.260.320.330.07 },  
  914.             { 0.040.170.190.230.240.270.10 },  
  915.             { 0.040.150.160.240.270.280.03 },  
  916.             { 0.070.080.110.130.210.270.08 },  
  917.             { 0.010.050.120.130.210.220.10 },  
  918.             { 0.030.040.050.250.300.310.04 },  
  919.             { 0.110.120.140.200.220.290.14 },  
  920.             { 0.120.180.210.220.270.320.11 },  
  921.             { 0.050.070.120.190.270.310.02 },  
  922.             { 0.060.100.130.160.230.240.15 },  
  923.             { 0.080.200.250.300.320.330.01 },  
  924.             { 0.020.150.160.170.190.300.08 },  
  925.             { 0.060.110.120.140.170.220.01 },  
  926.             { 0.090.180.250.260.300.320.11 },  
  927.             { 0.010.150.160.250.260.290.10 },  
  928.             { 0.030.090.100.190.280.330.09 },  
  929.             { 0.040.060.140.160.180.290.05 },  
  930.             { 0.080.110.130.180.280.330.10 },  
  931.             { 0.070.110.140.190.240.290.05 },  
  932.             { 0.030.090.150.200.270.290.01 },  
  933.             { 0.040.210.230.310.320.330.04 } };  
  934. }  

试验数据准备完毕,开始写个主类调用一下!看看是不是就发了,哈哈:

  1. package ghost.writer.start;  
  2.   
  3. import ghost.writer.data.Data;  
  4. import ghost.writer.logic.BPFactory;  
  5.   
  6. public class TestBP {  
  7.   
  8.     /** 
  9.      * @param args 
  10.      */  
  11.     public static void main(String[] args) {  
  12.         // TODO Auto-generated method stub  
  13.         // 7,18,7  
  14.         BPFactory.initialization(7557);  
  15.         double[][] trainData = Data.trainData_89feibo;  
  16.         double[][] target = Data.target_89feibo;  
  17.   
  18.         for (int i = 0; i < 1156; i++) {  
  19.             for (int j = 0; j < trainData.length; j++) {  
  20.                 BPFactory.train(trainData[j], target[j]);  
  21.             }  
  22.             System.out.println(i);  
  23.         }  
  24.   
  25.         // 0.04, 0.21, 0.23, 0.31, 0.32, 0.33, 0.04  
  26.         // 0.03,0.09,0.15,0.20,0.27,0.29,0.01, 0.04, 0.21, 0.23, 0.31, 0.32,  
  27.         // 0.33, 0.04  
  28.         // 0.06, 0.10, 0.11, 0.28, 0.30, 0.33, 0.12  
  29.         double[] test = {  0.020.110.190.300.320.330.09  };  
  30.   
  31.         double[] resault = BPFactory.test(test);  
  32.   
  33.         System.out.print("{");  
  34.         for (double res : resault) {  
  35.             System.out.print(String.format("%.2f", res) + ",");  
  36.         }  
  37.         System.out.println("}");  
  38.         //  
  39.         // System.out.print("{");  
  40.         // int i = 1;  
  41.         // for (double res : resault) {  
  42.         // if (res > 0.5 && res < 1.5) {  
  43.         // System.out.print(i % 33 + ",");  
  44.         // }  
  45.         // i++;  
  46.         // }  
  47.         // System.out.println("}");  
  48.     }  
  49. }  

运行此类,效果明显啊!1156次样本训练之后,test里的号码,如果是训练数据中出现过的,其test结果直接就是其后一期中出号码!这就是要发财的节奏啊!

不过!各位也看到了,本博还在写博客,还在因为工作原因研究hadoop!本博对BP神经网络进行一番研究之后,发现隐层节点基本上将训练样本数据完全“记忆”了下来,因此在用训练样本数据做测试时,可以基本达到100%出现后一期号码。而当出现训练样本最后一条记录作为输入时,问题发生了。BP网络其实本身计算出了整个样本的各各输出的“平均”数,之后他将此数输出了出来。之所以发现这个规律,是连续2次跟进买号之后,发现每次输出的结果基本都一样。因为新产生的一注号码,毕竟对往届历史的N个号码影响很小。因此BP网络输出的看上去一直是一个均值。

扫描二维码关注公众号,回复: 55106 查看本文章

游戏做完了,BP网络也熟悉了。随机事件规律发现的问题,还需要进一步的去探索,而创造一个人工智能来帮助人们发现未知的规律,那才是真真有趣的!~~最后希望结交更多的人工智能实现方面的人,一起找乐子。用彩票数据来训练,纯属一种玩乐的心态,学习是一件有趣的事,不要太当真。

猜你喜欢

转载自blog.csdn.net/u010144805/article/details/80060257