/// <summary> /// Selects an optimal combination of features to classify the provided data. /// Instance represents: Handle of the training data. /// </summary> /// <param name="selectionMethod">Method to perform the selection. Default: "greedy"</param> /// <param name="genParamName">Names of generic parameters to configure the selection process and the classifier. Default: []</param> /// <param name="genParamValue">Values of generic parameters to configure the selection process and the classifier. Default: []</param> /// <param name="selectedFeatureIndices">The selected feature set, contains indices.</param> /// <param name="score">The achieved score using two-fold cross-validation.</param> /// <returns>A trained SVM classifier using only the selected features.</returns> public HClassSvm SelectFeatureSetSvm( string selectionMethod, string genParamName, double genParamValue, out HTuple selectedFeatureIndices, out HTuple score) { IntPtr proc = HalconAPI.PreCall(1800); this.Store(proc, 0); HalconAPI.StoreS(proc, 1, selectionMethod); HalconAPI.StoreS(proc, 2, genParamName); HalconAPI.StoreD(proc, 3, genParamValue); HalconAPI.InitOCT(proc, 0); HalconAPI.InitOCT(proc, 1); HalconAPI.InitOCT(proc, 2); int err1 = HalconAPI.CallProcedure(proc); HClassSvm hclassSvm; int err2 = HClassSvm.LoadNew(proc, 0, err1, out hclassSvm); int err3 = HTuple.LoadNew(proc, 1, err2, out selectedFeatureIndices); int procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out score); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); return(hclassSvm); }
/// <summary> /// Approximate a trained support vector machine by a reduced support vector machine for faster classification. /// Instance represents: Original SVM handle. /// </summary> /// <param name="method">Type of postprocessing to reduce number of SV. Default: "bottom_up"</param> /// <param name="minRemainingSV">Minimum number of remaining SVs. Default: 2</param> /// <param name="maxError">Maximum allowed error of reduction. Default: 0.001</param> /// <returns>SVMHandle of reduced SVM.</returns> public HClassSvm ReduceClassSvm(string method, int minRemainingSV, double maxError) { IntPtr proc = HalconAPI.PreCall(1852); this.Store(proc, 0); HalconAPI.StoreS(proc, 1, method); HalconAPI.StoreI(proc, 2, minRemainingSV); HalconAPI.StoreD(proc, 3, maxError); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); HClassSvm hclassSvm; int procResult = HClassSvm.LoadNew(proc, 0, err, out hclassSvm); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); return(hclassSvm); }