Changeset 11523 for trunk/sources
- Timestamp:
- 11/05/14 11:13:34 (10 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.csproj
r10540 r11523 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="EPPlus-3.1.3, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL"> 96 <SpecificVersion>False</SpecificVersion> 97 <HintPath>..\..\bin\EPPlus-3.1.3.dll</HintPath> 98 <Private>False</Private> 99 </Reference> 95 100 <Reference Include="System" /> 96 101 <Reference Include="System.Core"> … … 116 121 <DependentUpon>InteractiveSymbolicClassificationSolutionSimplifierView.cs</DependentUpon> 117 122 </Compile> 123 <Compile Include="SymbolicDiscriminantFunctionClassificationSolutionExcelExporter.cs" /> 118 124 <Compile Include="SymbolicClassificationSolutionView.cs"> 119 125 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs
r11171 r11523 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;28 27 using HeuristicLab.Problems.DataAnalysis.Views; 29 28 … … 54 53 55 54 private void exportButton_Click(object sender, EventArgs e) { 56 var exporter = new Symbolic SolutionExcelExporter();55 var exporter = new SymbolicDiscriminantFunctionClassificationSolutionExcelExporter(); 57 56 exportFileDialog.Filter = exporter.FileTypeFilter; 58 57 if (exportFileDialog.ShowDialog(this) == DialogResult.OK) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Exporters/SymbolicSolutionExcelExporter.cs
r11171 r11523 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 31 31 public class SymbolicSolutionExcelExporter : IDataAnalysisSolutionExporter { 32 pr ivateconst string TRAININGSTART = "TrainingStart";33 pr ivateconst string TRAININGEND = "TrainingEnd";34 pr ivateconst string TESTSTART = "TestStart";35 pr ivateconst string TESTEND = "TestEnd";32 protected const string TRAININGSTART = "TrainingStart"; 33 protected const string TRAININGEND = "TrainingEnd"; 34 protected const string TESTSTART = "TestStart"; 35 protected const string TESTEND = "TestEnd"; 36 36 37 37 … … 52 52 } 53 53 54 pr ivatevoid ExportChart(string fileName, ISymbolicDataAnalysisSolution solution, string formula) {54 protected virtual void ExportChart(string fileName, ISymbolicDataAnalysisSolution solution, string formula) { 55 55 FileInfo newFile = new FileInfo(fileName); 56 56 if (newFile.Exists) { … … 85 85 } 86 86 87 pr ivatevoid FormatModelSheet(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisSolution solution, IEnumerable<string> formulaParts) {87 protected virtual void FormatModelSheet(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisSolution solution, IEnumerable<string> formulaParts) { 88 88 int row = 1; 89 89 modelWorksheet.Cells[row, 1].Value = "Model"; … … 216 216 } 217 217 218 pr ivatestring Indirect(string column, bool training) {218 protected string Indirect(string column, bool training) { 219 219 if (training) { 220 220 return string.Format("INDIRECT(\"'Estimated Values'!{0}\"&{1}+2&\":{0}\"&{2}+1)", column, TRAININGSTART, TRAININGEND); … … 224 224 } 225 225 226 pr ivatevoid AddCharts(ExcelWorksheet chartsWorksheet) {226 protected virtual void AddCharts(ExcelWorksheet chartsWorksheet) { 227 227 chartsWorksheet.Names.AddFormula("AllId", "OFFSET('Estimated Values'!$A$1,1,0, COUNTA('Estimated Values'!$A:$A)-1)"); 228 228 chartsWorksheet.Names.AddFormula("AllTarget", "OFFSET('Estimated Values'!$B$1,1,0, COUNTA('Estimated Values'!$B:$B)-1)"); … … 260 260 } 261 261 262 pr ivatevoid AddModelTreePicture(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisModel model) {262 protected virtual void AddModelTreePicture(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisModel model) { 263 263 SymbolicExpressionTreeChart modelTreePicture = new SymbolicExpressionTreeChart(); 264 264 modelTreePicture.Tree = model.SymbolicExpressionTree; … … 289 289 estimatedWorksheet.Cells[1, 1, 1, 10].AutoFitColumns(); 290 290 291 // fill in id, target variable and unbounded estimated values 291 292 int targetIndex = solution.ProblemData.Dataset.VariableNames.ToList().FindIndex(x => x.Equals(solution.ProblemData.TargetVariable)) + 1; 292 293 for (int i = 0; i < rows; i++) { 293 estimatedWorksheet.Cells[i + 2, 1].Value = i; 294 estimatedWorksheet.Cells[i + 2, 2].Formula = datasetWorksheet.Cells[i + 2, targetIndex].FullAddress; 295 estimatedWorksheet.Cells[i + 2, 9].Formula = string.Format(preparedFormula, i + 2); 294 estimatedWorksheet.Cells[i + 2, 1].Value = i; // id 295 estimatedWorksheet.Cells[i + 2, 2].Formula = datasetWorksheet.Cells[i + 2, targetIndex].FullAddress; // target variable 296 estimatedWorksheet.Cells[i + 2, 9].Formula = string.Format(preparedFormula, i + 2); // unbounded estimated values 296 297 } 297 298 estimatedWorksheet.Cells["B2:B" + (rows + 1)].Style.Numberformat.Format = "0.000"; … … 313 314 } 314 315 315 pr ivatestring PrepareFormula(string[] formulaParts) {316 protected string PrepareFormula(string[] formulaParts) { 316 317 string preparedFormula = formulaParts[0]; 317 318 foreach (var part in formulaParts.Skip(2)) { … … 323 324 } 324 325 325 pr ivatevoid WriteInputSheet(ExcelWorksheet inputsWorksheet, ExcelWorksheet datasetWorksheet, IEnumerable<string> list, Dataset dataset) {326 protected void WriteInputSheet(ExcelWorksheet inputsWorksheet, ExcelWorksheet datasetWorksheet, IEnumerable<string> list, Dataset dataset) { 326 327 //remark the performance of EPPlus drops dramatically 327 328 //if the data is not written row wise (from left to right) due the internal indices used. … … 337 338 } 338 339 339 pr ivatevoid WriteDatasetToExcel(ExcelWorksheet datasetWorksheet, IDataAnalysisProblemData problemData) {340 protected void WriteDatasetToExcel(ExcelWorksheet datasetWorksheet, IDataAnalysisProblemData problemData) { 340 341 //remark the performance of EPPlus drops dramatically 341 342 //if the data is not written row wise (from left to right) due the internal indices used. -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r11171 r11523 203 203 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 204 204 stringBuilder.Append(",0))"); 205 } else if (symbol is IfThenElse) { 206 stringBuilder.Append("IF("); 207 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + " ) > 0"); 208 stringBuilder.Append(","); 209 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 210 stringBuilder.Append(","); 211 stringBuilder.Append(FormatRecursively(node.GetSubtree(2))); 212 stringBuilder.Append(")"); 213 } else if (symbol is VariableCondition) { 214 VariableConditionTreeNode variableConditionTreeNode = node as VariableConditionTreeNode; 215 double threshold = variableConditionTreeNode.Threshold; 216 double slope = variableConditionTreeNode.Slope; 217 string p = "(1 / (1 + EXP(-" + slope.ToString(CultureInfo.InvariantCulture) + "* (" + GetColumnToVariableName(variableConditionTreeNode.VariableName) + "-" + threshold.ToString(CultureInfo.InvariantCulture) + "))))"; 218 stringBuilder.Append("INT(("); 219 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 220 stringBuilder.Append("*"); 221 stringBuilder.Append(p); 222 stringBuilder.Append(") + ("); 223 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 224 stringBuilder.Append("*("); 225 stringBuilder.Append("1 - " + p + ")"); 226 stringBuilder.Append("))"); 227 } else if (symbol is Xor) { 228 stringBuilder.Append("IF("); 229 stringBuilder.Append("XOR("); 230 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,"); 231 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0"); 232 stringBuilder.Append("), 1.0, -1.0)"); 233 } else if (symbol is Or) { 234 stringBuilder.Append("IF("); 235 stringBuilder.Append("OR("); 236 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,"); 237 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0"); 238 stringBuilder.Append("), 1.0, -1.0)"); 239 } else if (symbol is And) { 240 stringBuilder.Append("IF("); 241 stringBuilder.Append("AND("); 242 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,"); 243 stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0"); 244 stringBuilder.Append("), 1.0, -1.0)"); 245 } else if (symbol is Not) { 246 stringBuilder.Append("IF("); 247 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 248 stringBuilder.Append(" > 0, -1.0, 1.0)"); 249 } else if (symbol is GreaterThan) { 250 stringBuilder.Append("IF(("); 251 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 252 stringBuilder.Append(") > ("); 253 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 254 stringBuilder.Append("), 1.0, -1.0)"); 255 } else if (symbol is LessThan) { 256 stringBuilder.Append("IF(("); 257 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 258 stringBuilder.Append(") < ("); 259 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 260 stringBuilder.Append("), 1.0, -1.0)"); 205 261 } else { 206 262 throw new NotImplementedException("Excel export of " + node.Symbol + " is not implemented.");
Note: See TracChangeset
for help on using the changeset viewer.