📄 rule.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
* @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
* @version 1.2
*/
package com.prudsys.pdm.Models.Classification.Rules;
import com.prudsys.pdm.Input.Predicates.Predicate;
/**
* Class representing a classification rule. Each rule has a predicate as
* premise and a predicate as conclusion. <p>
*
* From PDM CWM extension.
*
* @see com.prudsys.pdm.Input.Predicates.Predicate
*/
public class Rule extends com.prudsys.pdm.Cwm.Core.ModelElement implements com.prudsys.pdm.Core.MiningMatrixElement
{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Premise predicate of rule. */
public Predicate premise;
/** Conclusion predicate of rule. */
public Predicate conclusion;
/** Support of rule. */
public double support;
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public Rule()
{
}
/**
* Constructs rule from two predicates and support value.
*
* @param a predicate to be used as premise
* @param b predicate to be used as conclusion
* @param s support value
*/
public Rule(Predicate a, Predicate b, double s)
{
premise = a;
conclusion = b;
support = s;
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Get the premise predicate.
*
* @return premise predicate
*/
public Predicate getPremise()
{
return premise;
}
/**
* Get the conclusion predicate.
*
* @return conclusion predicate
*/
public Predicate getConclusion()
{
return conclusion;
}
/**
* Get the support of the rule.
*
* @return support value
*/
public double getSupport()
{
return support;
}
// -----------------------------------------------------------------------
// java.lang.Object methods
// -----------------------------------------------------------------------
/**
* Find out if two rule are equal.
* They must have the same premise and conclusion.
* The support value is not compared.
*
* @param obj the rule to compare with
* @return true if equal, otherwise false
*/
public boolean equals(Object obj)
{
Rule r = (Rule) obj;
if ( ! r.getPremise().equals( premise ) ||
! r.getConclusion().equals( conclusion ) )
return false;
return true;
}
/**
* Calculates the hash code.
*
* @return hash code
*/
public int hashCode() {
return premise.hashCode() + conclusion.hashCode();
}
/**
* String representation of rule.
*
* @return String representation of rule
*/
public String toString()
{
String text = "";
text = text + premise.toString()+"\t";
text = text + "==>";
text = text + conclusion.toString()+"\t";
text = text + "Support="+(Math.round((support*1000))/10.0)+"%";
return text;
}
/**
* Prints the rule.
*/
public void print()
{
System.out.println(toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -