Beispiel #1
0
        /// <summary>
        /// 学習データを与えて初期化
        /// </summary>
        /// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
#else
		/// <summary>
        /// Training constructor
        /// </summary>
        /// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
#endif
		public CvBoost(
            CvMat trainData, 
            DTreeDataLayout tflag, 
            CvMat responses, 
			CvMat varIdx = null, 
            CvMat sampleIdx = null, 
            CvMat varType = null, 
            CvMat missingMask = null, 
            CvBoostParams param = null)
		{    
			if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

            if (param == null)
                param = new CvBoostParams();

			ptr = NativeMethods.ml_Boost_new_CvMat(
				trainData.CvPtr, 
				(int)tflag,
				responses.CvPtr,
				Cv2.ToPtr(varIdx), 
                Cv2.ToPtr(sampleIdx), 
                Cv2.ToPtr(varType), 
                Cv2.ToPtr(missingMask),
				param.CvPtr
			);
		}
Beispiel #2
0
        /// <summary>
        /// ブーストされた分類器の学習
        /// </summary>
        /// <param name="trainData"></param>
        /// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
        /// <param name="update"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// Trains boosted tree classifier
        /// </summary>
        /// <param name="trainData"></param>
        /// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
        /// <param name="update"></param>
        /// <returns></returns>
#endif
        public virtual bool Train(
            Mat trainData,
            DTreeDataLayout tflag,
            Mat responses,
            Mat varIdx          = null,
            Mat sampleIdx       = null,
            Mat varType         = null,
            Mat missingMask     = null,
            CvBoostParams param = null,
            bool update         = false)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException("trainData");
            }
            if (responses == null)
            {
                throw new ArgumentNullException("responses");
            }
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

            if (param == null)
            {
                param = new CvBoostParams();
            }

            int ret = NativeMethods.ml_CvBoost_train_Mat(
                ptr,
                trainData.CvPtr,
                (int)tflag,
                responses.CvPtr,
                Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask),
                param.CvPtr,
                update ? 1 : 0);

            return(ret != 0);
        }
Beispiel #3
0
        /// <summary>
        /// 学習データを与えて初期化
        /// </summary>
        /// <param name="trainData"></param>
        /// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
#else
        /// <summary>
        /// Training constructor
        /// </summary>
        /// <param name="trainData"></param>
        /// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
#endif
        public CvBoost(
            CvMat trainData,
            DTreeDataLayout tflag,
            CvMat responses,
            CvMat varIdx        = null,
            CvMat sampleIdx     = null,
            CvMat varType       = null,
            CvMat missingMask   = null,
            CvBoostParams param = null)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException("trainData");
            }
            if (responses == null)
            {
                throw new ArgumentNullException("responses");
            }
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

            if (param == null)
            {
                param = new CvBoostParams();
            }

            ptr = NativeMethods.ml_CvBoost_new_CvMat(
                trainData.CvPtr,
                (int)tflag,
                responses.CvPtr,
                Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask),
                param.CvPtr
                );
        }
Beispiel #4
0
        /// <summary>
        /// ブーストされた分類器の学習
        /// </summary>
        /// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
		/// <param name="update"></param>
		/// <returns></returns>
#else
        /// <summary>
        /// Trains boosted tree classifier
        /// </summary>
        /// <param name="trainData"></param>
        /// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <param name="param"></param>
        /// <param name="update"></param>
        /// <returns></returns>
#endif
        public virtual bool Train(
            Mat trainData,
            DTreeDataLayout tflag,
            Mat responses,
            Mat varIdx = null,
            Mat sampleIdx = null,
            Mat varType = null,
            Mat missingMask = null,
            CvBoostParams param = null,
            bool update = false)
        {
            if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

            if (param == null)
                param = new CvBoostParams();

            int ret = NativeMethods.ml_CvBoost_train_Mat(
                ptr,
                trainData.CvPtr,
                (int)tflag,
                responses.CvPtr,
                Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask),
                param.CvPtr,
                update ? 1 : 0);
            return ret != 0;
        }