org.bigml.binding.localassociation.AssociationRule Maven / Gradle / Ivy
package org.bigml.binding.localassociation;
import java.util.*;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
/**
* Object encapsulating an association rule as described in
* https://bigml.com/developers/associations
*
*/
public class AssociationRule {
private JSONObject rule;
private String ruleId;
private Double confidence;
private Double leverage;
private Integer[] lhs;
private Double[] lhsCover;
private Double pValue;
private Integer[] rhs;
private Double[] rhsCover;
private Double lift;
private Double[] support;
/**
* Constructor
*/
public AssociationRule(final JSONObject ruleInfo) {
super();
this.rule = ruleInfo;
this.ruleId = (String) ruleInfo.get("id");
this.confidence = ((Number) ruleInfo.get("confidence")).doubleValue();
this.leverage = ((Number) ruleInfo.get("leverage")).doubleValue();
this.lhs = parseIntegerJSONArray((JSONArray) ruleInfo.get("lhs"));
this.lhsCover = parseDoubleJSONArray((JSONArray) ruleInfo.get("lhs_cover"));
this.pValue = ((Number) ruleInfo.get("p_value")).doubleValue();
this.rhs = parseIntegerJSONArray((JSONArray) ruleInfo.get("rhs"));
this.rhsCover = parseDoubleJSONArray((JSONArray) ruleInfo.get("rhs_cover"));
this.lift = ((Number) ruleInfo.get("lift")).doubleValue();
this.support = parseDoubleJSONArray((JSONArray) ruleInfo.get("support"));
}
public JSONObject getRule() {
return this.rule;
}
public String getRuleId() {
return this.ruleId;
}
public Double getConfidence() {
return this.confidence;
}
public Double getLeverage() {
return this.leverage;
}
public Integer[] getLhs() {
return this.lhs;
}
public Double[] getLhsCover() {
return this.lhsCover;
}
public Double getPValue() {
return this.pValue;
}
public Integer[] getRhs() {
return this.rhs;
}
public Double[] getRhsCover() {
return this.rhsCover;
}
public Double getLift() {
return this.lift;
}
public Double[] getSupport() {
return this.support;
}
/**
* Transforming the rule to CSV formats
* Metrics ordered as in ASSOCIATION_METRICS in LocalAssociation.java
*/
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy