示例#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));
 }
示例#2
0
        /// <summary>
        /// Get the default parameter grid for the specific SVM type
        /// </summary>
        /// <param name="type">The SVM type</param>
        /// <returns>The default parameter grid for the specific SVM type </returns>
        public static MCvParamGrid GetDefaultGrid(MlEnum.SVM_PARAM_TYPE type)
        {
            MCvParamGrid grid = new MCvParamGrid();

            MlInvoke.CvSVMGetDefaultGrid(type, ref grid);
            return(grid);
        }
示例#3
0
文件: SVM.cs 项目: TNvGelder/DroneIt
        /// <summary>
        /// Get the default parameter grid for the specific SVM type
        /// </summary>
        /// <param name="type">The SVM type</param>
        /// <returns>The default parameter grid for the specific SVM type </returns>
        public static MCvParamGrid GetDefaultGrid(SVM.ParamType type)
        {
            MCvParamGrid grid = new MCvParamGrid();

            MlInvoke.CvSVMGetDefaultGrid(type, ref grid);
            return(grid);
        }
示例#4
0
 internal static extern bool CvSVMTrainAuto(
     IntPtr model,
     IntPtr trainData,
     int kFold,
     ref MCvParamGrid cGrid,
     ref MCvParamGrid gammaGrid,
     ref MCvParamGrid pGrid,
     ref MCvParamGrid nuGrid,
     ref MCvParamGrid coefGrid,
     ref MCvParamGrid degreeGrid,
     [MarshalAs(CvInvoke.BoolMarshalType)]
     bool balanced);
示例#5
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);
示例#6
0
文件: SVM.cs 项目: TNvGelder/DroneIt
 /// <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="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">grid for gamma</param>
 /// <param name="pGrid">grid for p</param>
 /// <param name="nuGrid">grid for nu</param>
 /// <param name="coefGrid">grid for coeff</param>
 /// <param name="degreeGrid">grid for degree</param>
 /// <param name="balanced">If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset.</param>
 /// <returns></returns>
 public bool TrainAuto(
     TrainData trainData,
     int kFold,
     MCvParamGrid cGrid,
     MCvParamGrid gammaGrid,
     MCvParamGrid pGrid,
     MCvParamGrid nuGrid,
     MCvParamGrid coefGrid,
     MCvParamGrid degreeGrid,
     bool balanced = false)
 {
     return(MlInvoke.CvSVMTrainAuto(
                Ptr,
                trainData.Ptr,
                kFold,
                ref cGrid,
                ref gammaGrid,
                ref pGrid,
                ref nuGrid,
                ref coefGrid,
                ref degreeGrid,
                balanced));
 }
示例#7
0
 internal static extern void CvSVMGetDefaultGrid(SVM.ParamType type, ref MCvParamGrid grid);
示例#8
0
 public static extern void CvSVMGetDefaultGrid(MlEnum.SvmParamType type, ref MCvParamGrid grid);
示例#9
0
 public static extern void CvSVMGetDefaultGrid(MlEnum.SVM_PARAM_TYPE type, ref MCvParamGrid grid);