示例#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>
		/// <param name="shared"></param>
        /// <param name="addLabels"></param>
        /// <returns></returns>
#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>
		/// <param name="shared"></param>
		/// <param name="addLabels"></param>
        /// <returns></returns>
#endif
		public CvDTreeTrainData(
            CvMat trainData,
            DTreeDataLayout tflag, 
            CvMat responses, 
            CvMat varIdx = null, 
            CvMat sampleIdx = null, 
            CvMat varType = null, 
            CvMat missingMask = null,
			CvDTreeParams param = null, 
            bool shared = false, 
            bool addLabels = false)
		{
            if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

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

            ptr = NativeMethods.ml_CvDTreeTrainData_new2(
				trainData.CvPtr, 
				(int)tflag, 
				responses.CvPtr, 
				Cv2.ToPtr(varIdx), 
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType), 
                Cv2.ToPtr(missingMask), 
				param.CvPtr, 
				shared ? 1 : 0, 
                addLabels ? 1 : 0
			);
		}
示例#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>
#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
			);
		}
示例#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>
        /// <returns></returns>
#else
        /// <summary>
        /// Trains Random Trees model
        /// </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>
        /// <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,
            CvRTParams param = null)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException("trainData");
            }
            if (responses == null)
            {
                throw new ArgumentNullException("responses");
            }

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

            return(NativeMethods.ml_CvRTrees_train_CvMat(
                       ptr,
                       trainData.CvPtr,
                       (int)tflag,
                       responses.CvPtr,
                       Cv2.ToPtr(varIdx),
                       Cv2.ToPtr(sampleIdx),
                       Cv2.ToPtr(varType),
                       Cv2.ToPtr(missingMask),
                       param.CvPtr) != 0);
        }
示例#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="shared"></param>
        /// <param name="addLabels"></param>
        /// <param name="updateData"></param>
        /// <returns></returns>
#else
        /// <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="shared"></param>
        /// <param name="addLabels"></param>
        /// <param name="updateData"></param>
        /// <returns></returns>
#endif
        public void SetData(
            CvMat trainData,
            DTreeDataLayout tflag,
            CvMat responses,
            CvMat varIdx        = null,
            CvMat sampleIdx     = null,
            CvMat varType       = null,
            CvMat missingMask   = null,
            CvDTreeParams param = null,
            bool shared         = false,
            bool addLabels      = false,
            bool updateData     = false)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException(nameof(trainData));
            }
            if (responses == null)
            {
                throw new ArgumentNullException(nameof(responses));
            }

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

            NativeMethods.ml_CvDTreeTrainData_set_data(
                ptr,
                trainData.CvPtr,
                (int)tflag,
                responses.CvPtr,
                Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask),
                param.CvPtr,
                shared ? 1 : 0,
                addLabels ? 1 : 0,
                updateData ? 1 : 0
                );
        }
示例#5
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="shared"></param>
        /// <param name="addLabels"></param>
        /// <returns></returns>
#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>
        /// <param name="shared"></param>
        /// <param name="addLabels"></param>
        /// <returns></returns>
#endif
        public CvDTreeTrainData(
            CvMat trainData,
            DTreeDataLayout tflag,
            CvMat responses,
            CvMat varIdx        = null,
            CvMat sampleIdx     = null,
            CvMat varType       = null,
            CvMat missingMask   = null,
            CvDTreeParams param = null,
            bool shared         = false,
            bool addLabels      = false)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException("trainData");
            }
            if (responses == null)
            {
                throw new ArgumentNullException("responses");
            }
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

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

            ptr = NativeMethods.ml_CvDTreeTrainData_new2(
                trainData.CvPtr,
                (int)tflag,
                responses.CvPtr,
                Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask),
                param.CvPtr,
                shared ? 1 : 0,
                addLabels ? 1 : 0
                );
        }
示例#6
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);
        }
示例#7
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
                );
        }
示例#8
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>
        /// <returns></returns>
#else
        /// <summary>
        /// Trains decision tree
        /// </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>
        /// <returns></returns>
#endif
        public virtual bool Train(
            Mat trainData,
            DTreeDataLayout tflag,
            Mat responses,
            Mat varIdx,
            Mat sampleIdx,
            Mat varType,
            Mat missingMask,
            CvDTreeParams param)
        {
            if (trainData == null)
            {
                throw new ArgumentNullException(nameof(trainData));
            }
            if (responses == null)
            {
                throw new ArgumentNullException(nameof(responses));
            }
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

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

            return(NativeMethods.ml_CvDTree_train_Mat(
                       ptr,
                       trainData.CvPtr,
                       (int)tflag,
                       responses.CvPtr,
                       Cv2.ToPtr(varIdx),
                       Cv2.ToPtr(sampleIdx),
                       Cv2.ToPtr(varType),
                       Cv2.ToPtr(missingMask),
                       param.CvPtr) != 0);
        }
