在Encog中对MLData进行非规范化

时间:2015-11-05 07:16:21

标签: encog

我使用以下代码对一组数据进行了规范化:

public static void main(String[] args) {

//To Normalize the data
    File sourcefiletotrain=new File("E:\\Shreyas-Internship\\RforLF\\dataforAnn.csv");
    File targetfiletotrain=new File("E:\\Shreyas-Internship\\RforLF\\ideal.csv");
    EncogAnalyst analyst=new EncogAnalyst();
    AnalystWizard wizard=new AnalystWizard(analyst);
    wizard.setGoal(AnalystGoal.Regression);
    wizard.wizard(sourcefiletotrain, false,AnalystFileFormat.DECPNT_COMMA);
    final AnalystNormalizeCSV norm=new AnalystNormalizeCSV();
    norm.analyze(sourcefiletotrain, false, ENGLISH, analyst);
    norm.normalize(targetfiletotrain);

然后我使用以下数据来训练和运行使用Encog的神经网络。我面临的问题是我无法将值反规范化为实际形式。培训和运行神经网络的代码是:

  //To Train the Neural Network
    CSVNeuralDataSet fileread=new CSVNeuralDataSet("E:\\Shreyas-Internship\\RforLF\\ideal.csv",4,1,true);
    BasicNetwork network=new BasicNetwork();
    network.addLayer(new BasicLayer(4));
    network.addLayer(new BasicLayer(20));
    network.addLayer(new BasicLayer(1));
    network.getStructure().finalizeStructure();
    network.reset();
    MLDataSet trainingset=new BasicMLDataSet(fileread);
    MLTrain train= new ResilientPropagation(network,trainingset);
    int epoch=1;
    do{

        train.iteration();
        System.out.println("Epoch " +epoch+ " Error:" +train.getError());
        epoch++;
       }while((train.getError()>0.01)&&(epoch<=500));



    //To run the Neural Network
    System.out.println("Neural Network Results");
    for (MLDataPair pair: trainingset){  
        final MLData output=network.compute(pair.getInput());  
        System.out.println("actual="+output.getData(0)+  "\tideal="+pair.getIdeal().getData(0));//pair.getInput().getData(0)+" ,"+pair.getInput().getData(1)+" ,"+pair.getInput().getData(2)+" ,"+pair.getInput().getData(3)+" ,"+pair.getInput().getData(4)+" ,"+pair.getInput().getData(5)+


    }


}

怀疑是如何进一步获得MLData的非规格化输出

1 个答案:

答案 0 :(得分:0)

您可以使用encog NormalizedField class:

def denormalize(double high, double low, double normalizedValue){
    NormalizedField normalizedField = new NormalizedField(high, low)
    normalizedField.deNormalize(normalizedValue)
}

其中是用于标准化的范围。