Neuroph training

Help
Anonymous
2012-10-27
2012-12-24
  • Anonymous - 2012-10-27

    Hello,

    I am trying to do something like in the neuroph stock prediction example. But after I trained the network I always get 0.0 as output when I set the data and calculate
    Here is how I create the input and output data and train the network:

    String query = "SELECT DATE, CLOSEING FROM APP."+stocks[i].stockName.toUpperCase()+" ORDER BY DATE DESC";
                PreparedStatement ps = DBHelperClass.getSingelton().conn.prepareStatement(query,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
                ResultSet rs = DBHelperClass.getSingelton().getDataFromDB(ps);
                
                ArrayList<double[]> inputData = new ArrayList<double[]>();
                ArrayList<double[]> outputData = new ArrayList<double[]>();
                
                int c = 0;
                
                double[] dataInput = new double[10];
                double[] dataOutput = new double[1];
                
                rs.last();
                int numOfRows = rs.getRow();
                rs.beforeFirst();
                
                System.out.println("ROWS:"+numOfRows);
                
                while(rs.next())
                {   
                    if(c>=10)
                    {
                        inputData.add(dataInput);
                        dataInput = new double[10];
                        dataOutput[0] = rs.getDouble(2)/1000;
                        System.out.println("Out:"+rs.getDouble(2)/1000);
                        outputData.add(dataOutput);
                        dataOutput = new double[1];
                        c = 0;
                        
                    }
                    if((rs.getRow()>((numOfRows/11)*10)))
                    {
                        System.out.println("NUM OF ROW:"+rs.getRow());
                        rs.afterLast();  
                    }
                    else
                    {
                        dataInput[c] = rs.getDouble(2)/1000;
                        System.out.println("IN:"+rs.getDouble(2)/1000);
                        c++;
                        
                    }
                    
                }
                
                // create new perceptron network
                NeuralNetwork neuralNetwork = new Perceptron(10, 1);
                
                
                //create training set
                TrainingSet<SupervisedTrainingElement> trainingSet = 
                          new TrainingSet<SupervisedTrainingElement>(10, 1);
                    
                int bla = 0;    
                for(int x=0;x<inputData.size();x++)
                {
                    trainingSet.addElement(new SupervisedTrainingElement(inputData.get(x),outputData.get(x)));  
                    bla = x;
                }
                System.out.println("LEARN NETWORK");
                neuralNetwork.learn(trainingSet);
               
                
                neuralNetwork.setInput(inputData.get(bla-1));
                neuralNetwork.calculate();
                
                System.out.println("OUT:"+neuralNetwork.getOutput().toString());
            }
    

    Example how the data looks like:

    IN:0.029
    IN:0.02911000061035156
    IN:0.02809000015258789
    IN:0.02825
    IN:0.030719999313354493
    IN:0.030809999465942383
    IN:0.030969999313354493
    IN:0.031469999313354494
    IN:0.032169998168945314
    IN:0.03172999954223633
    Out:0.031469999313354494
    IN:0.031469999313354494
    IN:0.031200000762939453
    IN:0.030770000457763673
    IN:0.031100000381469727
    IN:0.03136000061035156
    IN:0.03222999954223633
    IN:0.033099998474121095
    IN:0.032060001373291014
    IN:0.03304999923706055
    IN:0.031840000152587894
    Out:0.03160000038146973
    IN:0.03160000038146973
    IN:0.03190999984741211
    IN:0.03140999984741211
    IN:0.030010000228881836
    IN:0.028290000915527344
    IN:0.027270000457763673
    IN:0.027399999618530273
    IN:0.027010000228881836
    IN:0.027100000381469726
    IN:0.026309999465942382
    Out:0.026809999465942383
    
     
  • Valentin Steinhauer

    and the perceptron will be used for the logical prediction. You need the multilayer perceptron.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks