- Timestamp:
- 07/06/17 10:19:37 (7 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs
r15061 r15131 74 74 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; 75 75 IEnumerable<int> rows = problemData.TrainingIndices; 76 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables.Concat(new string[] { targetVariable }), rows); 76 var doubleVariables = allowedInputVariables.Where(dataset.VariableHasType<double>); 77 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); 81 var inputMatrix = binaryMatrix.HorzCat(doubleVarMatrix); 82 77 83 if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x))) 78 84 throw new NotSupportedException("Linear regression does not support NaN or infinity values in the input dataset."); … … 99 105 100 106 int col = 0; 101 foreach (string column in allowedInputVariables) { 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) { 102 120 VariableTreeNode vNode = (VariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable().CreateTreeNode(); 103 121 vNode.VariableName = column;
Note: See TracChangeset
for help on using the changeset viewer.