示例#9
0
        /// <summary>
        /// ブーストされた分類器の学習
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="var_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></param>
        /// <param name="params"></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="params"></param>
		/// <returns></returns>
#endif
		public virtual bool Train(CvMat trainData, DTreeDataLayout tflag, CvMat responses, 
			CvMat varIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask, 
			CvBoostParams @params )
		{    
			return Train(trainData, tflag, responses, varIdx, sampleIdx, varType, missingMask, @params, false);
		}
示例#10
0
        /// <summary>
        /// ブーストされた分類器の学習
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <returns></returns>
#else
		/// <summary>
        /// Trains boosted tree classifier
        /// </summary>
        /// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <returns></returns>
#endif
		public virtual bool Train(CvMat trainData, DTreeDataLayout tflag, CvMat responses)
		{    
			return Train(trainData, tflag, responses, null, null, null, null, new CvBoostParams(), false);
		}
示例#11
0
        /// <summary>
        /// 学習データを与えて初期化
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="var_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></param>
        /// <param name="params"></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="params"></param>
#endif
		public CvBoost(CvMat trainData, DTreeDataLayout tflag, CvMat responses, 
			CvMat varIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask, CvBoostParams @params )
		{    
			if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");
			
			if(@params == null)
				@params = new CvBoostParams();

            IntPtr varIdxPtr = (varIdx == null) ? IntPtr.Zero : varIdx.CvPtr;
            IntPtr sampleIdxPtr = (sampleIdx == null) ? IntPtr.Zero : sampleIdx.CvPtr;
            IntPtr varTypePtr = (varType == null) ? IntPtr.Zero : varType.CvPtr;
            IntPtr missingMaskPtr = (missingMask == null) ? IntPtr.Zero : missingMask.CvPtr;

			ptr = MLInvoke.CvBoost_construct_training(
				trainData.CvPtr, 
				(int)tflag,
				responses.CvPtr,
				varIdxPtr, 
                sampleIdxPtr, 
                varTypePtr, 
                missingMaskPtr,
				@params.CvPtr
			);

			NotifyMemoryPressure(SizeOf);
		}
示例#12
0
        /// <summary>
        /// 学習データを与えて初期化
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="var_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></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>
#endif
		public CvBoost(CvMat trainData, DTreeDataLayout tflag, CvMat responses, 
			CvMat varIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask )
            : this(trainData, tflag, responses, varIdx, sampleIdx, varType, missingMask, new CvBoostParams())
		{    
		}
示例#13
0
        /// <summary>
        /// ランダムツリーモデルの学習
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="comp_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></param>
        /// <returns></returns>
#else
		/// <summary>
        /// Trains Random Trees model
        /// </summary>
        /// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="compIdx"></param>
        /// <param name="sampleIdx"></param>
        /// <param name="varType"></param>
        /// <param name="missingMask"></param>
        /// <returns></returns>
#endif
		public virtual bool Train(CvMat trainData, DTreeDataLayout tflag, CvMat responses, 
			CvMat compIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask)
        {
			return Train(trainData, tflag, responses, compIdx, sampleIdx, varType, missingMask, new CvRTParams());
        }
示例#14
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>
        /// <returns></returns>
#else
        /// <summary>
        /// Trains Random Trees model
        /// </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>
        /// <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,
            CvRTParams param = null)
        {
            if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");

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

            return NativeMethods.ml_CvRTrees_train_CvMat(
                ptr,
                trainData.CvPtr,
                (int)tflag,
                responses.CvPtr,
                Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask),
                param.CvPtr) != 0;
        }
示例#15
0
		/// <summary>
        /// 
        /// </summary>
		/// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <returns></returns>
#else
		/// <summary>
        /// 
        /// </summary>
		/// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <returns></returns>
#endif
		public void SetData(CvMat trainData, DTreeDataLayout tflag, CvMat responses)
		{
            SetData(trainData, tflag, responses, null, null, null, null, new CvDTreeParams(), false, false, false);
		}
示例#16
0
        /// <summary>
        /// ブーストされた分類器の学習
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="var_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></param>
        /// <param name="params"></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="params"></param>
        /// <param name="update"></param>
		/// <returns></returns>
#endif
		public virtual bool Train(CvMat trainData, DTreeDataLayout tflag, CvMat responses, 
			CvMat varIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask, 
			CvBoostParams @params, Boolean update )
		{    
			if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");
			
			if(@params == null)
				@params = new CvBoostParams();

            IntPtr varIdxPtr = (varIdx == null) ? IntPtr.Zero : varIdx.CvPtr;
            IntPtr sampleIdxPtr = (sampleIdx == null) ? IntPtr.Zero : sampleIdx.CvPtr;
            IntPtr varTypePtr = (varType == null) ? IntPtr.Zero : varType.CvPtr;
            IntPtr missingMaskPtr = (missingMask == null) ? IntPtr.Zero : missingMask.CvPtr;

			return MLInvoke.CvBoost_train(
                ptr,
				trainData.CvPtr, 
				(int)tflag,
				responses.CvPtr,
				varIdxPtr, 
                sampleIdxPtr, 
                varTypePtr, 
                missingMaskPtr,
				@params.CvPtr,
				update
			);
		}
