#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; namespace HeuristicLab.DataPreprocessing { public class TransformationLogic : ITransformationLogic { private readonly ITransactionalPreprocessingData preprocessingData; private readonly ISearchLogic searchLogic; private readonly IStatisticsLogic statisticsLogic; public TransformationLogic(ITransactionalPreprocessingData thePreprocessingData, ISearchLogic theSearchLogic, IStatisticsLogic theStatisticsLogic) { preprocessingData = thePreprocessingData; searchLogic = theSearchLogic; statisticsLogic = theStatisticsLogic; } public void DeleteRowsWithMissingValuesGreater(double percent) { for (int i = 0; i < preprocessingData.Rows; ++i) { int missingCount = statisticsLogic.GetRowMissingValueCount(i); if (100f / preprocessingData.Columns * missingCount >= percent) { preprocessingData.DeleteRow(i); --i; } } } public void DeleteColumnsWithMissingValuesGreater(float percent) { for (int i = 0; i < preprocessingData.Columns; ++i) { int missingCount = statisticsLogic.GetMissingValueCount(i); if (100f / preprocessingData.Columns * missingCount >= percent) { preprocessingData.DeleteColumn(i); --i; } } } public void DeleteColumnsWithVarianceSmaller(double variance) { for (int i = 0; i < preprocessingData.Columns; ++i) { if (preprocessingData.IsType(i) || preprocessingData.IsType(i)) { double columnVariance = statisticsLogic.GetVariance(i); if (columnVariance < variance) { preprocessingData.DeleteColumn(i); --i; } } } } } }