Ejemplo n.º 1
0
        /**
         * Trains the statistical model
         *
         *     param trainData training data that can be loaded from file using TrainData::loadFromCSV or
         *         created with TrainData::create.
         *         new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
         * return automatically generated
         */
        public bool train(TrainData trainData)
        {
            ThrowIfDisposed();
            if (trainData != null)
            {
                trainData.ThrowIfDisposed();
            }

            return(ml_StatModel_train_12(nativeObj, trainData.getNativeObjAddr()));
        }
Ejemplo n.º 2
0
        //
        // C++:  float cv::ml::StatModel::calcError(Ptr_TrainData data, bool test, Mat& resp)
        //

        /**
         * Computes error on the training or test dataset
         *
         *     param data the training data
         *     param test if true, the error is computed over the test subset of the data, otherwise it's
         *         computed over the training subset of the data. Please note that if you loaded a completely
         *         different dataset to evaluate already trained classifier, you will probably want not to set
         *         the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so
         *         that the error is computed for the whole new set. Yes, this sounds a bit confusing.
         *     param resp the optional output responses.
         *
         *     The method uses StatModel::predict to compute the error. For regression models the error is
         *     computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).
         * return automatically generated
         */
        public float calcError(TrainData data, bool test, Mat resp)
        {
            ThrowIfDisposed();
            if (data != null)
            {
                data.ThrowIfDisposed();
            }
            if (resp != null)
            {
                resp.ThrowIfDisposed();
            }

            return(ml_StatModel_calcError_10(nativeObj, data.getNativeObjAddr(), test, resp.nativeObj));
        }
Ejemplo n.º 3
0
        //javadoc: StatModel::train(trainData)
        public bool train(TrainData trainData)
        {
            ThrowIfDisposed();
            if (trainData != null)
            {
                trainData.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            bool retVal = ml_StatModel_train_12(nativeObj, trainData.getNativeObjAddr());

            return(retVal);
#else
            return(false);
#endif
        }
Ejemplo n.º 4
0
        //
        // C++:  float cv::ml::StatModel::calcError(Ptr_TrainData data, bool test, Mat& resp)
        //

        //javadoc: StatModel::calcError(data, test, resp)
        public float calcError(TrainData data, bool test, Mat resp)
        {
            ThrowIfDisposed();
            if (data != null)
            {
                data.ThrowIfDisposed();
            }
            if (resp != null)
            {
                resp.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            float retVal = ml_StatModel_calcError_10(nativeObj, data.getNativeObjAddr(), test, resp.nativeObj);

            return(retVal);
#else
            return(-1);
#endif
        }