Exemplo n.º 1
0
        /**
         * Trains an %SVM with optimal parameters
         *
         *     param samples training samples
         *     param layout See ml::SampleTypes.
         *     param responses vector of responses associated with the training samples.
         *     param kFold Cross-validation parameter. The training set is divided into kFold subsets. One
         *         subset is used to test the model, the others form the train set. So, the %SVM algorithm is
         *     param Cgrid grid for C
         *         balanced cross-validation subsets that is proportions between classes in subsets are close
         *         to such proportion in the whole train dataset.
         *
         *     The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
         *     nu, coef0, degree. Parameters are considered optimal when the cross-validation
         *     estimate of the test set error is minimal.
         *
         *     This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
         *     offers rudimentary parameter options.
         *
         *     This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
         *     regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
         *     the usual %SVM with parameters specified in params is executed.
         * return automatically generated
         */
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }

            return(ml_SVM_trainAuto_16(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr()));
        }
Exemplo n.º 2
0
        //javadoc: SVM::trainAuto(samples, layout, responses, kFold, Cgrid)
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            bool retVal = ml_SVM_trainAuto_16(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr());

            return(retVal);
#else
            return(false);
#endif
        }
Exemplo n.º 3
0
        /**
         * Trains an %SVM with optimal parameters
         *
         *     param samples training samples
         *     param layout See ml::SampleTypes.
         *     param responses vector of responses associated with the training samples.
         *     param kFold Cross-validation parameter. The training set is divided into kFold subsets. One
         *         subset is used to test the model, the others form the train set. So, the %SVM algorithm is
         *     param Cgrid grid for C
         *     param gammaGrid grid for gamma
         *     param pGrid grid for p
         *     param nuGrid grid for nu
         *     param coeffGrid grid for coeff
         *         balanced cross-validation subsets that is proportions between classes in subsets are close
         *         to such proportion in the whole train dataset.
         *
         *     The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
         *     nu, coef0, degree. Parameters are considered optimal when the cross-validation
         *     estimate of the test set error is minimal.
         *
         *     This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
         *     offers rudimentary parameter options.
         *
         *     This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
         *     regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
         *     the usual %SVM with parameters specified in params is executed.
         * return automatically generated
         */
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
            if (gammaGrid != null)
            {
                gammaGrid.ThrowIfDisposed();
            }
            if (pGrid != null)
            {
                pGrid.ThrowIfDisposed();
            }
            if (nuGrid != null)
            {
                nuGrid.ThrowIfDisposed();
            }
            if (coeffGrid != null)
            {
                coeffGrid.ThrowIfDisposed();
            }

            return(ml_SVM_trainAuto_12(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr(), gammaGrid.getNativeObjAddr(), pGrid.getNativeObjAddr(), nuGrid.getNativeObjAddr(), coeffGrid.getNativeObjAddr()));
        }
Exemplo n.º 4
0
        //javadoc: SVM::trainAuto(samples, layout, responses, kFold, Cgrid, gammaGrid, pGrid, nuGrid, coeffGrid, degreeGrid)
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
            if (gammaGrid != null)
            {
                gammaGrid.ThrowIfDisposed();
            }
            if (pGrid != null)
            {
                pGrid.ThrowIfDisposed();
            }
            if (nuGrid != null)
            {
                nuGrid.ThrowIfDisposed();
            }
            if (coeffGrid != null)
            {
                coeffGrid.ThrowIfDisposed();
            }
            if (degreeGrid != null)
            {
                degreeGrid.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            bool retVal = ml_SVM_trainAuto_11(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr(), gammaGrid.getNativeObjAddr(), pGrid.getNativeObjAddr(), nuGrid.getNativeObjAddr(), coeffGrid.getNativeObjAddr(), degreeGrid.getNativeObjAddr());

            return(retVal);
#else
            return(false);
#endif
        }