示例#17
0
		/// <summary>
        /// 
        /// </summary>
		/// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="var_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></param>
        /// <returns></returns>
#else
		/// <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>
        /// <returns></returns>
#endif
		public void SetData(CvMat trainData, DTreeDataLayout tflag, CvMat responses, CvMat varIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask)
		{
             SetData(trainData, tflag, responses, varIdx, sampleIdx, varType, missingMask, new CvDTreeParams(), false, false, false);
		}
示例#18
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;
        }
示例#19
0
		/// <summary>
        /// 学習データを与えて初期化
        /// </summary>
		/// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="var_idx"></param>
        /// <returns></returns>
#else
		/// <summary>
        /// Training constructor
        /// </summary>
		/// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
        /// <param name="varIdx"></param>
        /// <returns></returns>
#endif
        public CvDTreeTrainData(CvMat trainData, DTreeDataLayout tflag, CvMat responses, CvMat varIdx)
            : this(trainData, tflag, responses, varIdx, null, null, null, new CvDTreeParams(), false, false)
		{
		}
示例#20
0
		/// <summary>
        /// 
        /// </summary>
		/// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
		/// <param name="var_idx"></param>
        /// <param name="sample_idx"></param>
        /// <param name="var_type"></param>
        /// <param name="missing_mask"></param>
        /// <param name="params"></param>
		/// <param name="shared"></param>
		/// <param name="add_labels"></param>
		/// <param name="update_data"></param>
        /// <returns></returns>
#else
		/// <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="params"></param>
		/// <param name="shared"></param>
		/// <param name="addLabels"></param>
		/// <param name="updateData"></param>
        /// <returns></returns>
#endif
		public void SetData(CvMat trainData, DTreeDataLayout tflag, CvMat responses, CvMat varIdx, CvMat sampleIdx, CvMat varType, CvMat missingMask,
			CvDTreeParams @params, bool shared, bool addLabels, bool updateData)
		{
            if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");

			if(@params == null)
				@params = new CvDTreeParams();
            
            IntPtr varIdxPtr = (varIdx == null) ? IntPtr.Zero : varIdx.CvPtr;
            IntPtr sampleIdxPtr = (sampleIdx == null) ? IntPtr.Zero : sampleIdx.CvPtr;
            IntPtr varTypePtr = (varType == null) ? IntPtr.Zero : varType.CvPtr;
            IntPtr missingMaskPtr = (missingMask == null) ? IntPtr.Zero : missingMask.CvPtr;

			MLInvoke.CvDTreeTrainData_set_data(
                ptr,
				trainData.CvPtr, 
				(int)tflag, 
				responses.CvPtr, 
				varIdxPtr,
				sampleIdxPtr, 
				varTypePtr, 
				missingMaskPtr,
				@params.CvPtr, 
				shared, addLabels, updateData
			);
		}
示例#21
0
        /// <summary>
        /// 学習データを与えて初期化
        /// </summary>
        /// <param name="train_data"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
#else
		/// <summary>
        /// Training constructor
        /// </summary>
        /// <param name="trainData"></param>
		/// <param name="tflag"></param>
        /// <param name="responses"></param>
#endif
		public CvBoost(CvMat trainData, DTreeDataLayout tflag, CvMat responses)
            : this(trainData, tflag, responses, null, null, null, null, new CvBoostParams())
		{    
		}
示例#22
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>
        /// <returns></returns>
#else
		/// <summary>
        /// Trains decision tree
        /// </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>
        /// <returns></returns>
#endif
		public virtual bool Train(
            CvMat trainData,
            DTreeDataLayout tflag,
            CvMat responses, 
			CvMat varIdx, 
            CvMat sampleIdx, 
            CvMat varType, 
            CvMat missingMask, 
            CvDTreeParams param)
        {
            if (trainData == null)
                throw new ArgumentNullException("trainData");
            if (responses == null)
                throw new ArgumentNullException("responses");
            trainData.ThrowIfDisposed();
            responses.ThrowIfDisposed();

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

            return NativeMethods.ml_CvDTree_train1(
                ptr,
				trainData.CvPtr, 
				(int)tflag, 
				responses.CvPtr, 
				Cv2.ToPtr(varIdx),
                Cv2.ToPtr(sampleIdx),
                Cv2.ToPtr(varType),
                Cv2.ToPtr(missingMask), 
				param.CvPtr) != 0;
        }