mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Deleted all trailing whitespace.
This commit is contained in:
@@ -67,7 +67,7 @@ The following loss functions are implemented for regression problems:
|
||||
:math:`L(y,f(x)) = \left\{ \begin{array}{lr}
|
||||
\delta\cdot\left(|y-f(x)|-\dfrac{\delta}{2}\right) & : |y-f(x)|>\delta\\
|
||||
\dfrac{1}{2}\cdot(y-f(x))^2 & : |y-f(x)|\leq\delta \end{array} \right.`,
|
||||
|
||||
|
||||
where :math:`\delta` is the :math:`\alpha`-quantile estimation of the
|
||||
:math:`|y-f(x)|`. In the current implementation :math:`\alpha=0.2`.
|
||||
|
||||
@@ -129,9 +129,9 @@ CvGBTreesParams::CvGBTreesParams
|
||||
:param weak_count: Count of boosting algorithm iterations. ``weak_count*K`` is the total
|
||||
count of trees in the GBT model, where ``K`` is the output classes count
|
||||
(equal to one in case of a regression).
|
||||
|
||||
|
||||
:param shrinkage: Regularization parameter (see :ref:`Training GBT`).
|
||||
|
||||
|
||||
:param subsample_portion: Portion of the whole training set used for each algorithm iteration.
|
||||
Subset is generated randomly. For more information see
|
||||
http://www.salfordsystems.com/doc/StochasticBoostingSS.pdf.
|
||||
@@ -139,7 +139,7 @@ CvGBTreesParams::CvGBTreesParams
|
||||
:param max_depth: Maximal depth of each decision tree in the ensemble (see :ocv:class:`CvDTree`).
|
||||
|
||||
:param use_surrogates: If ``true``, surrogate splits are built (see :ocv:class:`CvDTree`).
|
||||
|
||||
|
||||
By default the following constructor is used:
|
||||
|
||||
.. code-block:: cpp
|
||||
@@ -178,7 +178,7 @@ Trains a Gradient boosted tree model.
|
||||
.. ocv:function:: bool CvGBTrees::train(CvMLData* data, CvGBTreesParams params=CvGBTreesParams(), bool update=false)
|
||||
|
||||
.. ocv:pyfunction:: cv2.GBTrees.train(trainData, tflag, responses[, varIdx[, sampleIdx[, varType[, missingDataMask[, params[, update]]]]]]) -> retval
|
||||
|
||||
|
||||
The first train method follows the common template (see :ocv:func:`CvStatModel::train`).
|
||||
Both ``tflag`` values (``CV_ROW_SAMPLE``, ``CV_COL_SAMPLE``) are supported.
|
||||
``trainData`` must be of the ``CV_32F`` type. ``responses`` must be a matrix of type
|
||||
@@ -188,7 +188,7 @@ list of indices (``CV_32S``) or a mask (``CV_8U`` or ``CV_8S``). ``update`` is
|
||||
a dummy parameter.
|
||||
|
||||
The second form of :ocv:func:`CvGBTrees::train` function uses :ocv:class:`CvMLData` as a
|
||||
data set container. ``update`` is still a dummy parameter.
|
||||
data set container. ``update`` is still a dummy parameter.
|
||||
|
||||
All parameters specific to the GBT model are passed into the training function
|
||||
as a :ocv:class:`CvGBTreesParams` structure.
|
||||
@@ -207,42 +207,42 @@ Predicts a response for an input sample.
|
||||
:param sample: Input feature vector that has the same format as every training set
|
||||
element. If not all the variables were actually used during training,
|
||||
``sample`` contains forged values at the appropriate places.
|
||||
|
||||
|
||||
:param missing: Missing values mask, which is a dimensional matrix of the same size as
|
||||
``sample`` having the ``CV_8U`` type. ``1`` corresponds to the missing value
|
||||
in the same position in the ``sample`` vector. If there are no missing values
|
||||
in the feature vector, an empty matrix can be passed instead of the missing mask.
|
||||
|
||||
|
||||
:param weakResponses: Matrix used to obtain predictions of all the trees.
|
||||
The matrix has :math:`K` rows,
|
||||
where :math:`K` is the count of output classes (1 for the regression case).
|
||||
The matrix has as many columns as the ``slice`` length.
|
||||
|
||||
|
||||
:param slice: Parameter defining the part of the ensemble used for prediction.
|
||||
If ``slice = Range::all()``, all trees are used. Use this parameter to
|
||||
get predictions of the GBT models with different ensemble sizes learning
|
||||
only one model.
|
||||
|
||||
|
||||
:param k: Number of tree ensembles built in case of the classification problem
|
||||
(see :ref:`Training GBT`). Use this
|
||||
parameter to change the output to sum of the trees' predictions in the
|
||||
``k``-th ensemble only. To get the total GBT model prediction, ``k`` value
|
||||
must be -1. For regression problems, ``k`` is also equal to -1.
|
||||
|
||||
|
||||
The method predicts the response corresponding to the given sample
|
||||
(see :ref:`Predicting with GBT`).
|
||||
The result is either the class label or the estimated function value. The
|
||||
:ocv:func:`CvGBTrees::predict` method enables using the parallel version of the GBT model
|
||||
prediction if the OpenCV is built with the TBB library. In this case, predictions
|
||||
of single trees are computed in a parallel fashion.
|
||||
of single trees are computed in a parallel fashion.
|
||||
|
||||
|
||||
|
||||
CvGBTrees::clear
|
||||
----------------
|
||||
Clears the model.
|
||||
|
||||
.. ocv:function:: void CvGBTrees::clear()
|
||||
|
||||
|
||||
.. ocv:pyfunction:: cv2.GBTrees.clear() -> None
|
||||
|
||||
The function deletes the data set information and all the weak models and sets all internal
|
||||
@@ -257,7 +257,7 @@ Calculates a training or testing error.
|
||||
.. ocv:function:: float CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp = 0 )
|
||||
|
||||
:param _data: Data set.
|
||||
|
||||
|
||||
:param type: Parameter defining the error that should be computed: train (``CV_TRAIN_ERROR``) or test
|
||||
(``CV_TEST_ERROR``).
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Trains the model.
|
||||
|
||||
:param updateBase: Specifies whether the model is trained from scratch (``update_base=false``), or it is updated using the new training data (``update_base=true``). In the latter case, the parameter ``maxK`` must not be larger than the original value.
|
||||
|
||||
The method trains the K-Nearest model. It follows the conventions of the generic :ocv:func:`CvStatModel::train` approach with the following limitations:
|
||||
The method trains the K-Nearest model. It follows the conventions of the generic :ocv:func:`CvStatModel::train` approach with the following limitations:
|
||||
|
||||
* Only ``CV_ROW_SAMPLE`` data layout is supported.
|
||||
* Input variables are all ordered.
|
||||
|
||||
+31
-31
@@ -9,7 +9,7 @@ CvMLData
|
||||
--------
|
||||
.. ocv:class:: CvMLData
|
||||
|
||||
Class for loading the data from a ``.csv`` file.
|
||||
Class for loading the data from a ``.csv`` file.
|
||||
::
|
||||
|
||||
class CV_EXPORTS CvMLData
|
||||
@@ -27,42 +27,42 @@ Class for loading the data from a ``.csv`` file.
|
||||
void set_response_idx( int idx );
|
||||
int get_response_idx() const;
|
||||
|
||||
|
||||
|
||||
void set_train_test_split( const CvTrainTestSplit * spl);
|
||||
const CvMat* get_train_sample_idx() const;
|
||||
const CvMat* get_test_sample_idx() const;
|
||||
void mix_train_and_test_idx();
|
||||
|
||||
|
||||
const CvMat* get_var_idx();
|
||||
void change_var_idx( int vi, bool state );
|
||||
|
||||
const CvMat* get_var_types();
|
||||
void set_var_types( const char* str );
|
||||
|
||||
|
||||
int get_var_type( int var_idx ) const;
|
||||
void change_var_type( int var_idx, int type);
|
||||
|
||||
|
||||
void set_delimiter( char ch );
|
||||
char get_delimiter() const;
|
||||
|
||||
void set_miss_ch( char ch );
|
||||
char get_miss_ch() const;
|
||||
|
||||
|
||||
const std::map<std::string, int>& get_class_labels_map() const;
|
||||
|
||||
protected:
|
||||
...
|
||||
|
||||
protected:
|
||||
...
|
||||
};
|
||||
|
||||
CvMLData::read_csv
|
||||
------------------
|
||||
Reads the data set from a ``.csv``-like ``filename`` file and stores all read values in a matrix.
|
||||
Reads the data set from a ``.csv``-like ``filename`` file and stores all read values in a matrix.
|
||||
|
||||
.. ocv:function:: int CvMLData::read_csv(const char* filename)
|
||||
|
||||
:param filename: The input file name
|
||||
|
||||
While reading the data, the method tries to define the type of variables (predictors and responses): ordered or categorical. If a value of the variable is not numerical (except for the label for a missing value), the type of the variable is set to ``CV_VAR_CATEGORICAL``. If all existing values of the variable are numerical, the type of the variable is set to ``CV_VAR_ORDERED``. So, the default definition of variables types works correctly for all cases except the case of a categorical variable with numerical class labels. In this case, the type ``CV_VAR_ORDERED`` is set. You should change the type to ``CV_VAR_CATEGORICAL`` using the method :ocv:func:`CvMLData::change_var_type`. For categorical variables, a common map is built to convert a string class label to the numerical class label. Use :ocv:func:`CvMLData::get_class_labels_map` to obtain this map.
|
||||
While reading the data, the method tries to define the type of variables (predictors and responses): ordered or categorical. If a value of the variable is not numerical (except for the label for a missing value), the type of the variable is set to ``CV_VAR_CATEGORICAL``. If all existing values of the variable are numerical, the type of the variable is set to ``CV_VAR_ORDERED``. So, the default definition of variables types works correctly for all cases except the case of a categorical variable with numerical class labels. In this case, the type ``CV_VAR_ORDERED`` is set. You should change the type to ``CV_VAR_CATEGORICAL`` using the method :ocv:func:`CvMLData::change_var_type`. For categorical variables, a common map is built to convert a string class label to the numerical class label. Use :ocv:func:`CvMLData::get_class_labels_map` to obtain this map.
|
||||
|
||||
Also, when reading the data, the method constructs the mask of missing values. For example, values are equal to `'?'`.
|
||||
|
||||
@@ -72,7 +72,7 @@ Returns a pointer to the matrix of predictors and response values
|
||||
|
||||
.. ocv:function:: const CvMat* CvMLData::get_values() const
|
||||
|
||||
The method returns a pointer to the matrix of predictor and response ``values`` or ``0`` if the data has not been loaded from the file yet.
|
||||
The method returns a pointer to the matrix of predictor and response ``values`` or ``0`` if the data has not been loaded from the file yet.
|
||||
|
||||
The row count of this matrix equals the sample count. The column count equals predictors ``+ 1`` for the response (if exists) count. This means that each row of the matrix contains values of one sample predictor and response. The matrix type is ``CV_32FC1``.
|
||||
|
||||
@@ -82,7 +82,7 @@ Returns a pointer to the matrix of response values
|
||||
|
||||
.. ocv:function:: const CvMat* CvMLData::get_responses()
|
||||
|
||||
The method returns a pointer to the matrix of response values or throws an exception if the data has not been loaded from the file yet.
|
||||
The method returns a pointer to the matrix of response values or throws an exception if the data has not been loaded from the file yet.
|
||||
|
||||
This is a single-column matrix of the type ``CV_32FC1``. Its row count is equal to the sample count, one column and .
|
||||
|
||||
@@ -92,7 +92,7 @@ Returns a pointer to the mask matrix of missing values
|
||||
|
||||
.. ocv:function:: const CvMat* CvMLData::get_missing() const
|
||||
|
||||
The method returns a pointer to the mask matrix of missing values or throws an exception if the data has not been loaded from the file yet.
|
||||
The method returns a pointer to the mask matrix of missing values or throws an exception if the data has not been loaded from the file yet.
|
||||
|
||||
This matrix has the same size as the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) and the type ``CV_8UC1``.
|
||||
|
||||
@@ -102,7 +102,7 @@ Specifies index of response column in the data matrix
|
||||
|
||||
.. ocv:function:: void CvMLData::set_response_idx( int idx )
|
||||
|
||||
The method sets the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
|
||||
The method sets the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
|
||||
|
||||
The old response columns become predictors. If ``idx < 0``, there is no response.
|
||||
|
||||
@@ -115,15 +115,15 @@ Returns index of the response column in the loaded data matrix
|
||||
The method returns the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
|
||||
|
||||
If ``idx < 0``, there is no response.
|
||||
|
||||
|
||||
|
||||
CvMLData::set_train_test_split
|
||||
------------------------------
|
||||
Divides the read data set into two disjoint training and test subsets.
|
||||
Divides the read data set into two disjoint training and test subsets.
|
||||
|
||||
.. ocv:function:: void CvMLData::set_train_test_split( const CvTrainTestSplit * spl )
|
||||
|
||||
This method sets parameters for such a split using ``spl`` (see :ocv:class:`CvTrainTestSplit`) or throws an exception if the data has not been loaded from the file yet.
|
||||
This method sets parameters for such a split using ``spl`` (see :ocv:class:`CvTrainTestSplit`) or throws an exception if the data has not been loaded from the file yet.
|
||||
|
||||
CvMLData::get_train_sample_idx
|
||||
------------------------------
|
||||
@@ -139,13 +139,13 @@ Returns the matrix of sample indices for a testing subset
|
||||
|
||||
.. ocv:function:: const CvMat* CvMLData::get_test_sample_idx() const
|
||||
|
||||
|
||||
|
||||
CvMLData::mix_train_and_test_idx
|
||||
--------------------------------
|
||||
Mixes the indices of training and test samples
|
||||
|
||||
.. ocv:function:: void CvMLData::mix_train_and_test_idx()
|
||||
|
||||
|
||||
The method shuffles the indices of training and test samples preserving sizes of training and test subsets if the data split is set by :ocv:func:`CvMLData::get_values`. If the data has not been loaded from the file yet, an exception is thrown.
|
||||
|
||||
CvMLData::get_var_idx
|
||||
@@ -153,8 +153,8 @@ CvMLData::get_var_idx
|
||||
Returns the indices of the active variables in the data matrix
|
||||
|
||||
.. ocv:function:: const CvMat* CvMLData::get_var_idx()
|
||||
|
||||
The method returns the indices of variables (columns) used in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`).
|
||||
|
||||
The method returns the indices of variables (columns) used in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`).
|
||||
|
||||
It returns ``0`` if the used subset is not set. It throws an exception if the data has not been loaded from the file yet. Returned matrix is a single-row matrix of the type ``CV_32SC1``. Its column count is equal to the size of the used variable subset.
|
||||
|
||||
@@ -165,22 +165,22 @@ Enables or disables particular variable in the loaded data
|
||||
.. ocv:function:: void CvMLData::change_var_idx( int vi, bool state )
|
||||
|
||||
By default, after reading the data set all variables in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) are used. But you may want to use only a subset of variables and include/exclude (depending on ``state`` value) a variable with the ``vi`` index from the used subset. If the data has not been loaded from the file yet, an exception is thrown.
|
||||
|
||||
|
||||
CvMLData::get_var_types
|
||||
-----------------------
|
||||
Returns a matrix of the variable types.
|
||||
Returns a matrix of the variable types.
|
||||
|
||||
.. ocv:function:: const CvMat* CvMLData::get_var_types()
|
||||
|
||||
|
||||
The function returns a single-row matrix of the type ``CV_8UC1``, where each element is set to either ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``. The number of columns is equal to the number of variables. If data has not been loaded from file yet an exception is thrown.
|
||||
|
||||
|
||||
CvMLData::set_var_types
|
||||
-----------------------
|
||||
Sets the variables types in the loaded data.
|
||||
|
||||
.. ocv:function:: void CvMLData::set_var_types( const char* str )
|
||||
|
||||
In the string, a variable type is followed by a list of variables indices. For example: ``"ord[0-17],cat[18]"``, ``"ord[0,2,4,10-12], cat[1,3,5-9,13,14]"``, ``"cat"`` (all variables are categorical), ``"ord"`` (all variables are ordered).
|
||||
In the string, a variable type is followed by a list of variables indices. For example: ``"ord[0-17],cat[18]"``, ``"ord[0,2,4,10-12], cat[1,3,5-9,13,14]"``, ``"cat"`` (all variables are categorical), ``"ord"`` (all variables are ordered).
|
||||
|
||||
CvMLData::get_var_type
|
||||
----------------------
|
||||
@@ -189,15 +189,15 @@ Returns type of the specified variable
|
||||
.. ocv:function:: int CvMLData::get_var_type( int var_idx ) const
|
||||
|
||||
The method returns the type of a variable by the index ``var_idx`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
|
||||
|
||||
|
||||
CvMLData::change_var_type
|
||||
-------------------------
|
||||
Changes type of the specified variable
|
||||
|
||||
.. ocv:function:: void CvMLData::change_var_type( int var_idx, int type)
|
||||
|
||||
|
||||
The method changes type of variable with index ``var_idx`` from existing type to ``type`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
|
||||
|
||||
|
||||
CvMLData::set_delimiter
|
||||
-----------------------
|
||||
Sets the delimiter in the file used to separate input numbers
|
||||
@@ -260,6 +260,6 @@ Structure setting the split of a data set read by :ocv:class:`CvMLData`.
|
||||
|
||||
There are two ways to construct a split:
|
||||
|
||||
* Set the training sample count (subset size) ``train_sample_count``. Other existing samples are located in a test subset.
|
||||
* Set the training sample count (subset size) ``train_sample_count``. Other existing samples are located in a test subset.
|
||||
|
||||
* Set a training sample portion in ``[0,..1]``. The flag ``mix`` is used to mix training and test samples indices when the split is set. Otherwise, the data set is split in the storing order: the first part of samples of a given size is a training subset, the second part is a test subset.
|
||||
|
||||
@@ -116,7 +116,7 @@ bool CvKNearest::train( const CvMat* _train_data, const CvMat* _responses,
|
||||
|
||||
if( !responses )
|
||||
CV_ERROR( CV_StsNoMem, "Could not allocate memory for responses" );
|
||||
|
||||
|
||||
if( _update_base && _dims != var_count )
|
||||
CV_ERROR( CV_StsBadArg, "The newly added data have different dimensionality" );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user