Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/18 11:11:37 (5 years ago)
Author:
fholzing
Message:

#2904: cleared variableImpacts on OnContentChanged(); Used existing epsilon (almost) function for comparison of estimated impacts; removed direct usage of alglib; Added a LDA- and RF-Unittest for Impact-Calculation; Changed the approach of loading ProblemData (no more strings); Renamed PerformanceTests for Regression/Classification so it can be found easier

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2904_CalculateImpacts/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/ClassificationVariableImpactCalculationTest.cs

    r16067 r16416  
    2626    }
    2727
    28     private static readonly double epsilon = 0.00001;
    2928
    3029    [TestMethod]
     
    4847      ClassificationSolutionVariableImpactsCalculator.CalculateImpacts(solution);
    4948      Dictionary<string, double> expectedImpacts = GetExpectedValuesForIrisKNNModel();
     49
     50      CheckDefaultAsserts(solution, expectedImpacts);
     51    }
     52
     53
     54    [TestMethod]
     55    [TestCategory("Problems.DataAnalysis")]
     56    [TestProperty("Time", "short")]
     57    public void LDAIrisVariableImpactTest() {
     58      IClassificationProblemData problemData = LoadIrisProblem();
     59      IClassificationSolution solution = LinearDiscriminantAnalysis.CreateLinearDiscriminantAnalysisSolution(problemData);
     60      ClassificationSolutionVariableImpactsCalculator.CalculateImpacts(solution);
     61      Dictionary<string, double> expectedImpacts = GetExpectedValuesForIrisLDAModel();
    5062
    5163      CheckDefaultAsserts(solution, expectedImpacts);
     
    8597    [TestProperty("Time", "short")]
    8698    [ExpectedException(typeof(ArgumentException))]
    87     public void WrongDataSetTest() {
     99    public void WrongDataSetVariableImpactClassificationTest() {
    88100      IClassificationProblemData problemData = LoadIrisProblem();
    89101      IClassificationSolution solution = NearestNeighbourClassification.CreateNearestNeighbourClassificationSolution(problemData, 3);
     
    99111    [TestCategory("Problems.DataAnalysis")]
    100112    [TestProperty("Time", "medium")]
    101     public void PerformanceTest() {
     113    public void PerformanceVariableImpactClassificationTest() {
    102114      int rows = 1500;
    103115      int columns = 77;
     
    229241      return expectedImpacts;
    230242    }
     243    private Dictionary<string, double> GetExpectedValuesForIrisLDAModel() {
     244      Dictionary<string, double> expectedImpacts = new Dictionary<string, double>();
     245      expectedImpacts.Add("sepal_width", 0.01);
     246      expectedImpacts.Add("sepal_length", 0.03);
     247      expectedImpacts.Add("petal_width", 0.2);
     248      expectedImpacts.Add("petal_length", 0.5);
     249
     250      return expectedImpacts;
     251    }
    231252    #endregion
    232253
     
    243264      //Check if impacts are as expected
    244265      Assert.AreEqual(modelImpacts.Count(), expectedImpacts.Count);
    245       Assert.IsTrue(modelImpacts.All(v => Math.Abs(expectedImpacts[v.Item1] - v.Item2) < epsilon));
     266      Assert.IsTrue(modelImpacts.All(v => v.Item2.IsAlmost(expectedImpacts[v.Item1])));
    246267    }
    247268  }
Note: See TracChangeset for help on using the changeset viewer.