📄 itemsetseq.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;
/**
* Sequential itemset. <p>
*
* In contrast to ItemSet a sequential itemset retains
* the order of the items and there also may
* be multiple items. <br>
*
* Example: 3 7 1 3 5 5 2 <br>
*
* The same example as ItemSet: 1 2 3 5 7 <br>
*
* Sequential itemsets are simply stored as IntVector.
* Addionally, a support count can be set. <p>
*
* From PDM CWM extension.
*
* @author Michael Thess
* @version 1.1, 2001/04/19
*/
public class ItemSetSeq extends com.prudsys.pdm.Cwm.Core.ModelElement implements com.prudsys.pdm.Core.MiningMatrixElement
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Sequential list of items. */
private IntVec itemListSeq;
/** Support count. */
private int supportCount = 0;
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
/**
* Create new list.
*/
public ItemSetSeq() {
itemListSeq = new IntVec();
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Get the support count for the itemset.
*
* @return support count
*/
public int getSupportCount() {
return supportCount;
}
/**
* Set the support count value.
*
* @param suppcount the new support count
*/
public void setSupportCount(int suppcount) {
supportCount = suppcount;
}
/**
* Returns number of sequential itemsets of itemset.
*
* @return number of items
*/
public int getSize() {
return itemListSeq.size();
}
// -----------------------------------------------------------------------
// Item manipulation methods
// -----------------------------------------------------------------------
/**
* Add an item to the itemset. It is appended to the itemset.
*
* @param element the new item to add
* @return true if item added, else false
*/
public boolean addItem(int element) {
itemListSeq.add(element);
return true;
};
/**
* Gets item at specified index.
*
* @param index position of item
* @return item at specified position
*/
public int getItemAt(int index) {
return itemListSeq.get(index);
}
/**
* Remove all items from itemset.
*
* New since version 1.1 to support abstract specification.
*/
public void removeAllItems() {
itemListSeq.clear();
supportCount = 0;
}
// -----------------------------------------------------------------------
// java.lang.Object methods
// -----------------------------------------------------------------------
/**
* Find out if two sequential itemsets are equal.
* They must have the same size and contain the same items in the same order.
* The support count variables are not compared.
*
* @param obj the sequential itemset to compare with
* @return true is equal, otherwise false
*/
public boolean equals(Object obj)
{
ItemSetSeq iss = (ItemSetSeq)obj;
if( getSize() != iss.getSize() ) return false; // different sizes
for( int i=0; i < getSize(); i++ )
if( itemListSeq.get(i) != iss.getItemAt(i)) return false;
return true;
}
/**
* Calculates the hash code.
*
* @return hash code
*/
public int hashCode() {
return itemListSeq.get(0);
}
/**
* String representation of sequential itemset.
*
* @return String representation of itemset
*/
public String toString() {
String text = "";
for (int i = 0; i < getSize(); i++) {
text = text + itemListSeq.get(i);
text = text + "\t";
};
text = text + "SuppCount = " + supportCount;
return text;
}
/**
* Prints all items of the itemset.
*/
public void print() {
System.out.println(toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -