示例#1
0
文件: WekaData.cs 项目: wushian/MLEA
        public void FilterArff(weka.filters.Filter filter, string append = Parameters.NewFileAppend)
        {
            if (TestParameters.UseFilter)
            {
                Instances origInstances = m_trainInstances;
                filter.setInputFormat(origInstances);
                if (origInstances != null && origInstances.numInstances() > 0)
                {
                    m_trainInstancesNew = weka.filters.Filter.useFilter(origInstances, filter);
                }

                origInstances = m_testInstances;
                if (origInstances != null && origInstances.numInstances() > 0)
                {
                    m_testInstancesNew = weka.filters.Filter.useFilter(origInstances, filter);
                }

                if (TestParameters.SaveDataFile)
                {
                    string newFileName = GetArffFileName(true, m_currentDealType.ToString(), append);
                    string testNewFileName = GetArffFileName(false, m_currentDealType.ToString(), append);

                    if (!System.IO.File.Exists(newFileName)
                        && m_trainInstancesNew != null && m_trainInstancesNew.numInstances() > 0)
                    {
                        WekaUtils.SaveInstances(m_trainInstancesNew, newFileName);
                    }
                    if (!System.IO.File.Exists(testNewFileName)
                        && m_testInstancesNew != null && m_testInstancesNew.numInstances() > 0)
                    {
                        WekaUtils.SaveInstances(m_testInstancesNew, testNewFileName);
                    }
                }
            }
            else
            {
                m_trainInstancesNew = m_trainInstances;
                m_testInstancesNew = m_testInstances;
            }
        }