📄 associationrulessettings.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.Models.AssociationRules;
import com.prudsys.pdm.Core.CategoricalAttribute;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Core.MiningModel;
import com.prudsys.pdm.Core.MiningSettings;
/**
* Parameters for computing association rules. <p>
*
* From CWM Data Mining. <p>
*
* Superclasses:
* <ul>
* <li> MiningSettings
* </ul>
* Attributes:
* <ul>
* <li> <i>minimumSupport</i>: The minimum support required for large itemsets. <br>
* - type: Float <br>
* - multiplicity: exactly one
* <li> <i>minimumConfidence</i>: The minimum confidence required for association rules. <br>
* - type: Float <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
* </ul>
* Constraints:
* <ul>
* <li> Function must specify "AssociationRules".
* </ul>
*
* @see MiningAttribute
* @see MiningSettings
*/
public class AssociationRulesSettings extends MiningSettings
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/**
* The minimum support required for association rules.
*/
private double minimumSupport;
/**
* The minimum confidence required for association rules.
*/
private double minimumConfidence;
/**
* Attribute containing item ID.
*/
private MiningAttribute itemId;
/**
* Attribute containing transaction ID.
*/
private MiningAttribute transactionId;
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
/**
* @roseuid 3C5EAF3A0105
*/
public AssociationRulesSettings()
{
this.setFunction( MiningModel.ASSOCIATION_RULES_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 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;
}
// -----------------------------------------------------------------------
// Verify settings
// -----------------------------------------------------------------------
/**
* Verify settings. Call super class method (of MiningSettings) for
* verifying settings and checks whether itemId and transactionId 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)
{
throw new IllegalArgumentException( "minimumConfidence can't be negative." );
}
if (minimumConfidence > 1)
{
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." );
}
}
// -----------------------------------------------------------------------
// Export methods
// -----------------------------------------------------------------------
/**
* Returns settings as string.
*
* @return settings as string
*/
public String toString()
{
return "Association rules (" +
"Support=" + minimumSupport + "; " +
"Confidence=" + minimumConfidence + "; " +
"Transaction attribute=\"" + transactionId + "\"; " +
"Item attribute=\"" + itemId + "\")";
}
/**
* Returns settings as HTML string.
*
* @return settings as HTML string
*/
public String toHtmlString()
{
String description = "Model: Association rules<br>" +
"<a href=http://this?minimumSupport>Support = <font color=blue><b>" + minimumSupport + "</b></font></a><br>" +
"<a href=http://this?minimumConfidence>Confidence = <font color=blue><b>" + minimumConfidence + "</b></font></a><br>" +
"<a href=http://this?transactionId>Transaction attribute = <font color=blue><b>" + transactionId + "</b></font></a><br>" +
"<a href=http://this?itemId>Item attribute = <font color=blue><b>" + itemId + "</b></font></a>";
return description;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -