Loading ...
Sorry, an error occurred while loading the content.
 

Re: Example of Training based on a DataSet

Expand Messages
  • gotnobluemilk
    Well, I didn t expect much reponse since the other posts about this subject received no reponses. Anyway, he is the approach I took. I just put the needed
    Message 1 of 4 , Feb 4, 2012
      Well, I didn't expect much reponse since the other posts about this subject received no reponses. Anyway, he is the approach I took. I just put the needed changes in the Evaluate function:

      public FitnessInfo Evaluate(IBlackBox box)
      {
      double fitness = 0;

      foreach (DataRow dr in dtTrain.Rows)
      {
      // Make decision
      MakeDecision(dr);
      if (!brainTrain.Brain.IsStateValid)
      return FitnessInfo.Zero;

      // Update the fitness score of the network
      fitness += getScore();
      }

      // Update the evaluation counter.
      _evalCount++;

      // Return the fitness score
      return new FitnessInfo(Math.Max(0, fitness), Math.Max(0, fitness));
      }

      --- In neat@yahoogroups.com, "gotnobluemilk" <gotnobluemilk@...> wrote:
      >
      > I'm using SharpNeat V2 and doing my first experiment. Lot's to learn trying to understand both the concept and the software.
      >
      > All of the experiments I have seen deal with robots of some sort. I'm looking for an experiment based on training off of a data set. For example, I have 5,000 cases in an XML DataSet, I want to use 6 inputs, predict two outputs. I would run through all 5,000 cases as one generation of the training and base my fitness off of how accurately it predicted the correct output for the 5,000 cases.
      >
      > If anyone is aware of an experiment or posting that would point me in the right direction I would appreciate it.
      >
      > Thanks.
      >
    • gotnobluemilk
      I probably should have elaborated on MakeDecision(). public void MakeDecision(DataRow dr) { // Clear the network box.ResetState(); // Reset all inputs.
      Message 2 of 4 , Feb 4, 2012
        I probably should have elaborated on MakeDecision().

        public void MakeDecision(DataRow dr)
        {
        // Clear the network
        box.ResetState();

        // Reset all inputs.
        inputArr.Reset();
        // set all inputs.
        for (Int32 j = 0; j < box.InputCount; j++)
        {
        box.InputSignalArray[0] = Convert.ToDouble(dr[j]);
        }

        // Activate the network
        box.Activate();

        }


        --- In neat@yahoogroups.com, "gotnobluemilk" <gotnobluemilk@...> wrote:
        >
        > Well, I didn't expect much reponse since the other posts about this subject received no reponses. Anyway, he is the approach I took. I just put the needed changes in the Evaluate function:
        >
        > public FitnessInfo Evaluate(IBlackBox box)
        > {
        > double fitness = 0;
        >
        > foreach (DataRow dr in dtTrain.Rows)
        > {
        > // Make decision
        > MakeDecision(dr);
        > if (!brainTrain.Brain.IsStateValid)
        > return FitnessInfo.Zero;
        >
        > // Update the fitness score of the network
        > fitness += getScore();
        > }
        >
        > // Update the evaluation counter.
        > _evalCount++;
        >
        > // Return the fitness score
        > return new FitnessInfo(Math.Max(0, fitness), Math.Max(0, fitness));
        > }
        >
        > --- In neat@yahoogroups.com, "gotnobluemilk" <gotnobluemilk@> wrote:
        > >
        > > I'm using SharpNeat V2 and doing my first experiment. Lot's to learn trying to understand both the concept and the software.
        > >
        > > All of the experiments I have seen deal with robots of some sort. I'm looking for an experiment based on training off of a data set. For example, I have 5,000 cases in an XML DataSet, I want to use 6 inputs, predict two outputs. I would run through all 5,000 cases as one generation of the training and base my fitness off of how accurately it predicted the correct output for the 5,000 cases.
        > >
        > > If anyone is aware of an experiment or posting that would point me in the right direction I would appreciate it.
        > >
        > > Thanks.
        > >
        >
      • gotnobluemilk
        Major bug in my code when setting input array values: for (Int32 j = 0; j
        Message 3 of 4 , Feb 13, 2012

          Major bug in my code when setting input array values:

              for (Int32 j = 0; j < box.InputCount; j++)
              {
              box.InputSignalArray[0] = Convert.ToDouble(dr[j]);
              }

          should be

              for (Int32 j = 0; j < box.InputCount; j++)
              {
              box.InputSignalArray[j] = Convert.ToDouble(dr[j]);
              }

          So if you are following my example, fix the bug.  The bug leads to a complete lack of convergence.


          --- In neat@yahoogroups.com, "gotnobluemilk" <gotnobluemilk@...> wrote:
          >
          > I probably should have elaborated on MakeDecision().
          >
          > public void MakeDecision(DataRow dr)
          > {
          > // Clear the network
          > box.ResetState();
          >
          > // Reset all inputs.
          > inputArr.Reset();
          > // set all inputs.
          > for (Int32 j = 0; j < box.InputCount; j++)
          > {
          > box.InputSignalArray[0] = Convert.ToDouble(dr[j]);
          > }
          >
          > // Activate the network
          > box.Activate();
          >
          > }
          >
          >
          > --- In neat@yahoogroups.com, "gotnobluemilk" gotnobluemilk@ wrote:
          > >
          > > Well, I didn't expect much reponse since the other posts about this subject received no reponses. Anyway, he is the approach I took. I just put the needed changes in the Evaluate function:
          > >
          > > public FitnessInfo Evaluate(IBlackBox box)
          > > {
          > > double fitness = 0;
          > >
          > > foreach (DataRow dr in dtTrain.Rows)
          > > {
          > > // Make decision
          > > MakeDecision(dr);
          > > if (!brainTrain.Brain.IsStateValid)
          > > return FitnessInfo.Zero;
          > >
          > > // Update the fitness score of the network
          > > fitness += getScore();
          > > }
          > >
          > > // Update the evaluation counter.
          > > _evalCount++;
          > >
          > > // Return the fitness score
          > > return new FitnessInfo(Math.Max(0, fitness), Math.Max(0, fitness));
          > > }
          > >
          > > --- In neat@yahoogroups.com, "gotnobluemilk" <gotnobluemilk@> wrote:
          > > >
          > > > I'm using SharpNeat V2 and doing my first experiment. Lot's to learn trying to understand both the concept and the software.
          > > >
          > > > All of the experiments I have seen deal with robots of some sort. I'm looking for an experiment based on training off of a data set. For example, I have 5,000 cases in an XML DataSet, I want to use 6 inputs, predict two outputs. I would run through all 5,000 cases as one generation of the training and base my fitness off of how accurately it predicted the correct output for the 5,000 cases.
          > > >
          > > > If anyone is aware of an experiment or posting that would point me in the right direction I would appreciate it.
          > > >
          > > > Thanks.
          > > >
          > >
          >

        Your message has been successfully submitted and would be delivered to recipients shortly.