TrainData.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. //
  2. // This file is auto-generated. Please don't modify it!
  3. //
  4. #pragma once
  5. #ifdef __cplusplus
  6. //#import "opencv.hpp"
  7. #import "opencv2/ml.hpp"
  8. #else
  9. #define CV_EXPORTS
  10. #endif
  11. #import <Foundation/Foundation.h>
  12. @class Mat;
  13. NS_ASSUME_NONNULL_BEGIN
  14. // C++: class TrainData
  15. /**
  16. * Class encapsulating training data.
  17. *
  18. * Please note that the class only specifies the interface of training data, but not implementation.
  19. * All the statistical model classes in _ml_ module accepts Ptr\<TrainData\> as parameter. In other
  20. * words, you can create your own class derived from TrainData and pass smart pointer to the instance
  21. * of this class into StatModel::train.
  22. *
  23. * @see REF: ml_intro_data
  24. *
  25. * Member of `Ml`
  26. */
  27. CV_EXPORTS @interface TrainData : NSObject
  28. #ifdef __cplusplus
  29. @property(readonly)cv::Ptr<cv::ml::TrainData> nativePtr;
  30. #endif
  31. #ifdef __cplusplus
  32. - (instancetype)initWithNativePtr:(cv::Ptr<cv::ml::TrainData>)nativePtr;
  33. + (instancetype)fromNative:(cv::Ptr<cv::ml::TrainData>)nativePtr;
  34. #endif
  35. #pragma mark - Methods
  36. //
  37. // int cv::ml::TrainData::getLayout()
  38. //
  39. - (int)getLayout NS_SWIFT_NAME(getLayout());
  40. //
  41. // int cv::ml::TrainData::getNTrainSamples()
  42. //
  43. - (int)getNTrainSamples NS_SWIFT_NAME(getNTrainSamples());
  44. //
  45. // int cv::ml::TrainData::getNTestSamples()
  46. //
  47. - (int)getNTestSamples NS_SWIFT_NAME(getNTestSamples());
  48. //
  49. // int cv::ml::TrainData::getNSamples()
  50. //
  51. - (int)getNSamples NS_SWIFT_NAME(getNSamples());
  52. //
  53. // int cv::ml::TrainData::getNVars()
  54. //
  55. - (int)getNVars NS_SWIFT_NAME(getNVars());
  56. //
  57. // int cv::ml::TrainData::getNAllVars()
  58. //
  59. - (int)getNAllVars NS_SWIFT_NAME(getNAllVars());
  60. //
  61. // void cv::ml::TrainData::getSample(Mat varIdx, int sidx, float* buf)
  62. //
  63. - (void)getSample:(Mat*)varIdx sidx:(int)sidx buf:(float)buf NS_SWIFT_NAME(getSample(varIdx:sidx:buf:));
  64. //
  65. // Mat cv::ml::TrainData::getSamples()
  66. //
  67. - (Mat*)getSamples NS_SWIFT_NAME(getSamples());
  68. //
  69. // Mat cv::ml::TrainData::getMissing()
  70. //
  71. - (Mat*)getMissing NS_SWIFT_NAME(getMissing());
  72. //
  73. // Mat cv::ml::TrainData::getTrainSamples(int layout = ROW_SAMPLE, bool compressSamples = true, bool compressVars = true)
  74. //
  75. /**
  76. * Returns matrix of train samples
  77. *
  78. * @param layout The requested layout. If it's different from the initial one, the matrix is
  79. * transposed. See ml::SampleTypes.
  80. * @param compressSamples if true, the function returns only the training samples (specified by
  81. * sampleIdx)
  82. * @param compressVars if true, the function returns the shorter training samples, containing only
  83. * the active variables.
  84. *
  85. * In current implementation the function tries to avoid physical data copying and returns the
  86. * matrix stored inside TrainData (unless the transposition or compression is needed).
  87. */
  88. - (Mat*)getTrainSamples:(int)layout compressSamples:(BOOL)compressSamples compressVars:(BOOL)compressVars NS_SWIFT_NAME(getTrainSamples(layout:compressSamples:compressVars:));
  89. /**
  90. * Returns matrix of train samples
  91. *
  92. * @param layout The requested layout. If it's different from the initial one, the matrix is
  93. * transposed. See ml::SampleTypes.
  94. * @param compressSamples if true, the function returns only the training samples (specified by
  95. * sampleIdx)
  96. * the active variables.
  97. *
  98. * In current implementation the function tries to avoid physical data copying and returns the
  99. * matrix stored inside TrainData (unless the transposition or compression is needed).
  100. */
  101. - (Mat*)getTrainSamples:(int)layout compressSamples:(BOOL)compressSamples NS_SWIFT_NAME(getTrainSamples(layout:compressSamples:));
  102. /**
  103. * Returns matrix of train samples
  104. *
  105. * @param layout The requested layout. If it's different from the initial one, the matrix is
  106. * transposed. See ml::SampleTypes.
  107. * sampleIdx)
  108. * the active variables.
  109. *
  110. * In current implementation the function tries to avoid physical data copying and returns the
  111. * matrix stored inside TrainData (unless the transposition or compression is needed).
  112. */
  113. - (Mat*)getTrainSamples:(int)layout NS_SWIFT_NAME(getTrainSamples(layout:));
  114. /**
  115. * Returns matrix of train samples
  116. *
  117. * transposed. See ml::SampleTypes.
  118. * sampleIdx)
  119. * the active variables.
  120. *
  121. * In current implementation the function tries to avoid physical data copying and returns the
  122. * matrix stored inside TrainData (unless the transposition or compression is needed).
  123. */
  124. - (Mat*)getTrainSamples NS_SWIFT_NAME(getTrainSamples());
  125. //
  126. // Mat cv::ml::TrainData::getTrainResponses()
  127. //
  128. /**
  129. * Returns the vector of responses
  130. *
  131. * The function returns ordered or the original categorical responses. Usually it's used in
  132. * regression algorithms.
  133. */
  134. - (Mat*)getTrainResponses NS_SWIFT_NAME(getTrainResponses());
  135. //
  136. // Mat cv::ml::TrainData::getTrainNormCatResponses()
  137. //
  138. /**
  139. * Returns the vector of normalized categorical responses
  140. *
  141. * The function returns vector of responses. Each response is integer from `0` to `<number of
  142. * classes>-1`. The actual label value can be retrieved then from the class label vector, see
  143. * TrainData::getClassLabels.
  144. */
  145. - (Mat*)getTrainNormCatResponses NS_SWIFT_NAME(getTrainNormCatResponses());
  146. //
  147. // Mat cv::ml::TrainData::getTestResponses()
  148. //
  149. - (Mat*)getTestResponses NS_SWIFT_NAME(getTestResponses());
  150. //
  151. // Mat cv::ml::TrainData::getTestNormCatResponses()
  152. //
  153. - (Mat*)getTestNormCatResponses NS_SWIFT_NAME(getTestNormCatResponses());
  154. //
  155. // Mat cv::ml::TrainData::getResponses()
  156. //
  157. - (Mat*)getResponses NS_SWIFT_NAME(getResponses());
  158. //
  159. // Mat cv::ml::TrainData::getNormCatResponses()
  160. //
  161. - (Mat*)getNormCatResponses NS_SWIFT_NAME(getNormCatResponses());
  162. //
  163. // Mat cv::ml::TrainData::getSampleWeights()
  164. //
  165. - (Mat*)getSampleWeights NS_SWIFT_NAME(getSampleWeights());
  166. //
  167. // Mat cv::ml::TrainData::getTrainSampleWeights()
  168. //
  169. - (Mat*)getTrainSampleWeights NS_SWIFT_NAME(getTrainSampleWeights());
  170. //
  171. // Mat cv::ml::TrainData::getTestSampleWeights()
  172. //
  173. - (Mat*)getTestSampleWeights NS_SWIFT_NAME(getTestSampleWeights());
  174. //
  175. // Mat cv::ml::TrainData::getVarIdx()
  176. //
  177. - (Mat*)getVarIdx NS_SWIFT_NAME(getVarIdx());
  178. //
  179. // Mat cv::ml::TrainData::getVarType()
  180. //
  181. - (Mat*)getVarType NS_SWIFT_NAME(getVarType());
  182. //
  183. // Mat cv::ml::TrainData::getVarSymbolFlags()
  184. //
  185. - (Mat*)getVarSymbolFlags NS_SWIFT_NAME(getVarSymbolFlags());
  186. //
  187. // int cv::ml::TrainData::getResponseType()
  188. //
  189. - (int)getResponseType NS_SWIFT_NAME(getResponseType());
  190. //
  191. // Mat cv::ml::TrainData::getTrainSampleIdx()
  192. //
  193. - (Mat*)getTrainSampleIdx NS_SWIFT_NAME(getTrainSampleIdx());
  194. //
  195. // Mat cv::ml::TrainData::getTestSampleIdx()
  196. //
  197. - (Mat*)getTestSampleIdx NS_SWIFT_NAME(getTestSampleIdx());
  198. //
  199. // void cv::ml::TrainData::getValues(int vi, Mat sidx, float* values)
  200. //
  201. - (void)getValues:(int)vi sidx:(Mat*)sidx values:(float)values NS_SWIFT_NAME(getValues(vi:sidx:values:));
  202. //
  203. // Mat cv::ml::TrainData::getDefaultSubstValues()
  204. //
  205. - (Mat*)getDefaultSubstValues NS_SWIFT_NAME(getDefaultSubstValues());
  206. //
  207. // int cv::ml::TrainData::getCatCount(int vi)
  208. //
  209. - (int)getCatCount:(int)vi NS_SWIFT_NAME(getCatCount(vi:));
  210. //
  211. // Mat cv::ml::TrainData::getClassLabels()
  212. //
  213. /**
  214. * Returns the vector of class labels
  215. *
  216. * The function returns vector of unique labels occurred in the responses.
  217. */
  218. - (Mat*)getClassLabels NS_SWIFT_NAME(getClassLabels());
  219. //
  220. // Mat cv::ml::TrainData::getCatOfs()
  221. //
  222. - (Mat*)getCatOfs NS_SWIFT_NAME(getCatOfs());
  223. //
  224. // Mat cv::ml::TrainData::getCatMap()
  225. //
  226. - (Mat*)getCatMap NS_SWIFT_NAME(getCatMap());
  227. //
  228. // void cv::ml::TrainData::setTrainTestSplit(int count, bool shuffle = true)
  229. //
  230. /**
  231. * Splits the training data into the training and test parts
  232. * @see `-setTrainTestSplitRatio:shuffle:`
  233. */
  234. - (void)setTrainTestSplit:(int)count shuffle:(BOOL)shuffle NS_SWIFT_NAME(setTrainTestSplit(count:shuffle:));
  235. /**
  236. * Splits the training data into the training and test parts
  237. * @see `-setTrainTestSplitRatio:shuffle:`
  238. */
  239. - (void)setTrainTestSplit:(int)count NS_SWIFT_NAME(setTrainTestSplit(count:));
  240. //
  241. // void cv::ml::TrainData::setTrainTestSplitRatio(double ratio, bool shuffle = true)
  242. //
  243. /**
  244. * Splits the training data into the training and test parts
  245. *
  246. * The function selects a subset of specified relative size and then returns it as the training
  247. * set. If the function is not called, all the data is used for training. Please, note that for
  248. * each of TrainData::getTrain\* there is corresponding TrainData::getTest\*, so that the test
  249. * subset can be retrieved and processed as well.
  250. * @see `-setTrainTestSplit:shuffle:`
  251. */
  252. - (void)setTrainTestSplitRatio:(double)ratio shuffle:(BOOL)shuffle NS_SWIFT_NAME(setTrainTestSplitRatio(ratio:shuffle:));
  253. /**
  254. * Splits the training data into the training and test parts
  255. *
  256. * The function selects a subset of specified relative size and then returns it as the training
  257. * set. If the function is not called, all the data is used for training. Please, note that for
  258. * each of TrainData::getTrain\* there is corresponding TrainData::getTest\*, so that the test
  259. * subset can be retrieved and processed as well.
  260. * @see `-setTrainTestSplit:shuffle:`
  261. */
  262. - (void)setTrainTestSplitRatio:(double)ratio NS_SWIFT_NAME(setTrainTestSplitRatio(ratio:));
  263. //
  264. // void cv::ml::TrainData::shuffleTrainTest()
  265. //
  266. - (void)shuffleTrainTest NS_SWIFT_NAME(shuffleTrainTest());
  267. //
  268. // Mat cv::ml::TrainData::getTestSamples()
  269. //
  270. /**
  271. * Returns matrix of test samples
  272. */
  273. - (Mat*)getTestSamples NS_SWIFT_NAME(getTestSamples());
  274. //
  275. // void cv::ml::TrainData::getNames(vector_String names)
  276. //
  277. /**
  278. * Returns vector of symbolic names captured in loadFromCSV()
  279. */
  280. - (void)getNames:(NSArray<NSString*>*)names NS_SWIFT_NAME(getNames(names:));
  281. //
  282. // static Mat cv::ml::TrainData::getSubVector(Mat vec, Mat idx)
  283. //
  284. /**
  285. * Extract from 1D vector elements specified by passed indexes.
  286. * @param vec input vector (supported types: CV_32S, CV_32F, CV_64F)
  287. * @param idx 1D index vector
  288. */
  289. + (Mat*)getSubVector:(Mat*)vec idx:(Mat*)idx NS_SWIFT_NAME(getSubVector(vec:idx:));
  290. //
  291. // static Mat cv::ml::TrainData::getSubMatrix(Mat matrix, Mat idx, int layout)
  292. //
  293. /**
  294. * Extract from matrix rows/cols specified by passed indexes.
  295. * @param matrix input matrix (supported types: CV_32S, CV_32F, CV_64F)
  296. * @param idx 1D index vector
  297. * @param layout specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES)
  298. */
  299. + (Mat*)getSubMatrix:(Mat*)matrix idx:(Mat*)idx layout:(int)layout NS_SWIFT_NAME(getSubMatrix(matrix:idx:layout:));
  300. //
  301. // static Ptr_TrainData cv::ml::TrainData::create(Mat samples, int layout, Mat responses, Mat varIdx = Mat(), Mat sampleIdx = Mat(), Mat sampleWeights = Mat(), Mat varType = Mat())
  302. //
  303. /**
  304. * Creates training data from in-memory arrays.
  305. *
  306. * @param samples matrix of samples. It should have CV_32F type.
  307. * @param layout see ml::SampleTypes.
  308. * @param responses matrix of responses. If the responses are scalar, they should be stored as a
  309. * single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
  310. * former case the responses are considered as ordered by default; in the latter case - as
  311. * categorical)
  312. * @param varIdx vector specifying which variables to use for training. It can be an integer vector
  313. * (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
  314. * active variables.
  315. * @param sampleIdx vector specifying which samples to use for training. It can be an integer
  316. * vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
  317. * of training samples.
  318. * @param sampleWeights optional vector with weights for each sample. It should have CV_32F type.
  319. * @param varType optional vector of type CV_8U and size `<number_of_variables_in_samples> +
  320. * <number_of_variables_in_responses>`, containing types of each input and output variable. See
  321. * ml::VariableTypes.
  322. */
  323. + (TrainData*)create:(Mat*)samples layout:(int)layout responses:(Mat*)responses varIdx:(Mat*)varIdx sampleIdx:(Mat*)sampleIdx sampleWeights:(Mat*)sampleWeights varType:(Mat*)varType NS_SWIFT_NAME(create(samples:layout:responses:varIdx:sampleIdx:sampleWeights:varType:));
  324. /**
  325. * Creates training data from in-memory arrays.
  326. *
  327. * @param samples matrix of samples. It should have CV_32F type.
  328. * @param layout see ml::SampleTypes.
  329. * @param responses matrix of responses. If the responses are scalar, they should be stored as a
  330. * single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
  331. * former case the responses are considered as ordered by default; in the latter case - as
  332. * categorical)
  333. * @param varIdx vector specifying which variables to use for training. It can be an integer vector
  334. * (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
  335. * active variables.
  336. * @param sampleIdx vector specifying which samples to use for training. It can be an integer
  337. * vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
  338. * of training samples.
  339. * @param sampleWeights optional vector with weights for each sample. It should have CV_32F type.
  340. * <number_of_variables_in_responses>`, containing types of each input and output variable. See
  341. * ml::VariableTypes.
  342. */
  343. + (TrainData*)create:(Mat*)samples layout:(int)layout responses:(Mat*)responses varIdx:(Mat*)varIdx sampleIdx:(Mat*)sampleIdx sampleWeights:(Mat*)sampleWeights NS_SWIFT_NAME(create(samples:layout:responses:varIdx:sampleIdx:sampleWeights:));
  344. /**
  345. * Creates training data from in-memory arrays.
  346. *
  347. * @param samples matrix of samples. It should have CV_32F type.
  348. * @param layout see ml::SampleTypes.
  349. * @param responses matrix of responses. If the responses are scalar, they should be stored as a
  350. * single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
  351. * former case the responses are considered as ordered by default; in the latter case - as
  352. * categorical)
  353. * @param varIdx vector specifying which variables to use for training. It can be an integer vector
  354. * (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
  355. * active variables.
  356. * @param sampleIdx vector specifying which samples to use for training. It can be an integer
  357. * vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
  358. * of training samples.
  359. * <number_of_variables_in_responses>`, containing types of each input and output variable. See
  360. * ml::VariableTypes.
  361. */
  362. + (TrainData*)create:(Mat*)samples layout:(int)layout responses:(Mat*)responses varIdx:(Mat*)varIdx sampleIdx:(Mat*)sampleIdx NS_SWIFT_NAME(create(samples:layout:responses:varIdx:sampleIdx:));
  363. /**
  364. * Creates training data from in-memory arrays.
  365. *
  366. * @param samples matrix of samples. It should have CV_32F type.
  367. * @param layout see ml::SampleTypes.
  368. * @param responses matrix of responses. If the responses are scalar, they should be stored as a
  369. * single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
  370. * former case the responses are considered as ordered by default; in the latter case - as
  371. * categorical)
  372. * @param varIdx vector specifying which variables to use for training. It can be an integer vector
  373. * (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
  374. * active variables.
  375. * vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
  376. * of training samples.
  377. * <number_of_variables_in_responses>`, containing types of each input and output variable. See
  378. * ml::VariableTypes.
  379. */
  380. + (TrainData*)create:(Mat*)samples layout:(int)layout responses:(Mat*)responses varIdx:(Mat*)varIdx NS_SWIFT_NAME(create(samples:layout:responses:varIdx:));
  381. /**
  382. * Creates training data from in-memory arrays.
  383. *
  384. * @param samples matrix of samples. It should have CV_32F type.
  385. * @param layout see ml::SampleTypes.
  386. * @param responses matrix of responses. If the responses are scalar, they should be stored as a
  387. * single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
  388. * former case the responses are considered as ordered by default; in the latter case - as
  389. * categorical)
  390. * (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
  391. * active variables.
  392. * vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
  393. * of training samples.
  394. * <number_of_variables_in_responses>`, containing types of each input and output variable. See
  395. * ml::VariableTypes.
  396. */
  397. + (TrainData*)create:(Mat*)samples layout:(int)layout responses:(Mat*)responses NS_SWIFT_NAME(create(samples:layout:responses:));
  398. @end
  399. NS_ASSUME_NONNULL_END