⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twostagesmoother.java

📁 用java实现的关联规则算法Apriori算法
💻 JAVA
字号:
package dragon.ir.search.smooth;import dragon.ir.index.*;import dragon.ir.query.SimpleTermPredicate;/** * <p>Two-stage smoother</p> * <p></p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: IST, Drexel University</p> * @author Davis Zhou * @version 1.0 */public class TwoStageSmoother extends AbstractSmoother implements Smoother{    private double bkgCoefficient, dirichletCoefficient;    private int docTermCount;    private long collectionTermCount;    private double docCollectionProb, queryBackgroundProb;    public TwoStageSmoother(IRCollection collection, double bkgCoefficient, double dirichletCoefficient) {        collectionTermCount=collection.getTermCount();        this.bkgCoefficient =bkgCoefficient;        this.dirichletCoefficient =dirichletCoefficient;        this.useLog =true;        this.docFirstOptimal=true;        this.querytermFirstOptimal=true;    }    public boolean setParameters(double[] params){        if(params!=null && params.length>=2)        {            bkgCoefficient=params[0];            dirichletCoefficient=params[1];            return true;        }        else            return false;    }    public void setQueryTerm(SimpleTermPredicate queryTerm){        this.queryWeight =queryTerm.getWeight();        docCollectionProb=dirichletCoefficient* queryTerm.getFrequency()/collectionTermCount;        queryBackgroundProb=bkgCoefficient* queryTerm.getFrequency()/collectionTermCount;    }    public void setDoc(IRDoc doc){        docTermCount=doc.getTermCount();    }    protected double computeSmoothedProb(int termFreq){        return queryWeight*getProb((1-bkgCoefficient)*(termFreq+docCollectionProb)/(docTermCount+dirichletCoefficient)+queryBackgroundProb);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -