示例#1
0
        /// <summary>
        /// This method will cross validate on the given data and number of folds
        /// to find the optimal C.
        /// </summary>
        /// <remarks>
        /// This method will cross validate on the given data and number of folds
        /// to find the optimal C.  The scorer is how you determine what to
        /// optimize for (F-score, accuracy, etc).  The C is then saved, so that
        /// if you train a classifier after calling this method, that C will be used.
        /// </remarks>
        public virtual void HeldOutSetC(GeneralDataset <L, F> trainSet, GeneralDataset <L, F> devSet, IScorer <L> scorer, ILineSearcher minimizer)
        {
            useAlphaFile = true;
            bool oldUseSigmoid = useSigmoid;

            useSigmoid = false;
            IDoubleUnaryOperator negativeScorer = null;

            C            = minimizer.Minimize(negativeScorer);
            useAlphaFile = false;
            useSigmoid   = oldUseSigmoid;
        }
示例#2
0
        /// <summary>
        /// This method will cross validate on the given data and number of folds
        /// to find the optimal C.
        /// </summary>
        /// <remarks>
        /// This method will cross validate on the given data and number of folds
        /// to find the optimal C.  The scorer is how you determine what to
        /// optimize for (F-score, accuracy, etc).  The C is then saved, so that
        /// if you train a classifier after calling this method, that C will be used.
        /// </remarks>
        public virtual void CrossValidateSetC(GeneralDataset <L, F> dataset, int numFolds, IScorer <L> scorer, ILineSearcher minimizer)
        {
            System.Console.Out.WriteLine("in Cross Validate");
            useAlphaFile = true;
            bool oldUseSigmoid = useSigmoid;

            useSigmoid = false;
            CrossValidator <L, F> crossValidator = new CrossValidator <L, F>(dataset, numFolds);
            IToDoubleFunction <Triple <GeneralDataset <L, F>, GeneralDataset <L, F>, CrossValidator.SavedState> > score = null;
            //train(trainSet,true,true);
            IDoubleUnaryOperator negativeScorer = null;

            C            = minimizer.Minimize(negativeScorer);
            useAlphaFile = false;
            useSigmoid   = oldUseSigmoid;
        }