📄 rulesetseq.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 Stefan Ludwig
* @author Michael Thess
* @version 1.1
*/
package com.prudsys.pdm.Models.Sequential;
import com.prudsys.pdm.Core.Category;
/**
* Class representing a sequence rule. <p>
*
* From PDM CWM extension.
*
* @see ItemSetSeq
*/
public class RuleSetSeq extends com.prudsys.pdm.Cwm.Core.ModelElement implements com.prudsys.pdm.Core.MiningMatrixElement
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Premise itemset of rule. */
public ItemSetSeq premise;
/** Conclusion itemset of rule. */
public ItemSetSeq conclusion;
/** Support of rule. */
public double support;
/** Confidence of rule. */
public double confidence;
/** Lift of rule (if defined). */
public double lift = Category.MISSING_VALUE;
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public RuleSetSeq()
{
}
/**
* Constructs rule set from two sequential itemsets and
* support and confidence values.
*
* @param a itemset to be used as premise
* @param b itemset to be used as conclusion
* @param s support value
* @param c confidence value
*/
public RuleSetSeq(ItemSetSeq a, ItemSetSeq b, double s, double c)
{
premise = a;
conclusion = b;
support = s;
confidence = c;
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Get the premise itemset.
*
* @return premise itemset
*/
public ItemSetSeq getPremise()
{
return premise;
}
/**
* Get the conclusion itemset.
*
* @return conclusion itemset
*/
public ItemSetSeq getConclusion()
{
return conclusion;
}
/**
* Get the number of items in rule.
* Obviously, this is the sum of the size of
* both premise and conclusion itemsets.
*
* @return number of items in rule
*/
public int getSize()
{
int size = premise.getSize() + conclusion.getSize();
return size;
}
/**
* Get the support of the rule.
*
* @return support value
*/
public double getSupport()
{
return support;
}
/**
* Set the confidence of the rule.
*
* @return confidence value
*/
public double getConfidence()
{
return confidence;
}
/**
* Get the lift of the rule.
*
* @return lift value
*/
public double getLift()
{
return lift;
}
/**
* Set lift of the rule.
*
* @param lift new lift value
*/
public void setLift(double lift)
{
this.lift = lift;
}
// -----------------------------------------------------------------------
// java.lang.Object methods
// -----------------------------------------------------------------------
/**
* String representation of rule set.
*
* @return String representation
*/
public String toString()
{
String text = "";
for (int i = 0; i < premise.getSize(); i++)
text = text + premise.getItemAt(i)+"\t";
text = text + "==>";
for (int i = 0; i < conclusion.getSize(); i++)
text = text + conclusion.getItemAt(i)+"\t";
text = text + "Support="+(Math.round((support*1000))/10.0)+"%";
text = text + "\tConfidence="+(Math.round((confidence*1000))/10.0)+"%";
if ( !Category.isMissingValue(lift) )
text = text + "\tLift="+(Math.round((lift*1000))/10.0)+"%";
return text;
}
/**
* Prints the sequence rule.
*/
public void print()
{
System.out.println(toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -