Changeset 4536 for branches/HeuristicLab.Classification
- Timestamp:
- 09/28/10 17:58:53 (14 years ago)
- Location:
- branches/HeuristicLab.Classification
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Classification/HeuristicLab.Algorithms.DataAnalysis.Views/3.3/HeuristicLab.Algorithms.DataAnalysis.Views.csproj
r4472 r4536 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3"> 105 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath> 106 </Reference> 107 <Reference Include="HeuristicLab.Collections-3.3"> 108 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath> 109 </Reference> 110 <Reference Include="HeuristicLab.Common-3.3"> 111 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath> 112 </Reference> 113 <Reference Include="HeuristicLab.Core-3.3"> 114 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath> 115 </Reference> 116 <Reference Include="HeuristicLab.Core.Views-3.3"> 117 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core.Views-3.3.dll</HintPath> 118 </Reference> 119 <Reference Include="HeuristicLab.Data-3.3"> 120 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath> 121 </Reference> 122 <Reference Include="HeuristicLab.Data.Views-3.3"> 123 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data.Views-3.3.dll</HintPath> 124 </Reference> 125 <Reference Include="HeuristicLab.MainForm-3.3"> 126 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm-3.3.dll</HintPath> 127 </Reference> 128 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3"> 129 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath> 130 </Reference> 131 <Reference Include="HeuristicLab.Optimization-3.3"> 132 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath> 133 </Reference> 104 134 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 105 135 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 106 136 </Reference> 137 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.3"> 138 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis-3.3.dll</HintPath> 139 </Reference> 107 140 <Reference Include="System" /> 108 141 <Reference Include="System.Core" /> 142 <Reference Include="System.Drawing" /> 143 <Reference Include="System.Windows.Forms" /> 109 144 <Reference Include="System.Xml.Linq" /> 110 145 <Reference Include="System.Data.DataSetExtensions" /> … … 113 148 </ItemGroup> 114 149 <ItemGroup> 150 <Compile Include="CrossValidationView.cs"> 151 <SubType>UserControl</SubType> 152 </Compile> 153 <Compile Include="CrossValidationView.Designer.cs"> 154 <DependentUpon>CrossValidationView.cs</DependentUpon> 155 </Compile> 115 156 <Compile Include="HeuristicLabAlgorithmsDataAnalysisViewsPlugin.cs" /> 116 157 <Compile Include="Properties\AssemblyInfo.cs" /> 158 <Compile Include="AlgorithmResultsCollectionView.cs"> 159 <SubType>UserControl</SubType> 160 </Compile> 161 <Compile Include="AlgorithmResultsCollectionView.Designer.cs"> 162 <DependentUpon>AlgorithmResultsCollectionView.cs</DependentUpon> 163 </Compile> 117 164 </ItemGroup> 118 165 <ItemGroup> … … 120 167 <None Include="HeuristicLabAlgorithmsDataAnalysisViewsPlugin.cs.frame" /> 121 168 <None Include="Properties\AssemblyInfo.frame" /> 169 </ItemGroup> 170 <ItemGroup> 171 <EmbeddedResource Include="CrossValidationView.resx"> 172 <DependentUpon>CrossValidationView.cs</DependentUpon> 173 </EmbeddedResource> 174 </ItemGroup> 175 <ItemGroup> 176 <ProjectReference Include="..\..\HeuristicLab.Algorithms.DataAnalysis\3.3\HeuristicLab.Algorithms.DataAnalysis-3.3.csproj"> 177 <Project>{A8D5676D-9662-437A-B44D-ECB4046CDE12}</Project> 178 <Name>HeuristicLab.Algorithms.DataAnalysis-3.3</Name> 179 </ProjectReference> 122 180 </ItemGroup> 123 181 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Classification/HeuristicLab.Algorithms.DataAnalysis/3.3/CrossValidation.cs
r4472 r4536 21 21 22 22 using System; 23 using System.Drawing; 24 using System.Linq; 23 25 using HeuristicLab.Collections; 24 26 using HeuristicLab.Common; … … 44 46 Runs = new RunCollection(); 45 47 46 algorithm Template= null;48 algorithm = null; 47 49 clonedAlgorithms = new ItemCollection<IAlgorithm>(); 48 50 RegisterClonedAlgorithmEvents(); … … 56 58 57 59 #region properties 58 private IAlgorithm algorithm Template;59 public IAlgorithm Algorithm Template{60 get { return algorithm Template; }60 private IAlgorithm algorithm; 61 public IAlgorithm Algorithm { 62 get { return algorithm; } 61 63 set { 62 if (algorithm Template!= value) {64 if (algorithm != value) { 63 65 if (value != null && value.Problem != null && !(value.Problem is IDataAnalysisProblem)) 64 66 throw new ArgumentException("Only algorithms with a DataAnalysisProblem could be used for the cross validation."); 65 if (algorithmTemplate != null) DeregisterAlgorithmTemplateEvents(); 66 algorithmTemplate = value; 67 if (algorithmTemplate != null) RegisterAlgorithmTemplateEvents(); 68 OnAlgorithmTemplateChanged(); 67 if (algorithm != null) DeregisterAlgorithmEvents(); 68 algorithm = value; 69 algorithm.Prepare(true); 70 if (algorithm != null) RegisterAlgorithmEvents(); 71 OnAlgorithmChanged(); 69 72 } 70 73 } 71 74 } 75 private IDataAnalysisProblem cachedProblem; 72 76 public IDataAnalysisProblem Problem { 73 77 get { 74 if (algorithm Template== null)78 if (algorithm == null) 75 79 return null; 76 return (IDataAnalysisProblem)algorithmTemplate.Problem; 77 } 78 } 80 return (IDataAnalysisProblem)algorithm.Problem; 81 } 82 set { 83 if (algorithm == null) throw new ArgumentNullException("Could not set a problem before an algorithm was set."); 84 algorithm.Problem = value; 85 cachedProblem = value; 86 } 87 } 88 79 89 private ItemCollection<IAlgorithm> clonedAlgorithms; 80 90 private ReadOnlyItemCollection<IAlgorithm> readOnlyClonedAlgorithms; … … 92 102 private IntValue samplesStart; 93 103 public IntValue SamplesStart { 94 get { return SamplesStart; }104 get { return samplesStart; } 95 105 } 96 106 private IntValue samplesEnd; 97 107 public IntValue SamplesEnd { 98 get { return SamplesEnd; }108 get { return samplesEnd; } 99 109 } 100 110 private IntValue numberOfWorkers; … … 126 136 } 127 137 } 138 public override Image ItemImage { 139 get { 140 if (ExecutionState == ExecutionState.Prepared) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared; 141 else if (ExecutionState == ExecutionState.Started) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStarted; 142 else if (ExecutionState == ExecutionState.Paused) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePaused; 143 else if (ExecutionState == ExecutionState.Stopped) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped; 144 else return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event; 145 } 146 } 147 128 148 private TimeSpan executionTime; 129 149 public TimeSpan ExecutionTime { 130 get { return executionTime; } 150 get { 151 if (ExecutionState != ExecutionState.Stopped) 152 return executionTime + TimeSpan.FromMilliseconds(clonedAlgorithms.Select(x => x.ExecutionTime.TotalMilliseconds).Sum()); 153 else 154 return executionTime; 155 } 131 156 private set { 132 157 executionTime = value; … … 137 162 138 163 public void Prepare() { 164 clonedAlgorithms.Clear(); 139 165 OnPrepared(); 140 166 } … … 144 170 } 145 171 public void Start() { 172 for (int i = 0; i < Folds.Value; i++) { 173 IAlgorithm clonedAlgorithm = (IAlgorithm)algorithm.Clone(); 174 clonedAlgorithm.Name = algorithm.Name + " Fold " + i; 175 clonedAlgorithms.Add(clonedAlgorithm); 176 } 177 for (int i = 0; i < NumberOfWorkers.Value && i < clonedAlgorithms.Count; i++) 178 clonedAlgorithms.ElementAt(i).Start(); 146 179 OnStarted(); 147 180 } … … 154 187 155 188 #region events 156 public event EventHandler AlgorithmTemplateChanged; 157 private void OnAlgorithmTemplateChanged() { 158 Prepare(); 159 EventHandler handler = AlgorithmTemplateChanged; 160 if (handler != null) handler(this, EventArgs.Empty); 161 } 162 private void RegisterAlgorithmTemplateEvents() { 163 algorithmTemplate.ProblemChanged += new EventHandler(algorithmTemplate_ProblemChanged); 164 } 165 private void DeregisterAlgorithmTemplateEvents() { 166 algorithmTemplate.ProblemChanged -= new EventHandler(algorithmTemplate_ProblemChanged); 167 } 168 private void algorithmTemplate_ProblemChanged(object sender, EventArgs e) { 189 public event EventHandler AlgorithmChanged; 190 private void OnAlgorithmChanged() { 191 EventHandler handler = AlgorithmChanged; 192 if (handler != null) handler(this, EventArgs.Empty); 193 OnProblemChanged(); 194 } 195 private void RegisterAlgorithmEvents() { 196 algorithm.ProblemChanged += new EventHandler(Algorithm_ProblemChanged); 197 } 198 private void DeregisterAlgorithmEvents() { 199 algorithm.ProblemChanged -= new EventHandler(Algorithm_ProblemChanged); 200 } 201 private void Algorithm_ProblemChanged(object sender, EventArgs e) { 202 if (algorithm.Problem != null && !(algorithm.Problem is IDataAnalysisProblem)) { 203 algorithm.Problem = cachedProblem; 204 throw new ArgumentException("A cross validation algorithm can only contain DataAnalysisProblems."); 205 } 206 cachedProblem = (IDataAnalysisProblem)algorithm.Problem; 169 207 SamplesStart.Value = 0; 170 SamplesEnd.Value = Problem.DataAnalysisProblemData.Dataset.Rows; 208 if (algorithm.Problem != null) 209 SamplesEnd.Value = Problem.DataAnalysisProblemData.Dataset.Rows; 210 else 211 SamplesEnd.Value = 0; 212 OnProblemChanged(); 213 } 214 public event EventHandler ProblemChanged; 215 private void OnProblemChanged() { 216 EventHandler handler = ProblemChanged; 217 if (handler != null) handler(this, EventArgs.Empty); 171 218 } 172 219 … … 191 238 } 192 239 private void RegisterClonedAlgorithmEvents(IAlgorithm algorithm) { 240 algorithm.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Algorithm_ExceptionOccurred); 241 algorithm.ExecutionTimeChanged += new EventHandler(Algorithm_ExecutionTimeChanged); 193 242 algorithm.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_Added); 194 243 algorithm.Paused += new EventHandler(Algorithm_Paused); … … 196 245 } 197 246 private void DeregisterClonedAlgorithmEvents(IAlgorithm algorithm) { 247 algorithm.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Algorithm_ExceptionOccurred); 248 algorithm.ExecutionTimeChanged += new EventHandler(Algorithm_ExecutionTimeChanged); 198 249 algorithm.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_Added); 199 250 algorithm.Paused -= new EventHandler(Algorithm_Paused); 200 251 algorithm.Stopped -= new EventHandler(Algorithm_Stopped); 201 252 } 253 private void Algorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) { 254 OnExceptionOccurred(e.Value); 255 } 256 private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) { 257 OnExecutionTimeChanged(); 258 } 202 259 private void Algorithm_Runs_Added(object sender, CollectionItemsChangedEventArgs<IRun> e) { 203 260 throw new NotImplementedException("TODO added finished run to actual results if the cross validation is running"); … … 209 266 throw new NotImplementedException("TODO stop the cross validation if all algorithms are stopped. and start remaining prepared algs"); 210 267 } 268 211 269 public event EventHandler ExecutionStateChanged; 212 270 private void OnExecutionStateChanged() { -
branches/HeuristicLab.Classification/HeuristicLab.Algorithms.DataAnalysis/3.3/HeuristicLab.Algorithms.DataAnalysis-3.3.csproj
r4472 r4536 108 108 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath> 109 109 </Reference> 110 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.2.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" /> 110 111 <Reference Include="HeuristicLab.Core-3.3"> 111 112 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath> … … 146 147 </Reference> 147 148 <Reference Include="System.Data" /> 149 <Reference Include="System.Drawing" /> 148 150 <Reference Include="System.Xml" /> 149 151 </ItemGroup> -
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/SingleObjectiveClassificationProblem.cs
r4366 r4536 30 30 [Item("Classification Problem", "Represents a classfication problem.")] 31 31 [StorableClass] 32 public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveProblem<T, U> 32 public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveProblem<T, U>, IDataAnalysisProblem 33 33 where T : class, ISingleObjectiveEvaluator 34 34 where U : class, ISolutionCreator { … … 41 41 get { return ClassificationProblemDataParameter.Value; } 42 42 set { ClassificationProblemDataParameter.Value = value; } 43 } 44 45 DataAnalysisProblemData IDataAnalysisProblem.DataAnalysisProblemData { 46 get { return ClassificationProblemData; } 43 47 } 44 48
Note: See TracChangeset
for help on using the changeset viewer.