Ejemplo n.º 1
0
 /// <summary>
 /// Create a normal Bayes classifier
 /// </summary>
 public NormalBayesClassifier()
 {
     _ptr = MlInvoke.cveNormalBayesClassifierDefaultCreate(ref _statModelPtr, ref _algorithmPtr);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize the activation function for each neuron.
 /// </summary>
 /// <param name="function">Currently the default and the only fully supported activation function is SigmoidSym </param>
 /// <param name="param1">The first parameter of the activation function.</param>
 /// <param name="param2">The second parameter of the activation function.</param>
 public void SetActivationFunction(ANN_MLP.AnnMlpActivationFunction function, double param1 = 0, double param2 = 0)
 {
     MlInvoke.cveANN_MLPSetActivationFunction(_ptr, function, param1, param2);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a neural network using the specific parameters
 /// </summary>
 public ANN_MLP()
 {
     _ptr = MlInvoke.cveANN_MLPCreate(ref _statModelPtr, ref _algorithmPtr, ref _sharedPtr);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// The method retrieves the number of vars
 /// </summary>
 /// <returns>The number of variables</returns>
 public int GetVarCount()
 {
     return(MlInvoke.CvSVMGetVarCount(Ptr));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a default Boost classifier
 /// </summary>
 public Boost()
 {
     _ptr = MlInvoke.CvBoostCreate();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a default decision tree
 /// </summary>
 public DTree()
 {
     _ptr = MlInvoke.CvDTreeCreate();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create a support Vector Machine
 /// </summary>
 public SVM()
 {
     _ptr = MlInvoke.CvSVMDefaultCreate();
 }
Ejemplo n.º 8
0
 public static bool Train(this IStatModel model, TrainData trainData, int flags = 0)
 {
     return(MlInvoke.StatModelTrainWithData(model.StatModelPtr, trainData, flags));
 }
Ejemplo n.º 9
0
        /*
         * /// <summary>
         * /// Load the statistic model from file
         * /// </summary>
         * /// <param name="fileName">The file to load the model from</param>
         * public void Load(String fileName)
         * {
         * using (CvString fs = new CvString(fileName))
         * MlInvoke.StatModelLoad(_ptr, fs);
         * }*/

        /// <summary>
        /// Clear the statistic model
        /// </summary>
        public static void Clear(this IStatModel model)
        {
            MlInvoke.StatModelClear(model.StatModelPtr);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Release the unmanaged resources
 /// </summary>
 protected override void DisposeObject()
 {
     MlInvoke.cveTrainDataRelease(ref _ptr, ref _sharedPtr);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Save the statistic model to file
 /// </summary>
 /// <param name="fileName">The file name where this StatModel will be saved</param>
 public static void Save(this IStatModel model, String fileName)
 {
     using (CvString fs = new CvString(fileName))
         MlInvoke.StatModelSave(model.StatModelPtr, fs);
 }
Ejemplo n.º 12
0
        /*
         * /// <summary>
         * /// Create a normal bayes classifier using the specific training data
         * /// </summary>
         * /// <param name="trainData">The training data. A 32-bit floating-point, single-channel matrix, one vector per row</param>
         * /// <param name="responses">A floating-point matrix of the corresponding output vectors, one vector per row. </param>
         * /// <param name="varIdx">Can be null if not needed. When specified, identifies variables (features) of interest. It is a Matrix&gt;int&lt; of nx1</param>
         * /// <param name="sampleIdx">Can be null if not needed. When specified, identifies samples of interest. It is a Matrix&gt;int&lt; of nx1</param>
         * public NormalBayesClassifier(Matrix<float> trainData, Matrix<int> responses, Matrix<Byte> varIdx, Matrix<Byte> sampleIdx)
         * {
         * _ptr = MlInvoke.CvNormalBayesClassifierCreate(
         *    trainData.Ptr,
         *    responses.Ptr,
         *    varIdx == null ? IntPtr.Zero : varIdx.Ptr,
         *    sampleIdx == null ? IntPtr.Zero : sampleIdx.Ptr);
         * }*/

        /// <summary>
        /// Release the memory associated with this classifier
        /// </summary>
        protected override void DisposeObject()
        {
            MlInvoke.CvNormalBayesClassifierRelease(ref _ptr);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Create a normal Bayes classifier
 /// </summary>
 public NormalBayesClassifier()
 {
     _ptr = MlInvoke.CvNormalBayesClassifierDefaultCreate();
 }
Ejemplo n.º 14
0
        /*
         * /// <summary>
         * /// Create a normal bayes classifier using the specific training data
         * /// </summary>
         * /// <param name="trainData">The training data. A 32-bit floating-point, single-channel matrix, one vector per row</param>
         * /// <param name="responses">A floating-point matrix of the corresponding output vectors, one vector per row. </param>
         * /// <param name="varIdx">Can be null if not needed. When specified, identifies variables (features) of interest. It is a Matrix&gt;int&lt; of nx1</param>
         * /// <param name="sampleIdx">Can be null if not needed. When specified, identifies samples of interest. It is a Matrix&gt;int&lt; of nx1</param>
         * public NormalBayesClassifier(Matrix<float> trainData, Matrix<int> responses, Matrix<Byte> varIdx, Matrix<Byte> sampleIdx)
         * {
         * _ptr = MlInvoke.CvNormalBayesClassifierCreate(
         *    trainData.Ptr,
         *    responses.Ptr,
         *    varIdx == null ? IntPtr.Zero : varIdx.Ptr,
         *    sampleIdx == null ? IntPtr.Zero : sampleIdx.Ptr);
         * }*/

        /// <summary>
        /// Release the memory associated with this classifier
        /// </summary>
        protected override void DisposeObject()
        {
            MlInvoke.cveNormalBayesClassifierRelease(ref _ptr);
            _statModelPtr = IntPtr.Zero;
            _algorithmPtr = IntPtr.Zero;
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Release all the memory associated with the SVM
 /// </summary>
 protected override void DisposeObject()
 {
     MlInvoke.CvSVMRelease(ref _ptr);
     _statModelPtr = IntPtr.Zero;
     _algorithmPtr = IntPtr.Zero;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Create a default Boost classifier
 /// </summary>
 public Boost()
 {
     _ptr = MlInvoke.cveBoostCreate(ref _statModel, ref _algorithm);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Create a default decision tree
 /// </summary>
 public DTrees()
 {
     _ptr = MlInvoke.cveDTreesCreate(ref _statModelPtr, ref _algorithmPtr, ref _sharedPtr);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Release the Boost classifier and all memory associate with it
 /// </summary>
 protected override void DisposeObject()
 {
     MlInvoke.cveBoostRelease(ref _ptr);
     _statModel = IntPtr.Zero;
     _algorithm = IntPtr.Zero;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Predicts response for the input sample.
 /// </summary>
 /// <param name="sample">The input sample</param>
 public float Predict(Matrix <float> sample)
 {
     return(MlInvoke.CvSVMPredict(Ptr, sample.Ptr));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// The method takes the feature vector and the optional missing measurement mask on input, traverses the random tree and returns the cumulative result from all the trees in the forest (the class that receives the majority of voices, or the mean of the regression function estimates)
 /// </summary>
 /// <param name="sample">The sample to be predicted</param>
 /// <param name="missingDataMask">Can be null if not needed. When specified, it is an 8-bit matrix of the same size as <i>trainData</i>, is used to mark the missed values (non-zero elements of the mask)</param>
 /// <returns>The cumulative result from all the trees in the forest (the class that receives the majority of voices, or the mean of the regression function estimates)</returns>
 public float Predict(
     Matrix <float> sample,
     Matrix <Byte> missingDataMask)
 {
     return(MlInvoke.CvRTreesPredict(_ptr, sample.Ptr, missingDataMask == null ? IntPtr.Zero : missingDataMask.Ptr));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// The method retrieves the number of support vectors
 /// </summary>
 /// <returns>The number of support vectors</returns>
 public int GetSupportVectorCount()
 {
     return(MlInvoke.CvSVMGetSupportVectorCount(Ptr));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogisticRegression"/> class.
 /// </summary>
 public LogisticRegression()
 {
     _ptr = MlInvoke.cveLogisticRegressionCreate(ref _statModelPtr, ref _algorithmPtr);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Release all the memory associated with the SVM
 /// </summary>
 protected override void DisposeObject()
 {
     MlInvoke.CvSVMRelease(_ptr);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Create an extreme Random tree
 /// </summary>
 public ERTrees()
 {
     _ptr = MlInvoke.CvERTreesCreate();
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Release the Boost classifier and all memory associate with it
 /// </summary>
 protected override void DisposeObject()
 {
     MlInvoke.CvBoostRelease(ref _ptr);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Release the extreme random tree and all memory associate with it
 /// </summary>
 protected override void DisposeObject()
 {
     MlInvoke.CvERTreesRelease(ref _ptr);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Sets training method and common parameters.
 /// </summary>
 /// <param name="method">The training method.</param>
 /// <param name="param1">param1 passed to setRpropDW0 for ANN_MLP::RPROP and to setBackpropWeightScale for ANN_MLP::BACKPROP and to initialT for ANN_MLP::ANNEAL.</param>
 /// <param name="param2">param2 passed to setRpropDWMin for ANN_MLP::RPROP and to setBackpropMomentumScale for ANN_MLP::BACKPROP and to finalT for ANN_MLP::ANNEAL.</param>
 public void SetTrainMethod(ANN_MLP.AnnMlpTrainMethod method = AnnMlpTrainMethod.Rprop, double param1 = 0, double param2 = 0)
 {
     MlInvoke.cveANN_MLPSetTrainMethod(_ptr, method, param1, param2);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Create a support Vector Machine
 /// </summary>
 public SVM()
 {
     _ptr = MlInvoke.CvSVMDefaultCreate(ref _statModelPtr, ref _algorithmPtr);
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Sets the layer sizes.
 /// </summary>
 /// <param name="layerSizes">Integer vector specifying the number of neurons in each layer including the input and output layers. The very first element specifies the number of elements in the input layer. The last element - number of elements in the output layer.</param>
 public void SetLayerSizes(IInputArray layerSizes)
 {
     using (InputArray iaLayerSizes = layerSizes.GetInputArray())
         MlInvoke.cveANN_MLPSetLayerSizes(_ptr, iaLayerSizes);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Set the optimal parameters for the given model type
 /// </summary>
 /// <param name="svmsgdType">SVMSGD type</param>
 /// <param name="marginType">Margin type</param>
 public void SetOptimalParameters(
     Emgu.CV.ML.SVMSGD.SvmsgdType svmsgdType,
     Emgu.CV.ML.SVMSGD.MarginType marginType)
 {
     MlInvoke.cveSVMSGDSetOptimalParameters(_ptr, svmsgdType, marginType);
 }