📄 sequentialsettings.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 Victor Borichev
* @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
* @version 1.0
*/
package com.prudsys.pdm.Models.Sequential;
import com.prudsys.pdm.Core.CategoricalAttribute;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Core.MiningModel;
import com.prudsys.pdm.Core.MiningSettings;
import com.prudsys.pdm.Core.NumericAttribute;
/**
* Parameters for computing sequences. <p>
*
* From PDM CWM extension. <p>
*
* Superclasses:
* <ul>
* <li> MiningSettings
* </ul>
* Attributes:
* <ul>
* <li> <i>minimumSupport</i>: The minimum support required for large sequences. <br>
* - type: Float <br>
* - multiplicity: exactly one
* <li> <i>minimumConfidence</i>: The minimum confidence required for sequence rules. <br>
* - type: Float <br>
* - multiplicity: exactly one
* <li> <i>generateRules</i>: Flag for generating sequence rules. <br>
* - type: Boolean <br>
* - multiplicity: exactly one
* </ul>
*
* References:
* <ul>
* <li> <i>itemId</i>: Reference MiningAttribute as Item ID. <br>
* - class: MiningAttribute <br>
* - defined by: UsesItemId::itemID <br>
* - multiplicity: exactly one
* <li> <i>transactionId</i>: Reference MiningAttribute as Transaction ID. <br>
* - class: MiningAttribute <br>
* - defined by: UsedTransactionId::transactionID <br>
* - multiplicity: exactly one
* <li> <i>itemIndex</i>: Reference MiningAttribute as Item Index. <br>
* - class: MiningAttribute <br>
* - multiplicity: exactly one
* </ul>
*/
public class SequentialSettings extends MiningSettings
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/**
* Minimum support of sequences.
*/
private double minimumSupport;
/**
* Minimum confidence of sequences.
*/
private double minimumConfidence;
/**
* Generate rules from sequences.
*/
private boolean generateRules = false;
/**
* Attribute containing item ID.
*/
private MiningAttribute itemId;
/**
* Attribute containing transaction ID.
*/
private MiningAttribute transactionId;
/**
* Attribute containing item index.
*/
private MiningAttribute itemIndex;
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public SequentialSettings()
{
this.setFunction( MiningModel.SEQUENTIAL_FUNCTION );
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Gets mining attribute of itemId.
*
* @return attribute of itemId
*/
public MiningAttribute getItemId()
{
return itemId;
}
/**
* Sets mining attribute of itemId.
*
* @param itemId attribute of itemId
*/
public void setItemId(MiningAttribute itemId)
{
this.itemId = itemId;
}
/**
* Get mining attribute of transactionId.
*
* @return attribute of transactionId
*/
public MiningAttribute getTransactionId()
{
return transactionId;
}
/**
* Set mining attribute of transactionId.
*
* @param transactionId attribute of transactionId
*/
public void setTransactionId(MiningAttribute transactionId)
{
this.transactionId = transactionId;
}
/**
* Gets mining attribute of itemIndex.
*
* @return attribute of itemIndex
*/
public MiningAttribute getItemIndex()
{
return itemIndex;
}
/**
* Sets mining attribute of itemIndex.
*
* @param itemIndex attribute of itemIndex
*/
public void setItemIndex(MiningAttribute itemIndex)
{
this.itemIndex = itemIndex;
}
/**
* Gets minimum support value.
*
* @return minimum support value
*/
public double getMinimumSupport()
{
return minimumSupport;
}
/**
* Sets minimum support value.
*
* @param minimumSupport minimum support value
*/
public void setMinimumSupport(double minimumSupport)
{
this.minimumSupport = minimumSupport;
}
/**
* Gets minimum confidence value.
*
* @return minimum confidence value
*/
public double getMinimumConfidence()
{
return minimumConfidence;
}
/**
* Sets minimum confidence value.
*
* @param minimumConfidence minimum confidence value
*/
public void setMinimumConfidence(double minimumConfidence)
{
this.minimumConfidence = minimumConfidence;
}
/**
* Generate rules from sequences?
*
* @return true if generate rules from sequences, otherwise false
*/
public boolean isGenerateRules()
{
return generateRules;
}
/**
* Set generate rules from sequences.
*
* @param generateRules generate rules from sequences
*/
public void setGenerateRules(boolean generateRules)
{
this.generateRules = generateRules;
}
// -----------------------------------------------------------------------
// Verify settings
// -----------------------------------------------------------------------
/**
* Verify settings. Call super class method (of MiningSettings) for
* verifying settings and checks whether itemId, transactionId, and
* itemIndex attributes are defined. If settings are incomplete an
* illegal argument exception is thrown.
*
* @exception IllegalArgumentException exception that is thrown for incomplete settings
*/
public void verifySettings() throws IllegalArgumentException
{
super.verifySettings();
if (minimumSupport <= 0)
{
throw new IllegalArgumentException( "minimumSupport must be positive." );
}
if (minimumSupport > 1)
{
throw new IllegalArgumentException( "minimumSupport can't be larger than 1 (100%)." );
}
if (minimumConfidence < 0 && generateRules)
{
throw new IllegalArgumentException( "minimumConfidence can't be negative." );
}
if (minimumConfidence > 1 && generateRules)
{
throw new IllegalArgumentException( "minimumConfidence can't be larger than 1 (100%)." );
}
if( itemId == null )
{
throw new IllegalArgumentException( "Attribute itemId can't be null." );
}
if( !(itemId instanceof CategoricalAttribute) )
{
throw new IllegalArgumentException( "Attribute itemId must be categorical." );
}
if( transactionId == null )
{
throw new IllegalArgumentException( "Attribute transactionId can't be null." );
}
if( !(transactionId instanceof CategoricalAttribute) )
{
throw new IllegalArgumentException( "Attribute transactionId must be categorical." );
}
if( itemIndex == null )
{
throw new IllegalArgumentException( "Attribute itemIndex can't be null." );
}
if( !(itemIndex instanceof NumericAttribute) )
{
throw new IllegalArgumentException( "Attribute itemIndex must be numeric." );
}
}
// -----------------------------------------------------------------------
// Export methods
// -----------------------------------------------------------------------
/**
* Returns settings as string.
*
* @return settings as string
*/
public String toString()
{
String description = "Sequential (" +
"Support=" + minimumSupport + "; ";
if (generateRules) description = description + "Confidence=" + minimumConfidence;
description = description +
"Transaction attribute=\"" + transactionId + "\"; " +
"Item attribute=\"" + itemId + "\"; " +
"Item order attribute=\"" + itemIndex + "\")";
return description;
}
/**
* Returns settings as HTML string.
*
* @return settings as HTML string
*/
public String toHtmlString()
{
String description = "Model: Sequential<br>" +
"<a href=http://this?minimumSupport>Support = <font color=blue><b>" + minimumSupport + "</b></color></a><br>";
if (generateRules) description = description + "<a href=http://this?minimumConfidence>Confidence = <font color=blue><b>" + minimumConfidence + "</b></font></a><br>";
description = description +
"<a href=http://this?transactionId>Transaction attribute = <font color=blue><b>" + transactionId + "</b></color></a><br>" +
"<a href=http://this?itemId>Item attribute = <font color=blue><b>" + itemId + "</b></color></a><br>" +
"<a href=http://this?itemIndex>Item order attribute = <font color=blue><b>" + itemIndex + "</b></color></a>";
return description;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -