本文整理汇总了Java中com.rapidminer.operator.learner.associations.AssociationRule类的典型用法代码示例。如果您正苦于以下问题:Java AssociationRule类的具体用法?Java AssociationRule怎么用?Java AssociationRule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssociationRule类属于com.rapidminer.operator.learner.associations包,在下文中一共展示了AssociationRule类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfidence
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
private double getConfidence(AssociationRule currentRule, double currentSummedConfidence, int selectedAggregation) {
switch (selectedAggregation) {
case BINARY:
return 1;
case MAX_CONFIDENCE:
return Math.max(currentSummedConfidence, currentRule.getConfidence());
case MAX_CONVICTION:
return Math.max(currentSummedConfidence, currentRule.getConviction());
case MAX_GAIN:
return Math.max(currentSummedConfidence, currentRule.getGain());
case MAX_LA_PLACE:
return Math.max(currentSummedConfidence, currentRule.getLaplace());
case MAX_LIFT:
return Math.max(currentSummedConfidence, currentRule.getLift());
}
return 0;
}
示例2: getFilter
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的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;
}
示例3: getCriterionValue
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
private double getCriterionValue(AssociationRule rule) {
int criterionSelection = criterionSelectorBox.getSelectedIndex();
switch (criterionSelection) {
case AssociationRuleGenerator.LIFT:
return rule.getLift();
case AssociationRuleGenerator.CONVICTION:
return rule.getConviction();
case AssociationRuleGenerator.PS:
return rule.getPs();
case AssociationRuleGenerator.GAIN:
return rule.getGain();
case AssociationRuleGenerator.LAPLACE:
return rule.getLaplace();
case AssociationRuleGenerator.CONFIDENCE:
default:
return rule.getConfidence();
}
}
示例4: createTooltip
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
/**
* Create the tooltip for a rule.
*
* @param rule
* the rule for which to create the tooltip
* @param ruleIndex
* the index of the rule
* @return the HTML-formatted tooltip string
*/
private String createTooltip(AssociationRule rule, int ruleIndex) {
StringBuilder sb = new StringBuilder();
sb.append("<html><div style=\"font-size: 10px; font-family: 'Open Sans'\">");
sb.append("<p style=\"font-size: 110%; text-align: center; font-family: 'Open Sans Semibold'\"><b>Rule " + ruleIndex
+ "</b><hr NOSHADE style=\"color: '#000000'; width: 95%; \"/></p>");
sb.append(SwingTools.transformToolTipText(
formatDependencies(rule.getPremiseItems()) + " \u2794 " + formatDependencies(rule.getConclusionItems()),
false, 200, false, false) + "<br/>");
sb.append("Support: " + Tools.formatNumber(rule.getTotalSupport(), 2) + "<br/>");
sb.append("Confidence: " + Tools.formatNumber(rule.getConfidence(), 2) + "<br/>");
sb.append("Lift: " + Tools.formatNumber(rule.getLift(), 2) + "<br/>");
sb.append("Gain: " + Tools.formatNumber(rule.getGain(), 2) + "<br/>");
sb.append("Conviction: " + Tools.formatNumber(rule.getConviction(), 2) + "<br/>");
sb.append("Laplace: " + Tools.formatNumber(rule.getLaplace(), 2) + "<br/>");
sb.append("Ps: " + Tools.formatNumber(rule.getPs(), 2));
sb.append("</div></html>");
return sb.toString();
}
示例5: getConfidence
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
private double getConfidence(AssociationRule currentRule, double currentSummedConfidence, int selectedAggregation) {
switch (selectedAggregation) {
case BINARY:
return 1;
case MAX_CONFIDENCE:
return Math.max(currentSummedConfidence, currentRule.getConfidence());
case MAX_CONVICTION:
return Math.max(currentSummedConfidence, currentRule.getConviction());
case MAX_GAIN:
return Math.max(currentSummedConfidence, currentRule.getGain());
case MAX_LA_PLACE:
return Math.max(currentSummedConfidence, currentRule.getLaplace());
case MAX_LIFT:
return Math.max(currentSummedConfidence, currentRule.getLift());
}
return 0;
}
示例6: getFilter
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的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;
}
示例7: getCriterionValue
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
private double getCriterionValue(AssociationRule rule) {
int criterionSelection = criterionSelectorBox.getSelectedIndex();
switch (criterionSelection) {
case AssociationRuleGenerator.LIFT:
return rule.getLift();
case AssociationRuleGenerator.CONVICTION:
return rule.getConviction();
case AssociationRuleGenerator.PS:
return rule.getPs();
case AssociationRuleGenerator.GAIN:
return rule.getGain();
case AssociationRuleGenerator.LAPLACE:
return rule.getLaplace();
case AssociationRuleGenerator.CONFIDENCE:
default:
return rule.getConfidence();
}
}
示例8: getGraphCreator
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
@Override
public GraphCreator<String, String> getGraphCreator(Object renderable, IOContainer ioContainer) {
AssociationRules rules = (AssociationRules) renderable;
int numberOfRules = rules.getNumberOfRules();
if (numberOfRules > 0) {
if (numberOfRules > MAX_RULE_NUMBER) {
List<AssociationRule> ruleList = new ArrayList<AssociationRule>(numberOfRules);
for (int i = 0; i < numberOfRules; ++i) {
ruleList.add(rules.getRule(i));
}
Collections.sort(ruleList, new Comparator<AssociationRule>() {
@Override
public int compare(AssociationRule rule1, AssociationRule rule2) {
if (rule1.getConfidence() == rule2.getConfidence()) {
return 0;
} else if (rule1.getConfidence() < rule2.getConfidence()) {
return -1;
} else {
return 1;
}
}
});
AssociationRules filteredRules = new AssociationRules();
for (int i = 0; i < MAX_RULE_NUMBER; ++i) {
filteredRules.addItemRule(ruleList.get(i));
}
rules = filteredRules;
}
return new AssociationRulesGraphCreator(rules);
} else {
return null;
}
}
示例9: checkForItem
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的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);
}
}
示例10: getValueAt
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
AssociationRule rule = rules.getRule(this.mapping[rowIndex]);
switch (columnIndex) {
case COLUMN_RULE_ID:
return Integer.valueOf(this.mapping[rowIndex] + 1);
case COLUMN_PREMISES:
return getItemString(rule.getPremiseItems());
case COLUMN_CONCLUSION:
return getItemString(rule.getConclusionItems());
case COLUMN_SUPPORT:
return Double.valueOf(rule.getTotalSupport());
case COLUMN_CONFIDENCE:
return Double.valueOf(rule.getConfidence());
case COLUMN_CONVICTION:
return Double.valueOf(rule.getConviction());
case COLUMN_GAIN:
return Double.valueOf(rule.getGain());
case COLUMN_PS:
return Double.valueOf(rule.getPs());
case COLUMN_LIFT:
return Double.valueOf(rule.getLift());
case COLUMN_LA_PLACE:
return Double.valueOf(rule.getLaplace());
default:
// cannot happen
return "?";
}
}
示例11: getGraphCreator
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
@Override
public GraphCreator<String, String> getGraphCreator(Object renderable, IOContainer ioContainer) {
AssociationRules rules = (AssociationRules) renderable;
int numberOfRules = rules.getNumberOfRules();
if (numberOfRules > 0) {
if (numberOfRules > MAX_RULE_NUMBER) {
List<AssociationRule> ruleList = new ArrayList<AssociationRule>(numberOfRules);
for (int i = 0; i < numberOfRules; ++i) {
ruleList.add(rules.getRule(i));
}
Collections.sort(ruleList, new Comparator<AssociationRule>() {
@Override
public int compare(AssociationRule rule1, AssociationRule rule2) {
if (rule1.getConfidence() == rule2.getConfidence()) {
return 0;
} else if (rule1.getConfidence() < rule2.getConfidence()) {
return -1;
} else {
return 1;
}
}
});
AssociationRules filteredRules = new AssociationRules();
for (int i = 0; i < MAX_RULE_NUMBER; ++i) {
filteredRules.addItemRule(ruleList.get(i));
}
rules = filteredRules;
}
rules.sort();
return new AssociationRulesGraphCreator(rules);
} else {
return null;
}
}
示例12: getGraphCreator
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
@Override
public GraphCreator<String, String> getGraphCreator(Object renderable, IOContainer ioContainer) {
AssociationRules rules = (AssociationRules) renderable;
int numberOfRules = rules.getNumberOfRules();
if (numberOfRules > 0) {
if (numberOfRules > MAX_RULE_NUMBER ) {
List<AssociationRule> ruleList = new ArrayList<AssociationRule>(numberOfRules);
for(int i = 0; i < numberOfRules; ++i) {
ruleList.add(rules.getRule(i));
}
Collections.sort(ruleList, new Comparator<AssociationRule>() {
@Override
public int compare(AssociationRule rule1, AssociationRule rule2) {
if(rule1.getConfidence() == rule2.getConfidence()) {
return 0;
} else if(rule1.getConfidence() < rule2.getConfidence()) {
return -1;
} else {
return 1;
}
}
});
AssociationRules filteredRules = new AssociationRules();
for(int i = 0; i < MAX_RULE_NUMBER; ++i) {
filteredRules.addItemRule(ruleList.get(i));
}
rules = filteredRules;
}
return new AssociationRulesGraphCreator(rules);
} else {
return null;
}
}
示例13: checkForItem
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的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);
}
}
示例14: getValueAt
import com.rapidminer.operator.learner.associations.AssociationRule; //导入依赖的package包/类
public Object getValueAt(int rowIndex, int columnIndex) {
AssociationRule rule = rules.getRule(this.mapping[rowIndex]);
switch (columnIndex) {
case COLUMN_RULE_ID:
return Integer.valueOf(this.mapping[rowIndex] + 1);
case COLUMN_PREMISES:
return getItemString(rule.getPremiseItems());
case COLUMN_CONCLUSION:
return getItemString(rule.getConclusionItems());
case COLUMN_SUPPORT:
return Double.valueOf(rule.getTotalSupport());
case COLUMN_CONFIDENCE:
return Double.valueOf(rule.getConfidence());
case COLUMN_CONVICTION:
return Double.valueOf(rule.getConviction());
case COLUMN_GAIN:
return Double.valueOf(rule.getGain());
case COLUMN_PS:
return Double.valueOf(rule.getPs());
case COLUMN_LIFT:
return Double.valueOf(rule.getLift());
case COLUMN_LA_PLACE:
return Double.valueOf(rule.getLaplace());
default:
// cannot happen
return "?";
}
}