Changeset 13502 for trunk/sources/HeuristicLab.DataPreprocessing
- Timestamp:
- 01/12/16 17:05:37 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.DataPreprocessing/3.4
- Files:
-
- 1 deleted
- 18 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r12682 r13502 108 108 <None Include="Plugin.cs.frame" /> 109 109 <Compile Include="Implementations\DataGridContent.cs" /> 110 <Compile Include=" Implementations\PreprocessingContext.cs" />110 <Compile Include="PreprocessingContext.cs" /> 111 111 <Compile Include="Implementations\TransactionalPreprocessingData.cs" /> 112 112 <Compile Include="Implementations\SearchLogic.cs" /> 113 113 <Compile Include="Implementations\StatisticsLogic.cs" /> 114 114 <Compile Include="Interfaces\IDataGridContent.cs" /> 115 <Compile Include="Interfaces\IPreprocessingContext.cs" />116 115 <Compile Include="Interfaces\ISearchLogic.cs" /> 117 116 <Compile Include="Interfaces\IStatisticsLogic.cs" /> … … 160 159 <Private>False</Private> 161 160 </ProjectReference> 161 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj"> 162 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> 163 <Name>HeuristicLab.Persistence-3.3</Name> 164 </ProjectReference> 162 165 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> 163 166 <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project> -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/CorrelationMatrixContent.cs
r12012 r13502 21 21 22 22 using System.Drawing; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 32 33 } 33 34 34 private IPreprocessingContext Context { get; set; }35 private PreprocessingContext Context { get; set; } 35 36 private ITransactionalPreprocessingData PreprocessingData { 36 37 get { return Context.Data; } … … 39 40 public DataAnalysisProblemData ProblemData { 40 41 get { 41 var creator = new ProblemDataCreator(Context); 42 return (DataAnalysisProblemData)creator.CreateProblemData(); 42 // ToDo: avoid iterating 43 return Context.ExportPossibilities.Select(p => p.Value()).OfType<DataAnalysisProblemData>().Single(); 44 //var creator = new ProblemDataCreator(Context); 45 //return (DataAnalysisProblemData)creator.CreateProblemData(); 43 46 } 44 47 } 45 48 46 public CorrelationMatrixContent( IPreprocessingContext context) {49 public CorrelationMatrixContent(PreprocessingContext context) { 47 50 Context = context; 48 51 } … … 50 53 public CorrelationMatrixContent(CorrelationMatrixContent original, Cloner cloner) 51 54 : base(original, cloner) { 52 55 Context = original.Context; 53 56 } 54 57 -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/Filter/IFilter.cs
r10667 r13502 1 using HeuristicLab.Core; 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 6 21 7 namespace HeuristicLab.DataPreprocessing.Filter 8 { 9 public interface IFilter : IConstraint 10 {22 using HeuristicLab.Core; 23 24 namespace HeuristicLab.DataPreprocessing.Filter { 25 public interface IFilter : IConstraint { 11 26 new bool[] Check(); 12 27 new bool[] Check(out string errorMessage); -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterLogic.cs
r12012 r13502 24 24 using System.Linq; 25 25 using HeuristicLab.DataPreprocessing.Filter; 26 using HeuristicLab.DataPreprocessing.Interfaces; 26 27 27 namespace HeuristicLab.DataPreprocessing { 28 28 public class FilterLogic : IFilterLogic { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs
r13252 r13502 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using HeuristicLab.Common; 4 25 using HeuristicLab.Core; 5 26 using HeuristicLab.Data; 6 using HeuristicLab.DataPreprocessing.Interfaces;7 27 using HeuristicLab.Problems.DataAnalysis; 8 28 9 namespace HeuristicLab.DataPreprocessing .Implementations{29 namespace HeuristicLab.DataPreprocessing { 10 30 public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData { 11 31 private readonly ITransactionalPreprocessingData originalData; -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/HistogramContent.cs
r12676 r13502 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.DataPreprocessing.Interfaces;28 27 29 28 namespace HeuristicLab.DataPreprocessing { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/LineChartContent.cs
r12012 r13502 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.DataPreprocessing.Interfaces;26 25 27 26 namespace HeuristicLab.DataPreprocessing { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingChartContent.cs
r12676 r13502 28 28 using HeuristicLab.Core; 29 29 using HeuristicLab.Data; 30 using HeuristicLab.DataPreprocessing.Interfaces;31 30 32 31 namespace HeuristicLab.DataPreprocessing { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs
r13427 r13502 94 94 selection = new Dictionary<int, IList<int>>(); 95 95 96 Import(problemData); 97 98 RegisterEventHandler(); 99 } 100 101 public void Import(IDataAnalysisProblemData problemData) { 96 102 Dataset dataset = (Dataset)problemData.Dataset; 97 103 variableNames = new List<string>(problemData.Dataset.VariableNames); … … 114 120 TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End); 115 121 TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End); 116 117 RegisterEventHandler();118 122 } 119 123 -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingDataTable.cs
r11114 r13502 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using HeuristicLab.Analysis; 3 24 using HeuristicLab.Common; 4 25 using HeuristicLab.Core; 5 26 6 namespace HeuristicLab.DataPreprocessing .Implementations{27 namespace HeuristicLab.DataPreprocessing { 7 28 [Item("PreprossingDataTable", "A table of data values.")] 8 29 public class PreprocessingDataTable : DataTable { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/ScatterPlotContent.cs
r12012 r13502 22 22 using System.Collections.Generic; 23 23 using System.Drawing; 24 using System.Linq; 24 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HeuristicLab.DataPreprocessing.Interfaces;28 28 29 29 namespace HeuristicLab.DataPreprocessing { … … 34 34 public string SelectedXVariable { get; set; } 35 35 public string SelectedYVariable { get; set; } 36 public string SelectedColorVariable { get; set; } 36 37 37 38 public ScatterPlotContent(IFilteredPreprocessingData preprocessingData) … … 43 44 this.SelectedXVariable = content.SelectedXVariable; 44 45 this.SelectedYVariable = content.SelectedYVariable; 46 this.SelectedColorVariable = content.SelectedColorVariable; 45 47 } 46 48 47 public static new Image StaticItemImage 48 { 49 public static new Image StaticItemImage { 49 50 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } 50 51 } … … 54 55 } 55 56 56 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY ) {57 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-") { 57 58 ScatterPlot scatterPlot = new ScatterPlot(); 58 59 59 60 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 60 61 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 62 if (variableNameColor == null || variableNameColor == "-") { 63 List<Point2D<double>> points = new List<Point2D<double>>(); 61 64 62 List<Point2D<double>> points = new List<Point2D<double>>(); 65 for (int i = 0; i < xValues.Count; i++) { 66 Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]); 67 points.Add(point); 68 } 63 69 64 for (int i = 0; i < xValues.Count; i++) { 65 Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]); 66 points.Add(point); 70 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); 71 scatterPlot.Rows.Add(scdr); 72 73 } else { 74 var colorValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameColor)); 75 var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList(); 76 var gradients = ColorGradient.Colors; 77 int curGradient = 0; 78 int numColors = colorValues.Distinct().Count(); 79 foreach (var colorValue in colorValues.Distinct()) { 80 var values = data.Where(x => x.c == colorValue); 81 var row = new ScatterPlotDataRow( 82 variableNameX + " - " + variableNameY + " (" + colorValue + ")", 83 "", 84 values.Select(v => new Point2D<double>(v.x, v.y)), 85 new ScatterPlotDataRowVisualProperties() { Color = gradients[curGradient] }); 86 curGradient += gradients.Count / numColors; 87 scatterPlot.Rows.Add(row); 88 } 67 89 } 68 69 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);70 scatterPlot.Rows.Add(scdr);71 90 return scatterPlot; 72 91 } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/StatisticsContent.cs
r12012 r13502 19 19 */ 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using HeuristicLab.Common; -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/StatisticsLogic.cs
r13051 r13502 26 26 27 27 namespace HeuristicLab.DataPreprocessing { 28 29 28 public class StatisticsLogic : IStatisticsLogic { 30 29 -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Interfaces/IFilterLogic.cs
r12012 r13502 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.DataPreprocessing.Filter; 25 using HeuristicLab.DataPreprocessing.Interfaces; 25 26 26 namespace HeuristicLab.DataPreprocessing { 27 27 public interface IFilterLogic { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Interfaces/IFilteredPreprocessingData.cs
r10900 r13502 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 5 21 6 namespace HeuristicLab.DataPreprocessing.Interfaces 7 { 8 public interface IFilteredPreprocessingData : ITransactionalPreprocessingData 9 {22 using System; 23 24 namespace HeuristicLab.DataPreprocessing { 25 public interface IFilteredPreprocessingData : ITransactionalPreprocessingData { 10 26 void SetFilter(bool[] rowFilters); 11 27 void PersistFilter(); … … 14 30 15 31 event EventHandler FilterChanged; 16 32 } 17 33 } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Interfaces/ITransactionalPreprocessingData.cs
r12012 r13502 20 20 #endregion 21 21 22 using System; 22 23 23 using System;24 24 namespace HeuristicLab.DataPreprocessing { 25 26 25 public interface ITransactionalPreprocessingData : IPreprocessingData { 27 26 -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Interfaces/IViewChartShortcut.cs
r12012 r13502 20 20 #endregion 21 21 22 using HeuristicLab.Core;23 22 24 23 namespace HeuristicLab.DataPreprocessing { -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/PreprocessingContext.cs
r13496 r13502 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 using HeuristicLab.DataPreprocessing.Implementations;25 using HeuristicLab.DataPreprocessing.Interfaces;26 26 using HeuristicLab.Optimization; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 using HeuristicLab.Problems.DataAnalysis; 28 29 29 30 namespace HeuristicLab.DataPreprocessing { 30 31 [Item("PreprocessingContext", "PreprocessingContext")] 31 public class PreprocessingContext 32 : Item, IPreprocessingContext { 32 public class PreprocessingContext : NamedItem, IStorableContent { 33 34 public string Filename { get; set; } 35 36 public IEnumerable<KeyValuePair<string, Func<IItem>>> ExportPossibilities { 37 get { 38 var algorithm = Source as IAlgorithm; 39 if (algorithm != null) 40 yield return new KeyValuePair<string, Func<IItem>>(algorithm.Name, () => ExportAlgorithm(algorithm)); 41 42 var problem = algorithm != null ? algorithm.Problem as IDataAnalysisProblem : Source as IDataAnalysisProblem; 43 if (problem != null) 44 yield return new KeyValuePair<string, Func<IItem>>(problem.Name, () => ExportProblem(problem)); 45 46 var problemData = problem != null ? problem.ProblemData : Source as IDataAnalysisProblemData; 47 if (problemData != null) 48 yield return new KeyValuePair<string, Func<IItem>>(problemData.Name, () => ExportProblemData(problemData)); 49 50 // ToDo: Export CSV 51 } 52 } 53 public bool CanExport { 54 get { return Source is IAlgorithm || Source is IDataAnalysisProblem || Source is IDataAnalysisProblemData; } 55 } 56 57 [Storable] 58 public IFilteredPreprocessingData Data { get; private set; } 59 60 [Storable] 61 private IItem Source { get; set; } 33 62 34 63 35 public IFilteredPreprocessingData Data { get; private set; } 64 public PreprocessingContext() : this(new RegressionProblemData()) { } 65 public PreprocessingContext(IItem source) { 66 Import(source); 36 67 37 public IAlgorithm Algorithm { get; private set; }38 public IDataAnalysisProblem Problem { get; private set; }39 public IDataAnalysisProblemData ProblemData { get; private set; }40 41 private readonly ProblemDataCreator creator;42 43 public PreprocessingContext(IDataAnalysisProblemData dataAnalysisProblemData, IAlgorithm algorithm, IDataAnalysisProblem problem) {44 var transactionalPreprocessingData = new TransactionalPreprocessingData(dataAnalysisProblemData);45 Data = new FilteredPreprocessingData(transactionalPreprocessingData);46 47 ProblemData = dataAnalysisProblemData;48 Algorithm = algorithm;49 Problem = problem;50 51 creator = new ProblemDataCreator(this);52 68 } 53 69 70 [StorableConstructor] 71 private PreprocessingContext(bool deserializing) 72 : base(deserializing) { } 54 73 protected PreprocessingContext(PreprocessingContext original, Cloner cloner) 55 74 : base(original, cloner) { 75 Source = cloner.Clone(original.Source); 56 76 Data = cloner.Clone(original.Data); 57 Algorithm = original.Algorithm;58 Problem = original.Problem;59 77 } 60 78 … … 63 81 } 64 82 83 #region Import 84 public void Import(IItem source) { 85 Source = source; 86 87 var dataSource = ExtractProblemData(source); 88 Data = new FilteredPreprocessingData(new TransactionalPreprocessingData(dataSource)); 89 } 90 91 private IDataAnalysisProblemData ExtractProblemData(IItem source) { 92 var algorithm = source as Algorithm; 93 var problem = algorithm != null ? algorithm.Problem as IDataAnalysisProblem : source as IDataAnalysisProblem; 94 var problemData = problem != null ? problem.ProblemData : source as IDataAnalysisProblemData; 95 return problemData; 96 } 97 #endregion 98 99 #region Export 65 100 public IItem Export() { 66 if (Algorithm != null) 67 return ExportAlgorithm(); 68 else if (Problem != null) 69 return ExportProblem(); 70 return ExportProblemData(); 101 var creator = new ProblemDataCreator(this); 102 if (Source is IAlgorithm) 103 return ExportAlgorithm((IAlgorithm)Source); 104 if (Source is IDataAnalysisProblem) 105 return ExportProblem((IDataAnalysisProblem)Source); 106 if (Source is IDataAnalysisProblemData) 107 return ExportProblemData((IDataAnalysisProblemData)Source); 108 return null; 71 109 } 72 p ublic IAlgorithm ExportAlgorithm() {73 var preprocessedAlgorithm = (IAlgorithm) Algorithm.Clone(new Cloner());110 private IAlgorithm ExportAlgorithm(IAlgorithm source) { 111 var preprocessedAlgorithm = (IAlgorithm)source.Clone(); 74 112 preprocessedAlgorithm.Name = preprocessedAlgorithm.Name + "(Preprocessed)"; 75 Algorithm.Runs.Clear();113 preprocessedAlgorithm.Runs.Clear(); 76 114 var problem = (IDataAnalysisProblem)preprocessedAlgorithm.Problem; 77 115 SetNewProblemData(problem); 78 116 return preprocessedAlgorithm; 79 117 } 80 p ublic IDataAnalysisProblem ExportProblem() {81 var preprocessedProblem = (IDataAnalysisProblem) Problem.Clone(new Cloner());118 private IDataAnalysisProblem ExportProblem(IDataAnalysisProblem source) { 119 var preprocessedProblem = (IDataAnalysisProblem)source.Clone(); 82 120 SetNewProblemData(preprocessedProblem); 83 121 return preprocessedProblem; 84 122 } 85 86 public IDataAnalysisProblemData ExportProblemData() {87 return creator.CreateProblemData( );123 private IDataAnalysisProblemData ExportProblemData(IDataAnalysisProblemData source) { 124 var creator = new ProblemDataCreator(this); 125 return creator.CreateProblemData(source); 88 126 } 89 90 127 private void SetNewProblemData(IDataAnalysisProblem problem) { 91 var data = creator.CreateProblemData();128 var data = ExtractProblemData(problem.ProblemData); 92 129 problem.ProblemDataParameter.ActualValue = data; 93 130 problem.Name = "Preprocessed " + problem.Name; 94 131 } 132 #endregion 95 133 } 96 134 } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs
r13252 r13502 29 29 public class ProblemDataCreator { 30 30 31 private readonly IPreprocessingContext context;31 private readonly PreprocessingContext context; 32 32 33 33 private Dataset ExportedDataset { … … 39 39 private IList<ITransformation> Transformations { get { return context.Data.Transformations; } } 40 40 41 public ProblemDataCreator( IPreprocessingContext context) {41 public ProblemDataCreator(PreprocessingContext context) { 42 42 this.context = context; 43 43 } 44 44 45 public IDataAnalysisProblemData CreateProblemData( ) {45 public IDataAnalysisProblemData CreateProblemData(IDataAnalysisProblemData oldProblemData) { 46 46 if (context.Data.Rows == 0 || context.Data.Columns == 0) return null; 47 47 48 var oldProblemData = context.ProblemData;49 48 IDataAnalysisProblemData problemData; 50 49
Note: See TracChangeset
for help on using the changeset viewer.