4 Replies - 1325 Views - Last Post: 08 May 2012 - 08:38 AM Rate Topic: -----

#1 mhaider2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-May 12

How to compare input with the data from text file and capture it?

Posted 07 May 2012 - 10:35 PM

Hi guys,

I'm new to java and currently trying to implement generalized regression neural network (grnn) in java. I need an opinion on how to comparing input with training data from text file.

this is the basic code/algorithm that i use right now:
public class Grnn {


public static void main(String[] args) 
{

// Check LSA, CM and CUT and compare to LSA, CM and CUT in training data,
// Capture Target Output values = TargetOutput


int LSA_Training_Data = 0.8;
int CM_Training_Data = 77;
int CUT_Training_Data = 65;

int LSA = 0.6;
int CM = 76;
int CUT = 64;

int dif1 = LSA_Training_Data - LSA;
int dif2 = CM_Training_Data - CM;
int dif3 = CUT_Training_Data - CUT;

int NoOfNeuron = 3;
int TargetOutput = 75;
double numenator = (((TargetOutput * Math.pow(NoOfNeuron,dif1)) + (TargetOutput * Math.pow(NoOfNeuron,dif2)) + (TargetOutput * Math.pow(NoOfNeuron,dif3))));
double denumenator = (Math.pow(NoOfNeuron,dif1)+ Math.pow(NoOfNeuron,dif2)+ Math.pow(NoOfNeuron,dif3));
double holdtime = (numenator / denumenator);

System.out.println ("hold time is " + holdtime);

System.out.println ("exponent a " + (TargetOutput * Math.pow(NoOfNeuron,dif1))); 
System.out.println ("exponent b " + (TargetOutput * Math.pow(NoOfNeuron,dif2)));
System.out.println ("exponent c " + (TargetOutput * Math.pow(NoOfNeuron,dif3)));



}
}




This is the example of training data that i put in text file.

LSA CM CUT Target Output
60 1 1 0.1
55 1 1 0.1
60 33 17 0.2
55 33 17 0.3
60 77 65 47
55 77 65 49
0.8 77 65 75
0.8 81 65 76
0.7 81 65 78


How am i going to compare my input (LSA, CM, CUT) with training data (LSA_Training_Data,CM_Training_Data,CUT_Training_D ata) that i put in text file and also capture the Target Output?

The other problem is how am i going to capture the nearest Training Data in file?

The input does not always the same with the data in text file. For example the input is can be 0.6(LSA), 76(CM) and 64(CUT) and if you refer to the training data above the nearest value is 0.8,77,65 where the target output is 75.

The use of GRNN is to predict the value of output (hold time) based on this three input (0.6, 76, 64). The way GRNN works can be seen in the code.

As you can see, i manually input the value of LSA, CM, CUT, LSA_Training_Data,CM_Training_Data,CUT_Training_Data and Target Output but i need to get this data (LSA_Training_Data,CM_Training_Data,CUT_Training_Data and Target Output) from text file based from the input (LSA, CM, CUT) that i provide.

Your opinion is very, very much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: How to compare input with the data from text file and capture it?

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: How to compare input with the data from text file and capture it?

Posted 07 May 2012 - 10:44 PM

Really really strange code :)
Do you know what is a int an what is a double ?

int LSA_Training_Data = 0.8;    // so LSA_Training == 0
int CM_Training_Data = 77;
int CUT_Training_Data = 65;

int LSA = 0.6;                  // so LSA == 0
int CM = 76;
int CUT = 64;

int dif1 = LSA_Training_Data - LSA;   // so dif1 == 0
int dif2 = CM_Training_Data - CM;     // so dif2 == 1
int dif3 = CUT_Training_Data - CUT;   // so dif3 == 1



Was This Post Helpful? 0
  • +
  • -

#3 mhaider2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-May 12

Re: How to compare input with the data from text file and capture it?

Posted 07 May 2012 - 10:49 PM

yeah..sorry about that..before this i used different values..so this is the updated one..

public class Grnn {


   public static void main(String[] args) 
   {
    
    // Check LSA, CM and CUT and compare to LSA, CM and CUT in training data,
    // Capture Target Output values = TargetOutput
      
       
    double LSA_Training_Data = 0.8;
    int CM_Training_Data = 77;
    int CUT_Training_Data = 65;
    
    double LSA = 0.6;
    int CM = 76;
    int CUT = 64;
    
    double dif1 = LSA_Training_Data - LSA;
    int dif2 = CM_Training_Data - CM;
    int dif3 = CUT_Training_Data - CUT;
     
    int NoOfNeuron = 3;
    int TargetOutput = 75;
    double numenator = (((TargetOutput * Math.pow(NoOfNeuron,dif1)) + (TargetOutput * Math.pow(NoOfNeuron,dif2)) + (TargetOutput * Math.pow(NoOfNeuron,dif3))));
    double denumenator = (Math.pow(NoOfNeuron,dif1)+ Math.pow(NoOfNeuron,dif2)+ Math.pow(NoOfNeuron,dif3));
    double holdtime = (numenator / denumenator);
    
    System.out.println ("hold time is " + holdtime);
    
    System.out.println ("exponent a " + (TargetOutput * Math.pow(NoOfNeuron,dif1)));
    System.out.println ("exponent b " + (TargetOutput * Math.pow(NoOfNeuron,dif2)));
    System.out.println ("exponent c " + (TargetOutput * Math.pow(NoOfNeuron,dif3)));
    
    

    }
}

Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: How to compare input with the data from text file and capture it?

Posted 07 May 2012 - 10:51 PM

Why don't you put everything double ? Especially that you use them into Math.pow() that expects double anyhow.
Was This Post Helpful? 0
  • +
  • -

#5 mhaider2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-May 12

Re: How to compare input with the data from text file and capture it?

Posted 08 May 2012 - 08:38 AM

Yeah, maybe i should, but i dont think it will effect my output since the CM and CUT input is in integer. Thanks for the sugesstion though. Do you have any opinion on how can i solve my main problem regarding read, compare and capture data from text file? I already seen some example on read part but still blur on compare and capturing data.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1