Exemple #1
0
 /// <summary>
 /// The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree from CvSVMParams. By the optimality one mean that the cross-validation estimate of the test set error is minimal.
 /// </summary>
 /// <param name="trainData">The training data.</param>
 /// <param name="responses">The response for the training data.</param>
 /// <param name="varIdx">Can be null if not needed. When specified, identifies variables (features) of interest. It is a Matrix&lt;int&gt; of nx1</param>
 /// <param name="sampleIdx">Can be null if not needed. When specified, identifies samples of interest. It is a Matrix&lt;int&gt; of nx1</param>
 /// <param name="parameters">The parameters for SVM</param>
 /// <param name="kFold">Cross-validation parameter. The training set is divided into k_fold subsets, one subset being used to train the model, the others forming the test set. So, the SVM algorithm is executed k_fold times</param>
 /// <param name="cGrid">cGrid</param>
 /// <param name="gammaGrid">gammaGrid</param>
 /// <param name="pGrid">pGrid</param>
 /// <param name="nuGrid">nuGrid</param>
 /// <param name="coefGrid">coedGrid</param>
 /// <param name="degreeGrid">degreeGrid</param>
 /// <returns></returns>
 public bool TrainAuto(
     Matrix <float> trainData,
     Matrix <float> responses,
     Matrix <Byte> varIdx,
     Matrix <Byte> sampleIdx,
     MCvSVMParams parameters,
     int kFold,
     MCvParamGrid cGrid,
     MCvParamGrid gammaGrid,
     MCvParamGrid pGrid,
     MCvParamGrid nuGrid,
     MCvParamGrid coefGrid,
     MCvParamGrid degreeGrid)
 {
     return(MlInvoke.CvSVMTrainAuto(
                Ptr,
                trainData.Ptr,
                responses.Ptr,
                varIdx == null ? IntPtr.Zero : varIdx.Ptr,
                sampleIdx == null ? IntPtr.Zero : sampleIdx.Ptr,
                parameters,
                kFold,
                cGrid,
                gammaGrid,
                pGrid,
                nuGrid,
                coefGrid,
                degreeGrid));
 }
Exemple #2
0
 public static extern bool CvSVMTrain(
     IntPtr model,
     IntPtr trainData,
     IntPtr responses,
     IntPtr varIdx,
     IntPtr sampleIdx,
     ref MCvSVMParams parameters);
Exemple #3
0
 public static extern bool CvSVMTrainAuto(
     IntPtr model,
     IntPtr trainData,
     IntPtr responses,
     IntPtr varIdx,
     IntPtr sampleIdx,
     ref MCvSVMParams parameters,
     int kFold,
     ref MCvParamGrid cGrid,
     ref MCvParamGrid gammaGrid,
     ref MCvParamGrid pGrid,
     ref MCvParamGrid nuGrid,
     ref MCvParamGrid coefGrid,
     ref MCvParamGrid degreeGrid);
Exemple #4
0
        /// <summary>
        /// Train the SVM model with the specific paramters
        /// </summary>
        /// <param name="trainData">The training data.</param>
        /// <param name="responses">The response for the training data.</param>
        /// <param name="varIdx">Can be null if not needed. When specified, identifies variables (features) of interest. It is a Matrix&lt;int&gt; of nx1</param>
        /// <param name="sampleIdx">Can be null if not needed. When specified, identifies samples of interest. It is a Matrix&lt;int&gt; of nx1</param>
        /// <param name="parameters">The parameters for SVM</param>
        /// <returns></returns>
        public bool Train(
            Matrix <float> trainData,
            Matrix <float> responses,
            Matrix <Byte> varIdx,
            Matrix <Byte> sampleIdx,
            SVMParams parameters)
        {
            MCvSVMParams svmparam = parameters.MCvSVMParams;

            return(MlInvoke.CvSVMTrain(
                       _ptr,
                       trainData.Ptr,
                       responses.Ptr,
                       varIdx == null ? IntPtr.Zero: varIdx.Ptr,
                       sampleIdx == null ? IntPtr.Zero : varIdx.Ptr,
                       ref svmparam));
        }
Exemple #5
0
 /// <summary>
 /// The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree from CvSVMParams. By the optimality one mean that the cross-validation estimate of the test set error is minimal.
 /// </summary>
 /// <param name="trainData">The training data.</param>
 /// <param name="responses">The response for the training data.</param>
 /// <param name="varIdx">Can be null if not needed. When specified, identifies variables (features) of interest. It is a Matrix&lt;int&gt; of nx1</param>
 /// <param name="sampleIdx">Can be null if not needed. When specified, identifies samples of interest. It is a Matrix&lt;int&gt; of nx1</param>
 /// <param name="parameters">The parameters for SVM</param>
 /// <param name="kFold">Cross-validation parameter. The training set is divided into k_fold subsets, one subset being used to train the model, the others forming the test set. So, the SVM algorithm is executed k_fold times</param>
 /// <returns></returns>
 public bool TrainAuto(
     Matrix <float> trainData,
     Matrix <float> responses,
     Matrix <Byte> varIdx,
     Matrix <Byte> sampleIdx,
     MCvSVMParams parameters,
     int kFold)
 {
     return(TrainAuto(
                trainData,
                responses,
                varIdx,
                sampleIdx,
                parameters,
                kFold,
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SVM_PARAM_TYPE.C),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SVM_PARAM_TYPE.GAMMA),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SVM_PARAM_TYPE.P),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SVM_PARAM_TYPE.NU),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SVM_PARAM_TYPE.COEF),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SVM_PARAM_TYPE.DEGREE)));
 }
Exemple #6
0
 /// <summary>
 /// The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree from CvSVMParams. By the optimality one mean that the cross-validation estimate of the test set error is minimal.
 /// </summary>
 /// <param name="trainData">The training data.</param>
 /// <param name="responses">The response for the training data.</param>
 /// <param name="varIdx">Can be null if not needed. When specified, identifies variables (features) of interest. It is a Matrix&lt;int&gt; of nx1</param>
 /// <param name="sampleIdx">Can be null if not needed. When specified, identifies samples of interest. It is a Matrix&lt;int&gt; of nx1</param>
 /// <param name="parameters">The parameters for SVM</param>
 /// <param name="kFold">Cross-validation parameter. The training set is divided into k_fold subsets, one subset being used to train the model, the others forming the test set. So, the SVM algorithm is executed k_fold times</param>
 /// <returns></returns>
 public bool TrainAuto(
     Matrix <float> trainData,
     Matrix <float> responses,
     Matrix <Byte> varIdx,
     Matrix <Byte> sampleIdx,
     MCvSVMParams parameters,
     int kFold)
 {
     return(TrainAuto(
                trainData,
                responses,
                varIdx,
                sampleIdx,
                parameters,
                kFold,
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SvmParamType.C),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SvmParamType.Gamma),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SvmParamType.P),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SvmParamType.Nu),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SvmParamType.Coef),
                GetDefaultGrid(Emgu.CV.ML.MlEnum.SvmParamType.Degree)));
 }
Exemple #7
0
 public static extern void CvSVMGetParameters(IntPtr model, ref MCvSVMParams param);