Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 13:54:57 (13 years ago)
Author:
spimming
Message:

#1680:

  • merged changes from trunk into branch

' removed pre-build event for multiple app.configs

Location:
branches/HeuristicLab.Hive.Azure
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r6636 r7215  
    278278            int testEnd = (i + 1) == Folds.Value ? SamplesEnd.Value : (i + 1) * testSamplesCount + SamplesStart.Value;
    279279
     280            problem.ProblemData.TrainingPartition.Start = SamplesStart.Value;
     281            problem.ProblemData.TrainingPartition.End = SamplesEnd.Value;
    280282            problem.ProblemData.TestPartition.Start = testStart;
    281283            problem.ProblemData.TestPartition.End = testEnd;
     
    515517        throw new InvalidOperationException("Can not change number of folds if the execution state is not prepared.");
    516518    }
     519
     520    private bool samplesChanged = false;
    517521    private void SamplesStart_ValueChanged(object sender, EventArgs e) {
     522      samplesChanged = true;
    518523      if (Problem != null) Problem.ProblemData.TrainingPartition.Start = SamplesStart.Value;
     524      samplesChanged = false;
    519525    }
    520526    private void SamplesEnd_ValueChanged(object sender, EventArgs e) {
     527      samplesChanged = true;
    521528      if (Problem != null) Problem.ProblemData.TrainingPartition.End = SamplesEnd.Value;
     529      samplesChanged = false;
    522530    }
    523531
     
    543551        throw new ArgumentException("A cross validation algorithm can only contain DataAnalysisProblems.");
    544552      }
    545       algorithm.Problem.Reset += (x,y) => OnProblemChanged();
     553      algorithm.Problem.Reset += (x, y) => OnProblemChanged();
    546554      problem = (IDataAnalysisProblem)algorithm.Problem;
    547555      OnProblemChanged();
     
    551559      EventHandler handler = ProblemChanged;
    552560      if (handler != null) handler(this, EventArgs.Empty);
     561      if (samplesChanged) return;
    553562
    554563      SamplesStart.Value = 0;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r6866 r7215  
    103103    <Reference Include="ALGLIB-3.1.0, Version=3.1.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    104104      <HintPath>..\..\bin\ALGLIB-3.1.0.dll</HintPath>
     105      <Private>False</Private>
    105106    </Reference>
    106107    <Reference Include="LibSVM-1.6.3, Version=1.6.3.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    107108      <HintPath>..\..\bin\LibSVM-1.6.3.dll</HintPath>
     109      <Private>False</Private>
    108110    </Reference>
    109111    <Reference Include="System" />
     
    142144    </Compile>
    143145    <Compile Include="Linear\AlglibUtil.cs" />
    144     <Compile Include="Linear\LinearTimeSeriesPrognosis.cs" />
    145146    <Compile Include="Linear\LinearDiscriminantAnalysis.cs" />
    146147    <Compile Include="Linear\LinearRegression.cs">
     
    246247      <Private>False</Private>
    247248    </ProjectReference>
    248     <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.csproj">
    249       <Project>{07486E68-1517-4B9D-A58D-A38E99AE71AB}</Project>
    250       <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4</Name>
    251       <Private>False</Private>
    252     </ProjectReference>
    253249    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
    254250      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/AlglibUtil.cs

    r6802 r7215  
    2727  public static class AlglibUtil {
    2828    public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) {
    29       return PrepareInputMatrix(dataset, variables, rows, new int[] { 0 });
    30     }
     29      List<string> variablesList = variables.ToList();
     30      List<int> rowsList = rows.ToList();
    3131
    32     public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows, IEnumerable<int> lags) {
    33       int maxLag = lags.Max();
    34 
    35       // drop last variable (target variable)
    36       List<string> inputVariablesList = variables
    37         .Reverse()
    38         .Skip(1)
    39         .Reverse()
    40         .ToList();
    41       string targetVariable = variables.Last();
    42       List<int> rowsList = rows.ToList();
    43       int nRows = rowsList.Count - maxLag;
    44       double[,] matrix = new double[nRows, inputVariablesList.Count * lags.Count() + 1];
     32      double[,] matrix = new double[rowsList.Count, variablesList.Count];
    4533
    4634      int col = 0;
    47       int row = 0;
    48       // input variables
    49       foreach (int lag in lags) {
    50         foreach (string column in inputVariablesList) {
    51           var values = dataset.GetDoubleValues(column, rows.Select(x => x - lag).Take(nRows));
    52           row = 0;
    53           foreach (var value in values) {
    54             if (row >= 0) {
    55               matrix[row, col] = value;
    56             }
    57             row++;
    58           }
    59           col++;
     35      foreach (string column in variables) {
     36        var values = dataset.GetDoubleValues(column, rows);
     37        int row = 0;
     38        foreach (var value in values) {
     39          matrix[row, col] = value;
     40          row++;
    6041        }
     42        col++;
    6143      }
    62       // target variable
    63       row = 0;
    64       foreach (var value in dataset.GetDoubleValues(targetVariable, rows).Take(nRows)) {
    65         matrix[row, col] = value;
    66         row++;
    67       }
     44
    6845      return matrix;
    6946    }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassificationSolution.cs

    r6589 r7215  
    5151      return new NeuralNetworkClassificationSolution(this, cloner);
    5252    }
    53 
    5453    protected override void RecalculateResults() {
    5554      CalculateResults();
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame

    r6866 r7215  
    4242  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Classification", "3.4")]
    4343  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
    44   [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis", "3.4")]
    4544  public class HeuristicLabAlgorithmsDataAnalysisPlugin : PluginBase {
    4645  }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs

    r6604 r7215  
    9898      this.targetVariable = original.targetVariable;
    9999      this.allowedInputVariables = (string[])original.allowedInputVariables.Clone();
    100       foreach (var dataset in original.cachedPredictions.Keys) {
    101         this.cachedPredictions.Add(cloner.Clone(dataset), (double[])original.cachedPredictions[dataset].Clone());
    102       }
    103100      if (original.classValues != null)
    104101        this.classValues = (double[])original.classValues.Clone();
     
    162159    }
    163160    #endregion
    164     // cache for predictions, which is cloned but not persisted, must be cleared when the model is changed
    165     private Dictionary<Dataset, double[]> cachedPredictions = new Dictionary<Dataset, double[]>();
    166161    private IEnumerable<double> GetEstimatedValuesHelper(Dataset dataset, IEnumerable<int> rows) {
    167       if (!cachedPredictions.ContainsKey(dataset)) {
    168         // create an array of cached predictions which is initially filled with NaNs
    169         double[] predictions = Enumerable.Repeat(double.NaN, dataset.Rows).ToArray();
    170         CalculatePredictions(dataset, rows, predictions);
    171         cachedPredictions.Add(dataset, predictions);
    172       }
    173       // get the array of predictions and select the subset of requested rows
    174       double[] p = cachedPredictions[dataset];
    175       var requestedPredictions = from r in rows
    176                                  select p[r];
    177       // check if the requested predictions contain NaNs
    178       // (this means for the request rows some predictions have not been cached)
    179       if (requestedPredictions.Any(x => double.IsNaN(x))) {
    180         // updated the predictions for currently requested rows
    181         CalculatePredictions(dataset, rows, p);
    182         cachedPredictions[dataset] = p;
    183         // now we can be sure that for the current rows all predictions are available
    184         return from r in rows
    185                select p[r];
    186       } else {
    187         // there were no NaNs => just return the cached predictions
    188         return requestedPredictions;
    189       }
    190     }
    191 
    192     private void CalculatePredictions(Dataset dataset, IEnumerable<int> rows, double[] predictions) {
    193       // calculate and cache predictions for the currently requested rows
     162      // calculate predictions for the currently requested rows
    194163      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows);
    195164      SVM.Problem scaledProblem = Scaling.Scale(RangeTransform, problem);
    196165
    197       // row is the index in the original dataset,
    198       // i is the index in the scaled dataset (containing only the necessary rows)
    199       int i = 0;
    200       foreach (var row in rows) {
    201         predictions[row] = SVM.Prediction.Predict(Model, scaledProblem.X[i]);
    202         i++;
     166      for (int i = 0; i < scaledProblem.Count; i++) {
     167        yield return SVM.Prediction.Predict(Model, scaledProblem.X[i]);
    203168      }
    204169    }
     
    207172    public event EventHandler Changed;
    208173    private void OnChanged(EventArgs e) {
    209       cachedPredictions.Clear();
    210174      var handlers = Changed;
    211175      if (handlers != null)
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs

    r6802 r7215  
    143143      parameter.Probability = false;
    144144
     145
    145146      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows);
    146147      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
Note: See TracChangeset for help on using the changeset viewer.