Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/17 11:12:18 (7 years ago)
Author:
gkronber
Message:

#2697: merged r14843 (resolving conflicts in csproj file for HL.Algorithms.DataAnalysis because MCTS has been removed)

Location:
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs

    r15131 r15142  
    7373      var doubleVariableNames = allowedInputVariables.Where(dataset.VariableHasType<double>).ToArray();
    7474      var factorVariableNames = allowedInputVariables.Where(dataset.VariableHasType<string>).ToArray();
    75       double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, doubleVariableNames.Concat(new string[] { targetVariable }), rows);
     75      double[,] inputMatrix = dataset.ToArray(doubleVariableNames.Concat(new string[] { targetVariable }), rows);
    7676
    77       var factorVariables = AlglibUtil.GetFactorVariableValues(dataset, factorVariableNames, rows);
    78       double[,] factorMatrix = AlglibUtil.PrepareInputMatrix(dataset, factorVariables, rows);
     77      var factorVariables = dataset.GetFactorVariableValues(factorVariableNames, rows);
     78      var factorMatrix = dataset.ToArray(factorVariables, rows);
    7979
    8080      inputMatrix = factorMatrix.HorzCat(inputMatrix);
     
    9494      if (info < 1) throw new ArgumentException("Error in calculation of linear discriminant analysis solution");
    9595
    96       ISymbolicExpressionTree tree = new SymbolicExpressionTree(new ProgramRootSymbol().CreateTreeNode());
    97       ISymbolicExpressionTreeNode startNode = new StartSymbol().CreateTreeNode();
    98       tree.Root.AddSubtree(startNode);
    99       ISymbolicExpressionTreeNode addition = new Addition().CreateTreeNode();
    100       startNode.AddSubtree(addition);
    101 
    102       int col = 0;
    103       foreach (var kvp in factorVariables) {
    104         var varName = kvp.Key;
    105         foreach (var cat in kvp.Value) {
    106           BinaryFactorVariableTreeNode vNode =
    107             (BinaryFactorVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.BinaryFactorVariable().CreateTreeNode();
    108           vNode.VariableName = varName;
    109           vNode.VariableValue = cat;
    110           vNode.Weight = w[col];
    111           addition.AddSubtree(vNode);
    112           col++;
    113         }
    114       }
    115       foreach (string column in doubleVariableNames) {
    116         VariableTreeNode vNode = (VariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable().CreateTreeNode();
    117         vNode.VariableName = column;
    118         vNode.Weight = w[col];
    119         addition.AddSubtree(vNode);
    120         col++;
    121       }
     96      var nFactorCoeff = factorMatrix.GetLength(1);
     97      var tree = LinearModelToTreeConverter.CreateTree(factorVariables, w.Take(nFactorCoeff).ToArray(),
     98        doubleVariableNames, w.Skip(nFactorCoeff).Take(doubleVariableNames.Length).ToArray());
    12299
    123100      var model = CreateDiscriminantFunctionModel(tree, new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), problemData, rows);
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs

    r15131 r15142  
    7676      var doubleVariables = allowedInputVariables.Where(dataset.VariableHasType<double>);
    7777      var factorVariableNames = allowedInputVariables.Where(dataset.VariableHasType<string>);
    78       var factorVariables = AlglibUtil.GetFactorVariableValues(dataset, factorVariableNames, rows);
    79       double[,] binaryMatrix = AlglibUtil.PrepareInputMatrix(dataset, factorVariables, rows);
    80       double[,] doubleVarMatrix = AlglibUtil.PrepareInputMatrix(dataset, doubleVariables.Concat(new string[] { targetVariable }), rows);
     78      var factorVariables = dataset.GetFactorVariableValues(factorVariableNames, rows);
     79      double[,] binaryMatrix = dataset.ToArray(factorVariables, rows);
     80      double[,] doubleVarMatrix = dataset.ToArray(doubleVariables.Concat(new string[] { targetVariable }), rows);
    8181      var inputMatrix = binaryMatrix.HorzCat(doubleVarMatrix);
    8282
     
    9898      alglib.lrunpack(lm, out coefficients, out nFeatures);
    9999
    100       ISymbolicExpressionTree tree = new SymbolicExpressionTree(new ProgramRootSymbol().CreateTreeNode());
    101       ISymbolicExpressionTreeNode startNode = new StartSymbol().CreateTreeNode();
    102       tree.Root.AddSubtree(startNode);
    103       ISymbolicExpressionTreeNode addition = new Addition().CreateTreeNode();
    104       startNode.AddSubtree(addition);
    105 
    106       int col = 0;
    107       foreach (var kvp in factorVariables) {
    108         var varName = kvp.Key;
    109         foreach (var cat in kvp.Value) {
    110           BinaryFactorVariableTreeNode vNode =
    111             (BinaryFactorVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.BinaryFactorVariable().CreateTreeNode();
    112           vNode.VariableName = varName;
    113           vNode.VariableValue = cat;
    114           vNode.Weight = coefficients[col];
    115           addition.AddSubtree(vNode);
    116           col++;
    117         }
    118       }
    119       foreach (string column in doubleVariables) {
    120         VariableTreeNode vNode = (VariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable().CreateTreeNode();
    121         vNode.VariableName = column;
    122         vNode.Weight = coefficients[col];
    123         addition.AddSubtree(vNode);
    124         col++;
    125       }
    126 
    127       ConstantTreeNode cNode = (ConstantTreeNode)new Constant().CreateTreeNode();
    128       cNode.Value = coefficients[coefficients.Length - 1];
    129       addition.AddSubtree(cNode);
    130 
     100      int nFactorCoeff = binaryMatrix.GetLength(1);
     101      int nVarCoeff = doubleVariables.Count();
     102      var tree = LinearModelToTreeConverter.CreateTree(factorVariables, coefficients.Take(nFactorCoeff).ToArray(),
     103        doubleVariables.ToArray(), coefficients.Skip(nFactorCoeff).Take(nVarCoeff).ToArray(),
     104        @const: coefficients[nFeatures]);
     105     
    131106      SymbolicRegressionSolution solution = new SymbolicRegressionSolution(new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeLinearInterpreter()), (IRegressionProblemData)problemData.Clone());
    132107      solution.Model.Name = "Linear Regression Model";
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs

    r15131 r15142  
    7272      var factorVariableNames = problemData.AllowedInputVariables.Where(dataset.VariableHasType<string>);
    7373      IEnumerable<int> rows = problemData.TrainingIndices;
    74       double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, doubleVariableNames.Concat(new string[] { targetVariable }), rows);
     74      double[,] inputMatrix = dataset.ToArray(doubleVariableNames.Concat(new string[] { targetVariable }), rows);
    7575
    76       var factorVariableValues = AlglibUtil.GetFactorVariableValues(dataset, factorVariableNames, rows);
    77       var factorMatrix = AlglibUtil.PrepareInputMatrix(dataset, factorVariableValues, rows);
     76      var factorVariableValues = dataset.GetFactorVariableValues(factorVariableNames, rows);
     77      var factorMatrix = dataset.ToArray(factorVariableValues, rows);
    7878      inputMatrix = factorMatrix.HorzCat(inputMatrix);
    7979
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitModel.cs

    r15131 r15142  
    9797    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    9898
    99       double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows);
    100       double[,] factorData = AlglibUtil.PrepareInputMatrix(dataset, factorVariables, rows);
     99      double[,] inputData = dataset.ToArray(allowedInputVariables, rows);
     100      double[,] factorData = dataset.ToArray(factorVariables, rows);
    101101
    102102      inputData = factorData.HorzCat(inputData);
  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/Scaling.cs

    r14186 r15142  
    2929
    3030namespace HeuristicLab.Algorithms.DataAnalysis {
     31  [Obsolete("Use transformation classes in Problems.DataAnalysis instead")]
    3132  [StorableClass]
    3233  [Item(Name = "Scaling", Description = "Contains information about scaling of variables for data-analysis algorithms.")]
Note: See TracChangeset for help on using the changeset viewer.