📄 miningsettings.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 Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
* @version 1.0
*/
package com.prudsys.pdm.Core;
/**
* Parameters for mining activities. Mining settings indicate how the model should
* be or was built. <p>
*
* From CWM Data Mining. <p>
*
* Superclasses:
* <ul>
* <li> Class
* </ul>
* ContainedElements:
* <ul>
* <li> AttributeUsageRelation
* </ul>
* Attributes:
* <ul>
* <li> <i>function</i>: Names the mining function. The following functions
* are predefined: StatisticalAnalysis, FeatureSelection, AssociationRules,
* Classification, Clustering, Regression as well as (from PDM extension)
* Sequential, CustomerSequential, TimeSeriesPrediction. <br>
* - type: String <br>
* - multiplicity: exactly one
* <li> <i>algorithm</i>: Names the algorithm used to perform the mining function.
* The following algorithms are predefined: decisionTree, neuralNetwork, naiveBayes,
* selfOrganizingMap, centerBasedClustering, distributionBasedClustering,
* associationRules, polynomialRegression, radialBasisFunction,
* ruleBasedClassification, principalComponentAnalysis, factorAnalysis,
* bivariateAnalysis, descriptiveAnalysis, geneticAlgorithm as well as
* (from PDM extension) sequenceAnalysis, sequentialBasketAnalysis,
* supportVectorMachine, sparseGrids, nonlinearDecisionTree,
* multidimensionalTimeSeries, hierarchicalClustering,
* partitioningClustering. <br>
* - type: String <br>
* - multiplicity: exactly one
* </ul>
* References:
* <ul>
* <li> <i>attributeUsage</i>: References the AttributeUsageRelation. <br>
* - class: AttributeUsageRelation <br>
* - defined by: ContainsAttributeUsage::attributeUsage <br>
* - multiplicity: one or more
* <li> <i>dataSpecification</i>: References the MiningDataSpecification. <br>
* - class: MiningDataSpecification <br>
* - defined by: UseAsInput::dataSpecification <br>
* - multiplicity: exactly one
* </ul>
*
* @see AttributeUsageRelation
* @see MiningDataSpecification
*/
public class MiningSettings extends com.prudsys.pdm.Cwm.Core.Class
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/**
* Names the mining function. The following functions are predefined:
* StatisticalAnalysis, FeatureSelection, AssociationRules, Classification,
* Clustering, Regression, Sequential, CustomerSequential,
* TimeSeriesPrediction
*/
private String function = "";
/**
* Names the algorithm used to perform the mining function. The following
* algorithms are predefined: decisionTree, neuralNetwork, naiveBayes,
* selfOrganizingMap, centerBasedClustering, distributionBasedClustering,
* associationRules, polynomialRegression, radialBasisFunction,
* ruleBasedClassification, principalComponentAnalysis, factorAnalysis,
* bivariateAnalysis, descriptiveAnalysis, geneticAlgorithm, sequenceAnalysis,
* sequentialBasketAnalysis, supportVectorMachine, sparseGrids,
* nonlinearDecisionTree, multidimensionalTimeSeries, hierarchicalClustering,
* partitioningClustering
*/
private String algorithm = "";
/** Reference to mining model generated using these settings. */
private MiningModel miningModel;
/** Attribute usage relation. */
private AttributeUsageRelation attributeUsage[];
/** Meta data of the settings. */
private MiningDataSpecification dataSpecification;
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public MiningSettings()
{
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Access method for the function property.
*
* @return the current value of the function property
*/
public String getFunction()
{
return function;
}
/**
* Sets the value of the function property.
*
* @param aFunction the new value of the function property
*/
public void setFunction(String aFunction)
{
function = aFunction;
}
/**
* Access method for the algorithm property.
*
* @return the current value of the algorithm property
*/
public String getAlgorithm()
{
return algorithm;
}
/**
* Sets the value of the algorithm property.
*
* @param aAlgorithm the new value of the algorithm property
*/
public void setAlgorithm(String aAlgorithm)
{
algorithm = aAlgorithm;
}
/**
* Returns array of attribute usage relations.
*
* @return array of attribute usage relations
*/
public AttributeUsageRelation[] getAttributeUsage()
{
return attributeUsage;
}
/**
* Sets array of attribute usage relations.
*
* @param attributeUsage new array of attribute usage relations
*/
public void setAttributeUsage(AttributeUsageRelation[] attributeUsage)
{
this.attributeUsage = attributeUsage;
}
/**
* Returns attribute usage object at specified index.
*
* @param usageIndex index of attribute usage object
* @return attribute usage object at specified position, null if not found
*/
public AttributeUsageRelation getAttributeUsage(int usageIndex) {
if (attributeUsage == null ||
usageIndex < 0 || usageIndex >= attributeUsage.length)
return null;
else
return attributeUsage[usageIndex];
}
/**
* Returns attribute usage object with specified attribute name.
*
* @param usageName attribute name of attribute usage object
* @return attribute usage object with given name, null if not found
*/
public AttributeUsageRelation getAttributeUsage(String usageName) {
if (attributeUsage == null || usageName == null)
return null;
for (int i = 0; i < attributeUsage.length; i++)
if ( attributeUsage[i].getAttribute().getName().equals(usageName) )
return attributeUsage[i];
return null;
}
/**
* Returns mining data specification.
*
* @return mining data specification
*/
public MiningDataSpecification getDataSpecification()
{
return dataSpecification;
}
/**
* Sets mining data specification.
*
* @param dataSpecification new mining data specification
*/
public void setDataSpecification(MiningDataSpecification dataSpecification)
{
this.dataSpecification = dataSpecification;
// Create default attribute usage relations:
if (dataSpecification != null) {
int nAtt = dataSpecification.getAttributesNumber();
this.attributeUsage = new AttributeUsageRelation[nAtt];
for (int i = 0; i < nAtt; i++) {
attributeUsage[i] = new AttributeUsageRelation();
attributeUsage[i].setSettings( this );
attributeUsage[i].setAttribute( dataSpecification.getMiningAttribute(i) );
attributeUsage[i].setUsageType( new AttributeUsage(AttributeUsage.ACTIVE) );
}
}
}
/**
* Returns mining model.
*
* @return mining model
*/
public MiningModel getMiningModel()
{
return miningModel;
}
/**
* Sets mining model.
*
* @param miningModel new mining model
*/
public void setMiningModel(MiningModel miningModel)
{
this.miningModel = miningModel;
}
// -----------------------------------------------------------------------
// Verify settings
// -----------------------------------------------------------------------
/**
* Check mining settings for completeness otherwise an exception is thrown.
* This means, that mata data, alfgorithm, and function
* must be specified.
*
* @throws IllegalArgumentException if some settings attributes are incorrect
*/
public void verifySettings() throws IllegalArgumentException
{
if( dataSpecification == null )
{
throw new IllegalArgumentException( "Model metadata data can't be null." );
}
if( function == null )
{
throw new IllegalArgumentException( "Model settings attribute \'function\' can't be null." );
}
if( algorithm == null )
{
throw new IllegalArgumentException( "Model settings attribute \'algorithm\' can't be null." );
}
}
// -----------------------------------------------------------------------
// HTML export
// -----------------------------------------------------------------------
/**
* Returns HTML string of mining settings.
*
* @return HTML string of mining settings
*/
public String toHtmlString()
{
String description = "mining settings";
return description;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -