mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-08 16:42:04 +00:00
258d2fd499
* normalize
* split & adjust links
* re-normalize
* adjust ru links
* adjust ja/tr links
* partially apply e0d19d2aea
* reset contribs
56 lines
2.0 KiB
Markdown
56 lines
2.0 KiB
Markdown
---
|
|
toc_priority: 222
|
|
---
|
|
|
|
# stochasticLogisticRegression {#agg_functions-stochasticlogisticregression}
|
|
|
|
This function implements stochastic logistic regression. It can be used for binary classification problem, supports the same custom parameters as stochasticLinearRegression and works the same way.
|
|
|
|
### Parameters {#agg_functions-stochasticlogisticregression-parameters}
|
|
|
|
Parameters are exactly the same as in stochasticLinearRegression:
|
|
`learning rate`, `l2 regularization coefficient`, `mini-batch size`, `method for updating weights`.
|
|
For more information see [parameters](#agg_functions-stochasticlinearregression-parameters).
|
|
|
|
``` text
|
|
stochasticLogisticRegression(1.0, 1.0, 10, 'SGD')
|
|
```
|
|
|
|
**1.** Fitting
|
|
|
|
<!-- -->
|
|
|
|
See the `Fitting` section in the [stochasticLinearRegression](#stochasticlinearregression-usage-fitting) description.
|
|
|
|
Predicted labels have to be in \[-1, 1\].
|
|
|
|
**2.** Predicting
|
|
|
|
<!-- -->
|
|
|
|
Using saved state we can predict probability of object having label `1`.
|
|
|
|
``` sql
|
|
WITH (SELECT state FROM your_model) AS model SELECT
|
|
evalMLMethod(model, param1, param2) FROM test_data
|
|
```
|
|
|
|
The query will return a column of probabilities. Note that first argument of `evalMLMethod` is `AggregateFunctionState` object, next are columns of features.
|
|
|
|
We can also set a bound of probability, which assigns elements to different labels.
|
|
|
|
``` sql
|
|
SELECT ans < 1.1 AND ans > 0.5 FROM
|
|
(WITH (SELECT state FROM your_model) AS model SELECT
|
|
evalMLMethod(model, param1, param2) AS ans FROM test_data)
|
|
```
|
|
|
|
Then the result will be labels.
|
|
|
|
`test_data` is a table like `train_data` but may not contain target value.
|
|
|
|
**See Also**
|
|
|
|
- [stochasticLinearRegression](../../../sql-reference/aggregate-functions/reference/stochasticlinearregression.md#agg_functions-stochasticlinearregression)
|
|
- [Difference between linear and logistic regressions.](https://stackoverflow.com/questions/12146914/what-is-the-difference-between-linear-regression-and-logistic-regression)
|