📄 customersequentialsettings.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: Java Data Mining API. Supported standarts: <a href="http://www.dmg.org">Predictive Model Markup Language (PMML 2.0) </a>; <a href="http://www.omg.org/cwm">DataMining specification for Common Warehouse Metamodel (OMG)</a>.
* Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
* Company: <a href="mailto:valentine.stepanenko@zsoft.ru">ZSoft, Spb, Russia</a>
* @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
* @version 1.0
*/
package com.prudsys.pdm.Models.CustomerSeq;
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 customer sequences (aka sequential basket
* analysis). <p>
*
* From PDM CWM extension. <p>
*
* Superclasses:
* <ul>
* <li> MiningSettings
* </ul>
* Attributes:
* <ul>
* <li> <i>minimumSupport</i>: The minimum support required for larger customer sequences. <br>
* - type: Float <br>
* - multiplicity: exactly one
* <li> <i>minimumConfidence</i>: The minimum confidence required for customer sequence rules. <br>
* - type: Float <br>
* - multiplicity: exactly one
* <li> <i>generateRules</i>: Flag for generating customer 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>customerId</i>: Reference MiningAttribute as Customer ID. <br>
* - class: MiningAttribute <br>
* - multiplicity: exactly one
* <li> <i>transactionPosition</i>: Reference MiningAttribute as Transaction Position. <br>
* - class: MiningAttribute <br>
* - multiplicity: exactly one
* </ul>
*
* @see MiningAttribute
*/
public class CustomerSequentialSettings extends MiningSettings {
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Minimum support of customer sequences. */
private double minimumSupport;
/** Minimum confidence of customer sequences. */
private double minimumConfidence;
/** Generate rules from customer sequences. */
private boolean generateRules = false;
/** Attribute containing item ID. */
private MiningAttribute itemId;
/** Attribute containing customer ID. */
private MiningAttribute customerId;
/** Attribute containing transaction position. */
private MiningAttribute transactionPosition;
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public CustomerSequentialSettings()
{
this.setFunction( MiningModel.CUSTOMER_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;
}
/**
* Gets mining attribute of customerId.
*
* @return attribute of customerId
*/
public MiningAttribute getCustomerId()
{
return customerId;
}
/**
* Sets mining attribute of customerId.
*
* @param customerId attribute of customerId
*/
public void setCustomerId(MiningAttribute customerId)
{
this.customerId = customerId;
}
/**
* Gets mining attribute of transactionPosition.
*
* @return attribute of transactionPosition
*/
public MiningAttribute getTransactionPosition()
{
return transactionPosition;
}
/**
* Sets mining attribute of transactionPosition.
*
* @param transactionPosition attribute of transactionPosition
*/
public void setTransactionPosition(MiningAttribute transactionPosition)
{
this.transactionPosition = transactionPosition;
}
/**
* Gets minimum support value.
*
* @return value of minimum support
*/
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 customer sequences?
*
* @return true if generate rules from sequences, otherwise false
*/
public boolean isGenerateRules()
{
return generateRules;
}
/**
* Set generate rules from customer 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, customerId, and
* transactionPosition 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( customerId == null )
{
throw new IllegalArgumentException( "Attribute customerId can't be null." );
}
if( !(customerId instanceof CategoricalAttribute) )
{
throw new IllegalArgumentException( "Attribute customerId must be categorical." );
}
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(transactionPosition == null )
{
throw new IllegalArgumentException( "Attribute transactionPosition can't be null." );
}
if( !(transactionPosition instanceof NumericAttribute) )
{
throw new IllegalArgumentException( "Attribute transactionPosition must be numeric." );
}
}
// -----------------------------------------------------------------------
// Export methods
// -----------------------------------------------------------------------
/**
* Returns settings as string.
*
* @return settings as string
*/
public String toString()
{
String description = "Customer sequential (" +
"Support=" + minimumSupport + "; ";
if (generateRules) description = description + "Confidence=" + minimumConfidence;
description = description +
"Transaction attribute=\"" + transactionPosition + "\"; " +
"Item attribute=\"" + itemId + "\"; " +
"Customer attribute=\"" + customerId + "\")";
return description;
}
/**
* Returns settings as HTML string.
*
* @return settings as HTML string
*/
public String toHtmlString()
{
String description = "Model: CustomerSequential<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?minimumSupport>Support = <font color=blue><b>" + minimumSupport + "</b></color></a><br>" +
"<a href=http://this?transactionId>Transaction attribute = <font color=blue><b>" + transactionPosition + "</b></color></a><br>" +
"<a href=http://this?itemId>Item attribute = <font color=blue><b>" + itemId + "</b></color></a><br>" +
"<a href=http://this?customerId>Customer attribute = <font color=blue><b>" + customerId + "</b></color></a>";
return description;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -