Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/13/09 17:28:07 (15 years ago)
Author:
gkronber
Message:

Worked on #722 (IModel should provide a Predict() method to get predicted values for an input vector).
At the same time removed parameter PunishmentFactor from GP algorithms (this parameter is internal to TreeEvaluators now).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs

    r2223 r2285  
    2727using System.Globalization;
    2828using System.Text;
     29using System.Linq;
    2930
    3031namespace HeuristicLab.DataAnalysis {
     
    7879      get { return scalingOffset; }
    7980      set {
    80         if (value.Length != scalingOffset.Length) 
     81        if (value.Length != scalingOffset.Length)
    8182          throw new ArgumentException("Length of scaling offset array doesn't match number of variables");
    82         scalingOffset = value; }
     83        scalingOffset = value;
     84      }
    8385    }
    8486
     
    98100      get { return samples; }
    99101      set {
     102        variableNames = Enumerable.Range(1, columns).Select(x => "Var" + x.ToString("###")).ToArray();
    100103        scalingFactor = new double[columns];
    101104        scalingOffset = new double[columns];
     
    115118    }
    116119
    117     public Dataset() {
     120    public Dataset()
     121      : this(new double[,] { { 0.0 } }) {
     122    }
     123
     124    public Dataset(double[,] samples) {
    118125      Name = "-";
    119       variableNames = new string[] { "Var0" };
    120       Columns = 1;
    121       Rows = 1;
    122       Samples = new double[1];
    123       scalingOffset = new double[] { 0.0 };
    124       scalingFactor = new double[] { 1.0 };
    125       cachedValuesInvalidated = true;
     126      Rows = samples.GetLength(0);
     127      Columns = samples.GetLength(1);
     128      double[] values = new double[Rows * Columns];
     129      int i = 0;
     130      for (int row = 0; row < Rows; row++) {
     131        for (int column = 0; column < columns; column++) {
     132          values[i++] = samples[row, column];
     133        }
     134      }
     135      Samples = values;
    126136      fireChangeEvents = true;
    127137    }
    128138
    129    
    130139
    131140    public string GetVariableName(int variableIndex) {
Note: See TracChangeset for help on using the changeset viewer.