Changeset 1869 for trunk/sources/HeuristicLab.Modeling
- Timestamp:
- 05/20/09 12:52:52 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Modeling/3.2
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
r1857 r1869 96 96 </Compile> 97 97 <Compile Include="Properties\AssemblyInfo.cs" /> 98 <Compile Include="SimpleMSEEvaluator.cs" /> 99 <Compile Include="SimpleR2Evaluator.cs" /> 98 100 <Compile Include="TimeSeriesProblemInjector.cs" /> 99 101 </ItemGroup> -
trunk/sources/HeuristicLab.Modeling/3.2/SimpleMSEEvaluator.cs
r1854 r1869 7 7 using HeuristicLab.DataAnalysis; 8 8 9 namespace HeuristicLab. SupportVectorMachines{10 public class SimpleMSEEvaluator : OperatorBase {9 namespace HeuristicLab.Modeling { 10 public class SimpleMSEEvaluator : OperatorBase { 11 11 12 12 public SimpleMSEEvaluator() 13 13 : base() { 14 AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof( ItemList), VariableKind.In));14 AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In)); 15 15 AddVariableInfo(new VariableInfo("MSE", "Mean squarred error", typeof(DoubleData), VariableKind.New | VariableKind.Out)); 16 16 } 17 17 18 18 public override IOperation Apply(IScope scope) { 19 ItemList values = GetVariableValue<ItemList>("Values", scope, true);19 DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true); 20 20 double sse = 0; 21 double cnt = 0; 22 for each (ItemList row in values) {23 double estimated = ((DoubleData)row[0]).Data;24 double target = ((DoubleData)row[1]).Data;21 double cnt = 0; 22 for (int i = 0; i < values.Data.GetLength(0); i++) { 23 double estimated = values.Data[i, 0]; 24 double target = values.Data[i, 1]; 25 25 if (!double.IsNaN(estimated) && !double.IsInfinity(estimated) && 26 26 !double.IsNaN(target) && !double.IsInfinity(target)) { … … 32 32 33 33 double mse = sse / cnt; 34 scope.AddVariable(new Variable(scope.TranslateName("MSE"), new DoubleData(mse)));34 scope.AddVariable(new Variable(scope.TranslateName("MSE"), new DoubleData(mse))); 35 35 return null; 36 36 } -
trunk/sources/HeuristicLab.Modeling/3.2/SimpleR2Evaluator.cs
r1854 r1869 7 7 using HeuristicLab.DataAnalysis; 8 8 9 namespace HeuristicLab. SupportVectorMachines{10 public class SimpleR2Evaluator : OperatorBase {9 namespace HeuristicLab.Modeling { 10 public class SimpleR2Evaluator : OperatorBase { 11 11 12 12 public SimpleR2Evaluator() 13 13 : base() { 14 AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof( ItemList), VariableKind.In));14 AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In)); 15 15 AddVariableInfo(new VariableInfo("R2", "Coefficient of determination", typeof(DoubleData), VariableKind.New | VariableKind.Out)); 16 16 } 17 17 18 18 public override IOperation Apply(IScope scope) { 19 ItemList values = GetVariableValue<ItemList>("Values", scope, true);19 DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true); 20 20 21 21 double targetMean = 0; 22 22 double sse = 0; 23 23 double cnt = 0; 24 for each (ItemList row in values) {25 double estimated = ((DoubleData)row[0]).Data;26 double target = ((DoubleData)row[1]).Data;24 for (int i = 0; i < values.Data.GetLength(0); i++) { 25 double estimated = values.Data[i, 0]; 26 double target = values.Data[i, 1]; 27 27 if (!double.IsNaN(estimated) && !double.IsInfinity(estimated) && 28 28 !double.IsNaN(target) && !double.IsInfinity(target)) { … … 36 36 37 37 double targetDeviationTotalSumOfSquares = 0; 38 for each (ItemList row in values) {39 double target = ((DoubleData)row[1]).Data;38 for (int i = 0; i < values.Data.GetLength(0); i++) { 39 double target = values.Data[i, 1]; 40 40 if (!double.IsNaN(target) && !double.IsInfinity(target)) { 41 41 target = target - targetMean;
Note: See TracChangeset
for help on using the changeset viewer.