📄 vectortransformationstream.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.
*/
/**
* Title: XELOPES Data Mining Library
* Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
* Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
* Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
* @author Michael Thess
* @version 1.0
*/
package com.prudsys.pdm.Transform.Special;
import java.util.Vector;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Input.MiningFilterStream;
import com.prudsys.pdm.Input.MiningInputStream;
import com.prudsys.pdm.Transform.MiningTransformationStep;
/**
* Base class for application of vector-type transformation methods
* to a mining input stream. This makes the use of the transformations
* of the one-to-one, one-to-multiple, and multiple-to-multiple type
* for complete streams more comfortable. <p>
*
* Examples are linearizations of the numeric attributes of a stream
* or the replacement of missing values of a stream. <p>
*
* Not applicable to pure stream-type transformations (i.e. which
* are not of the vector type, e.g. NontransactionalToTransactional).
*/
public abstract class VectorTransformationStream extends com.prudsys.pdm.Cwm.Core.Class
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Source input stream for transformation. */
protected MiningInputStream inputStream = null;
/** List of attributes excluded from transformation. */
protected Vector excludedAttributeNames = null;
/** Mining transformation step containg the transformation. */
protected MiningTransformationStep mts = null;
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public VectorTransformationStream()
{
}
/**
* Constructor for given stream.
*
* @param inputStream source mining input stream for transformation
*/
public VectorTransformationStream(MiningInputStream inputStream) {
this.inputStream = inputStream;
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Returns source mining input stream for transformation.
*
* @return source mining input stream for transformation
*/
public MiningInputStream getInputStream()
{
return inputStream;
}
/**
* Sets new source mining input stream for transformation.
*
* @param inputStream new source mining input stream
*/
public void setInputStream(MiningInputStream inputStream)
{
this.inputStream = inputStream;
}
/**
* Returns name of (first) attribute excluded from transformation.
* If defined, this is usually the target attribute name in
* supervised mining.
*
* @return name of attribute excluded from transformation, null if not defined
*/
public String getExcludedAttributeName()
{
if (excludedAttributeNames == null && excludedAttributeNames.size() > 0)
return (String) excludedAttributeNames.elementAt(0);
else
return null;
}
/**
* Sets name of (first) attribute excluded from transformation.
* If defined, this is usually the target attribute name in
* supervised mining.
*
* @param excludedAttributeName new name of attribute excluded from transformation,
* null if not defined
*/
public void setExcludedAttributeName(String excludedAttributeName)
{
if (excludedAttributeName == null)
excludedAttributeNames = null;
else {
excludedAttributeNames = new Vector();
excludedAttributeNames.addElement(excludedAttributeName);
}
}
/**
* Adds excluded attribute name to array of attributes to be excluded
* from transformation.
*
* @param excludedAttributeName new name of attribute excluded from transformation
*/
public void addExcludedAttributeName(String excludedAttributeName) {
if (excludedAttributeNames == null)
excludedAttributeNames = new Vector();
excludedAttributeNames.addElement(excludedAttributeName);
}
/**
* Returns array of attributes excluded from transformation.
*
* @return array of attributes excluded from transformation, null if not defined
*/
public Vector getExcludedAttributeNames() {
return excludedAttributeNames;
}
/**
* Sets array of attributes excluded from transformation.
*
* @param excludedAttributeNames new array of excluded attributes, null if not defined
*/
public void setExcludedAttributeNames(Vector excludedAttributeNames) {
this.excludedAttributeNames = excludedAttributeNames;
}
/**
* Returns mining transformation step containing the transformation.
*
* @return mining transformation step, null if not calculated
*/
public MiningTransformationStep getMiningTransformationStep()
{
return mts;
}
// -----------------------------------------------------------------------
// Transformation methods
// -----------------------------------------------------------------------
/**
* Creates mining transformation step containing the transformation.
*
* @return mining transformation step
* @exception MiningException no input stream defined
*/
public abstract MiningTransformationStep createMiningTransformationStep()
throws MiningException;
/**
* Creates mining input stream by applying the transformations
* to the source input stream. Uses mining filter stream.
*
* @return mining filter stream which applies the transformations
* @exception MiningException cannot create transformed stream
*/
public MiningInputStream createTransformedStream() throws MiningException {
if (mts == null)
mts = createMiningTransformationStep();
MiningFilterStream mfs = new MiningFilterStream(inputStream, mts);
return mfs;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -