Changeset 14259 for branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
- Timestamp:
- 08/17/16 16:20:08 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r14185 r14259 28 28 using HeuristicLab.Core; 29 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HeuristicLab.Optimization.Operators; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 32 … … 71 72 } 72 73 74 73 75 public string Format(ISymbolicExpressionTree symbolicExpressionTree, IDataset dataset) { 74 76 var stringBuilder = new StringBuilder(); … … 88 90 int columnIndex = 0; 89 91 int inputIndex = 0; 90 var usedVariables = tree.IterateNodesPrefix().OfType< VariableTreeNode>().Select(v => v.VariableName).Distinct();92 var usedVariables = tree.IterateNodesPrefix().OfType<IVariableTreeNode>().Select(v => v.VariableName).Distinct(); 91 93 foreach (var variable in dataset.VariableNames) { 92 94 columnIndex++; … … 190 192 stringBuilder.Append(variableTreeNode.Weight.ToString(CultureInfo.InvariantCulture)); 191 193 stringBuilder.Append("*"); 192 stringBuilder.Append(GetColumnToVariableName(variableTreeNode.VariableName));// + LagToString(currentLag)); 194 stringBuilder.Append(GetColumnToVariableName(variableTreeNode.VariableName)); // + LagToString(currentLag)); 195 } else if (symbol is BinaryFactorVariable) { 196 var binFactorNode = node as BinaryFactorVariableTreeNode; 197 stringBuilder.AppendFormat("IF({0}=\"{1}\", {2}, 0)", 198 GetColumnToVariableName(binFactorNode.VariableName), 199 binFactorNode.VariableValue, 200 binFactorNode.Weight.ToString(CultureInfo.InvariantCulture) 201 ); 202 } else if (symbol is FactorVariable) { 203 var factorNode = node as FactorVariableTreeNode; 204 var values = factorNode.Symbol.GetVariableValues(factorNode.VariableName).ToArray(); 205 var w = factorNode.Weights; 206 // create nested if 207 for (int i = 0; i < values.Length; i++) { 208 stringBuilder.AppendFormat("IF({0}=\"{1}\", {2}, ", 209 GetColumnToVariableName(factorNode.VariableName), 210 values[i], 211 w[i].ToString(CultureInfo.InvariantCulture)); 212 } 213 stringBuilder.Append("\"\""); // return empty string on unknown value 214 stringBuilder.Append(')', values.Length); // add closing parenthesis 193 215 } else if (symbol is Power) { 194 216 stringBuilder.Append("POWER(");
Note: See TracChangeset
for help on using the changeset viewer.