public virtual double GetFinalCost(Clusterer.ClustererClassifier classifier)
            {
                while (ExactLoss && !IsComplete())
                {
                    if (hashedCosts.Contains(hash))
                    {
                        ffHits += isTraining;
                        return(hashedCosts[hash]);
                    }
                    DoBestAction(classifier);
                }
                ffMisses += isTraining;
                double cost = EvalUtils.GetCombinedF1(MucWeight, doc.goldClusters, clusters, doc.mentionToGold, mentionToCluster);

                hashedCosts[hash] = cost;
                return(cost);
            }
            public virtual bool DoBestAction(Clusterer.ClustererClassifier classifier)
            {
                bool doMerge = hashedScores[new Clusterer.MergeKey(c1, c2, currentIndex)];

                if (doMerge == null)
                {
                    ICounter <string> features = GetFeatures(doc, c1, c2, globalFeatures[currentIndex]);
                    doMerge = classifier.WeightFeatureProduct(features) > 0;
                    hashedScores[new Clusterer.MergeKey(c1, c2, currentIndex)] = doMerge;
                    sMisses += isTraining;
                }
                else
                {
                    sHits += isTraining;
                }
                DoAction(doMerge);
                return(doMerge);
            }
 public Clusterer(string modelPath)
 {
     random     = new Random(0);
     classifier = new Clusterer.ClustererClassifier(modelPath, LearningRate);
 }
 public Clusterer()
 {
     random     = new Random(0);
     classifier = new Clusterer.ClustererClassifier(LearningRate);
 }
            public virtual Pair <Clusterer.CandidateAction, Clusterer.CandidateAction> GetActions(Clusterer.ClustererClassifier classifier)
            {
                ICounter <string> mergeFeatures = GetFeatures(doc, c1, c2, globalFeatures[currentIndex]);
                double            mergeScore    = Math.Exp(classifier.WeightFeatureProduct(mergeFeatures));

                hashedScores[new Clusterer.MergeKey(c1, c2, currentIndex)] = mergeScore > 0.5;
                Clusterer.State merge = new Clusterer.State(this);
                merge.DoAction(true);
                double mergeB3 = merge.GetFinalCost(classifier);

                Clusterer.State noMerge = new Clusterer.State(this);
                noMerge.DoAction(false);
                double noMergeB3 = noMerge.GetFinalCost(classifier);
                double weight    = doc.mentions.Count / 100.0;
                double maxB3     = Math.Max(mergeB3, noMergeB3);

                return(new Pair <Clusterer.CandidateAction, Clusterer.CandidateAction>(new Clusterer.CandidateAction(mergeFeatures, weight * (maxB3 - mergeB3)), new Clusterer.CandidateAction(new ClassicCounter <string>(), weight * (maxB3 - noMergeB3))));
            }