本文整理汇总了Java中com.rapidminer.operator.learner.associations.Item类的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于com.rapidminer.operator.learner.associations包,在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItemFrequency
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* This method scans the exampleSet and counts the frequency of every item
*
* @param exampleSet
* the exampleSet to be scaned
* @param mapping
* the mapping of attributes to items
*/
private void getItemFrequency(ExampleSet exampleSet, Attribute[] attributes, double[] positiveIndices,
Map<Attribute, Item> mapping) {
// iterate over exampleSet, counting item frequency
for (Example currentExample : exampleSet) {
int i = 0;
for (Attribute attribute : attributes) {
// if attribute is boolean and if attribute is the positive one
// --> increase frequency of item
if (currentExample.getValue(attribute) == positiveIndices[i]) {
mapping.get(attribute).increaseFrequency();
}
i++;
}
}
}
示例2: getFPTree
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* Returns a new FPTree, representing the complete ExampleSet.
*
* @param exampleSet
* is the exampleSet, which shall be represented
* @param mapping
* is the mapping of attributes of the exampleSet to items
*/
private FPTree getFPTree(ExampleSet exampleSet, Attribute[] attributes, double[] positiveIndices,
Map<Attribute, Item> mapping) {
FPTree tree = new FPTree();
for (Example currentExample : exampleSet) {
List<Item> itemSet = new ArrayList<Item>();
int i = 0;
for (Attribute currentAttribute : attributes) {
if (currentExample.getValue(currentAttribute) == positiveIndices[i]) {
itemSet.add(mapping.get(currentAttribute));
}
i++;
}
Collections.sort(itemSet);
tree.addItemSet(itemSet, 1);
}
return tree;
}
示例3: getFilter
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private boolean[] getFilter(AssociationRules rules, Item[] filter, int conjunctionMode, double minRatio) {
boolean[] mapping = new boolean[rules.getNumberOfRules()];
int counter = 0;
for (AssociationRule rule : rules) {
if (getCriterionValue(rule) >= getCriterionMinValue(minRatio)) {
if (checkForItem(filter, rule, conjunctionMode)) {
mapping[counter] = true;
} else {
mapping[counter] = false;
}
} else {
mapping[counter] = false;
}
counter++;
}
return mapping;
}
示例4: acceptItemSet
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private boolean acceptItemSet(FrequentItemSet itemSet, int min, int max, String[] itemNames) {
int size = itemSet.getNumberOfItems();
if (size < min) {
return false;
}
if (size > max) {
return false;
}
if ((itemNames == null) || (itemNames.length == 0)) {
return true;
}
for (Item item : itemSet.getItems()) {
for (String itemName : itemNames) {
if (item.toString().contains(itemName)) {
return true;
}
}
}
return false;
}
示例5: getItemFrequency
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* This method scans the exampleSet and counts the frequency of every item
*
* @param exampleSet
* the exampleSet to be scaned
* @param mapping
* the mapping of attributes to items
*/
private void getItemFrequency(ExampleSet exampleSet, Attribute[] attributes, double[] positiveIndices,
Map<Attribute, Item> mapping) {
// iterate over exampleSet, counting item frequency
int i = 0;
for (Attribute attribute : attributes) {
Item item = mapping.get(attribute);
for (Example currentExample : exampleSet) {
// if attribute is boolean and if attribute is the positive one
// --> increase frequency of item
if (currentExample.getValue(attribute) == positiveIndices[i]) {
item.increaseFrequency();
}
}
i++;
}
}
示例6: getFPTree
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* Returns a new FPTree, representing the complete ExampleSet.
*
* @param exampleSet
* is the exampleSet, which shall be represented
* @param mapping
* is the mapping of attributes of the exampleSet to items
*/
private FPTree getFPTree(ExampleSet exampleSet, Attribute[] attributes, double[] positiveIndices,
Map<Attribute, Item> mapping) {
FPTree tree = new FPTree();
for (Example currentExample : exampleSet) {
List<Item> itemSet = new ArrayList<Item>();
int i = 0;
for (Attribute currentAttribute : attributes) {
if (currentExample.getValue(currentAttribute) == positiveIndices[i]) {
itemSet.add(mapping.get(currentAttribute));
}
i++;
}
Collections.sort(itemSet);
tree.addItemSet(itemSet, 1);
}
return tree;
}
示例7: getFPTree
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* Returns a new FPTree, representing the complete ExampleSet.
*
* @param exampleSet
* is the exampleSet, which shall be represented
* @param mapping
* is the mapping of attributes of the exampleSet to items
*/
private FPTree getFPTree(ExampleSet exampleSet, Attribute[] attributes, double[] positiveIndices, Map<Attribute, Item> mapping) {
FPTree tree = new FPTree();
for (Example currentExample : exampleSet) {
List<Item> itemSet = new ArrayList<Item>();
int i = 0;
for (Attribute currentAttribute : attributes) {
if (currentExample.getValue(currentAttribute) == positiveIndices[i]) {
itemSet.add(mapping.get(currentAttribute));
}
i++;
}
Collections.sort(itemSet);
tree.addItemSet(itemSet, 1);
}
return tree;
}
示例8: getFilter
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private boolean[] getFilter(AssociationRules rules, Item[] filter, int conjunctionMode, double minRatio) {
boolean[] mapping = new boolean[rules.getNumberOfRules()];
int counter = 0;
for (AssociationRule rule : rules) {
if (getCriterionValue(rule) >= getCriterionMinValue(minRatio)) {
if (checkForItem(filter, rule, conjunctionMode)) {
mapping[counter] = true;
} else {
mapping[counter] = false;
}
} else {
mapping[counter] = false;
}
counter++;
}
return mapping;
}
示例9: acceptItemSet
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private boolean acceptItemSet(FrequentItemSet itemSet, int min, int max, String[] itemNames) {
int size = itemSet.getNumberOfItems();
if (size < min)
return false;
if (size > max)
return false;
if ((itemNames == null) || (itemNames.length == 0))
return true;
for (Item item : itemSet.getItems()) {
for (String itemName : itemNames)
if (item.toString().contains(itemName))
return true;
}
return false;
}
示例10: printHeaderTable
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
public String printHeaderTable(int recursionDepth) {
StringBuffer buffer = new StringBuffer();
for (Item item : headerTable.keySet()) {
buffer.append(item.toString());
buffer.append(" : ");
buffer.append(headerTable.get(item).getFrequencies().getFrequency(recursionDepth));
buffer.append(Tools.getLineSeparator());
}
return buffer.toString();
}
示例11: getAttributeMapping
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* This method maps the attributes of the given exampleSet to an Item.
*
* @param exampleSet
* the exampleSet which attributes are mapped
*/
private Map<Attribute, Item> getAttributeMapping(ExampleSet exampleSet) {
// computing Attributes to test, because only boolean attributes are
// used
Map<Attribute, Item> mapping = new HashMap<Attribute, Item>();
for (Attribute attribute : exampleSet.getAttributes()) {
mapping.put(attribute, new BooleanAttributeItem(attribute));
}
return mapping;
}
示例12: removeNonFrequentItems
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private void removeNonFrequentItems(Map<Attribute, Item> mapping, int minFrequency, ExampleSet exampleSet) {
Collection<Attribute> deleteMappings = new ArrayList<Attribute>();
Iterator<Map.Entry<Attribute, Item>> it = mapping.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Attribute, Item> entry = it.next();
if (entry.getValue().getFrequency() < minFrequency) {
deleteMappings.add(entry.getKey());
}
}
for (Attribute attribute : deleteMappings) {
exampleSet.getAttributes().remove(attribute);
}
}
示例13: addItemSet
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
/**
* This method only works at recursiondepth 0, therefore may only be used for tree constructing.
* This method adds a set of Items to the tree of this node. This set of items has to be sorted
* after the frequency of the contained items. This method is recursivly used to expand the tree
* for the given set, by adding a node for the first item and then call this method with the
* remaining set on the new node. The frequency of the set is represented of weight.
* siblingChain is the headerTable, giving this method a startingpoint for finding the other
* nodes of the item to append new nodes
*
* @param itemSet
* the sorted set of items
* @param headerTable
* gives the headertable for finding other nodes of an item
*/
public void addItemSet(Collection<Item> itemSet, Map<Item, Header> headerTable, int weight) {
Iterator<Item> iterator = itemSet.iterator();
if (iterator.hasNext()) {
Item firstItem = iterator.next();
FPTreeNode childNode;
if (!children.containsKey(firstItem)) {
// if this node has no child for this item, create it
childNode = createChildNode(firstItem);
// and add it to childs of this node
children.put(firstItem, childNode);
// update header table:
if (!headerTable.containsKey(firstItem)) {
// if item unknown in headerTable, create new entry
headerTable.put(firstItem, new Header());
}
// append new node to sibling chain of this item
headerTable.get(firstItem).addSibling(childNode);
} else {
// select children for this item if allready existing
childNode = children.get(firstItem);
}
// updating frequency in headerTable
headerTable.get(firstItem).frequencies.increaseFrequency(0, weight);
// updating frequency in this node
childNode.increaseFrequency(0, weight);
// remove added item and make recursiv call on child note
itemSet.remove(firstItem);
childNode.addItemSet(itemSet, headerTable, weight);
}
}
示例14: adjustFilter
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private void adjustFilter() {
int conjunctionMode = conjunctionBox.getSelectedIndex();
Item[] searchFilter = null;
int[] selectedIndices = conclusionList.getSelectedIndices();
if (selectedIndices.length > 0 && selectedIndices.length <= itemArray.length) {
searchFilter = new Item[selectedIndices.length];
int counter = 0;
for (int s : selectedIndices) {
searchFilter[counter++] = itemArray[s];
}
}
double minRatio = criterionMinSlider.getValue() / (double) MAX_VALUE;
fireFilteringEvent(searchFilter, conjunctionMode, minRatio);
}
示例15: checkForItem
import com.rapidminer.operator.learner.associations.Item; //导入依赖的package包/类
private boolean checkForItem(Item[] filter, AssociationRule rule, int conjunctionMode) {
if (filter == null) {
return true;
}
switch (conjunctionMode) {
case AssociationRuleFilterListener.CONJUNCTION_ANY:
List<Item> filterList = Arrays.asList(filter);
Iterator<Item> c = rule.getConclusionItems();
while (c.hasNext()) {
if (filterList.contains(c.next())) {
return true;
}
}
return false;
case AssociationRuleFilterListener.CONJUNCTION_ALL:
for (Item item : filter) {
c = rule.getConclusionItems();
boolean found = false;
while (c.hasNext()) {
if (c.next().equals(item)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
default:
throw new RuntimeException("Illegal filter type index: " + conjunctionMode);
}
}