⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oneinnsampling.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program 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 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program 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 this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 * Created on 2005/1/13
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package eti.bi.alphaminer.core.transform.filter;

import java.util.*;

import com.prudsys.pdm.Input.MiningStoredData;
import com.prudsys.pdm.Input.Records.Arff.MiningArffStream;
import com.prudsys.pdm.Transform.Special.CopyMiningStream;

/**
 * @author tyleung
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class OneInNSampling extends ETIFilter{
    private int m_NValue = 1; 
    
    public void setN(int a_NValue){
        m_NValue = a_NValue;
    }
    
    public int getN(){
        return m_NValue;
    }
    
    public MiningStoredData transform (MiningStoredData inputMiningStoredData){
        ArrayList<Object> miningVectors = new ArrayList<Object>();
        int numInstances = inputMiningStoredData.getVectorsNumber();
        for(int i=0; i< numInstances; i=i+m_NValue){
            miningVectors.add(inputMiningStoredData.get(i));            
        }
        
        MiningStoredData outputMiningStoredData = new MiningStoredData(miningVectors);
        return outputMiningStoredData;
    }
    
    public static void main (String [] argv)throws Exception{
        // Open 'iris.arff':
        MiningArffStream arff = new MiningArffStream( "data/arff/iris.arff" );

        // Display original stream:
        System.out.println( arff );

        // 1. Transformation -> Copy:
        MiningStoredData msd = new MiningStoredData();
        (new CopyMiningStream()).transform(arff, msd);

        // Display "transformed" stream:
        System.out.println("1. Transformed by 'CopyMiningStream': ");
        msd.reset();
//        System.out.println( msd );

        // 2. Transformation -> OneInNSample
        OneInNSampling sample = new OneInNSampling();
        sample.setN(10);
        msd = sample.transform(msd);
        System.out.println(msd);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -