Changeset 15104
- Timestamp:
- 07/01/17 08:48:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r14843 r15104 78 78 } 79 79 80 public string FormatWithMapping(ISymbolicExpressionTree symbolicExpressionTree, Dictionary<string,string> variableNameMapping) 81 { 82 foreach(var kvp in variableNameMapping) this.variableNameMapping.Add(kvp.Key,kvp.Value); 80 public string FormatWithMapping(ISymbolicExpressionTree symbolicExpressionTree, Dictionary<string, string> variableNameMapping) { 81 foreach (var kvp in variableNameMapping) this.variableNameMapping.Add(kvp.Key, kvp.Value); 83 82 var stringBuilder = new StringBuilder(); 84 83 85 84 stringBuilder.Append("="); 86 85 stringBuilder.Append(FormatRecursively(symbolicExpressionTree.Root)); … … 93 92 } 94 93 95 private Dictionary<string, string> CalculateVariableMapping(ISymbolicExpressionTree tree, IDataset dataset) {96 var mapping = new Dictionary<string, string>();94 private Dictionary<string, string> CalculateVariableMapping(ISymbolicExpressionTree tree, IDataset dataset) { 95 var mapping = new Dictionary<string, string>(); 97 96 int inputIndex = 0; 98 97 var usedVariables = tree.IterateNodesPrefix().OfType<IVariableTreeNode>().Select(v => v.VariableName).Distinct().ToArray(); … … 241 240 } else if (symbol is VariableCondition) { 242 241 VariableConditionTreeNode variableConditionTreeNode = node as VariableConditionTreeNode; 243 double threshold = variableConditionTreeNode.Threshold; 244 double slope = variableConditionTreeNode.Slope; 245 string p = "(1 / (1 + EXP(-" + slope.ToString(CultureInfo.InvariantCulture) + " * (" + GetColumnToVariableName(variableConditionTreeNode.VariableName) + "-" + threshold.ToString(CultureInfo.InvariantCulture) + "))))"; 246 stringBuilder.Append("(("); 247 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 248 stringBuilder.Append("*"); 249 stringBuilder.Append(p); 250 stringBuilder.Append(") + ("); 251 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 252 stringBuilder.Append("*("); 253 stringBuilder.Append("1 - " + p + ")"); 254 stringBuilder.Append("))"); 242 if (!variableConditionTreeNode.Symbol.IgnoreSlope) { 243 double threshold = variableConditionTreeNode.Threshold; 244 double slope = variableConditionTreeNode.Slope; 245 string p = "(1 / (1 + EXP(-" + slope.ToString(CultureInfo.InvariantCulture) + " * (" + 246 GetColumnToVariableName(variableConditionTreeNode.VariableName) + "-" + 247 threshold.ToString(CultureInfo.InvariantCulture) + "))))"; 248 stringBuilder.Append("(("); 249 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 250 stringBuilder.Append("*"); 251 stringBuilder.Append(p); 252 stringBuilder.Append(") + ("); 253 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 254 stringBuilder.Append("*("); 255 stringBuilder.Append("1 - " + p + ")"); 256 stringBuilder.Append("))"); 257 } else { 258 stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "(IF({0} <= {1}, {2}, {3}))", 259 GetColumnToVariableName(variableConditionTreeNode.VariableName), 260 variableConditionTreeNode.Threshold, 261 FormatRecursively(node.GetSubtree(0)), 262 FormatRecursively(node.GetSubtree(1)) 263 ); 264 } 255 265 } else if (symbol is Xor) { 256 266 stringBuilder.Append("IF(");
Note: See TracChangeset
for help on using the changeset viewer.