// end class class CRFBiasedClassifierOptimizer /// <summary>Adjust the bias parameter to optimize some objective function.</summary> /// <remarks> /// Adjust the bias parameter to optimize some objective function. /// Note that this function only tunes the bias parameter of one class /// (class of index 0), and is thus only useful for binary classification /// problems. /// </remarks> public virtual void AdjustBias(IList <IList <IN> > develData, IDoubleUnaryOperator evalFunction, double low, double high) { ILineSearcher ls = new GoldenSectionLineSearch(true, 1e-2, low, high); CRFBiasedClassifier.CRFBiasedClassifierOptimizer optimizer = new CRFBiasedClassifier.CRFBiasedClassifierOptimizer(this, this, evalFunction); double optVal = ls.Minimize(optimizer); int bi = featureIndex.IndexOf(Bias); log.Info("Class bias of " + weights[bi][0] + " reaches optimal value " + optVal); }
private void TuneSigma(int[][] data, int[] labels) { IDoubleUnaryOperator CVSigmaToPerplexity = null; //test if enough training data //leave-one-out //System.out.println("CV j: "+ j); //System.out.println("test i: "+ i + " "+ new BasicDatum(featureIndex.objects(data[i]))); //System.err.printf("%d: %8g%n", j, score); GoldenSectionLineSearch gsls = new GoldenSectionLineSearch(true); sigma = gsls.Minimize(CVSigmaToPerplexity, 0.01, 0.0001, 2.0); System.Console.Out.WriteLine("Sigma used: " + sigma); }