Machine Learning Functions

evalMLMethod

Prediction using fitted regression models uses evalMLMethod function. See link in linearRegression.

stochasticLinearRegressionn

The stochasticLinearRegression aggregate function implements stochastic gradient descent method using linear model and MSE loss function. Uses evalMLMethod to predict on new data.

stochasticLogisticRegression

The stochasticLogisticRegression aggregate function implements stochastic gradient descent method for binary classification problem. Uses evalMLMethod to predict on new data.

bayesAB

Compares test groups (variants) and calculates for each group the probability to be the best one. The first group is used as a control group.

Syntax

  1. bayesAB(distribution_name, higher_is_better, variant_names, x, y)

Arguments

  • distribution_name — Name of the probability distribution. String. Possible values:

  • higher_is_better — Boolean flag. Boolean. Possible values:

    • 0 - lower values are considered to be better than higher
    • 1 - higher values are considered to be better than lower
  • variant_names - Variant names. Array(String).

  • x - Numbers of tests for the corresponding variants. Array(Float64).

  • y - Numbers of successful tests for the corresponding variants. Array(Float64).

Note

All three arrays must have the same size. All x and y values must be non-negative constant numbers. y cannot be larger than x.

Returned values

For each variant the function calculates:
- beats_control - long-term probability to out-perform the first (control) variant
- to_be_best - long-term probability to out-perform all other variants

Type: JSON.

Example

Query:

  1. SELECT bayesAB('beta', 1, ['Control', 'A', 'B'], [3000., 3000., 3000.], [100., 90., 110.]) FORMAT PrettySpace;

Result:

  1. {
  2. "data":[
  3. {
  4. "variant_name":"Control",
  5. "x":3000,
  6. "y":100,
  7. "beats_control":0,
  8. "to_be_best":0.22619
  9. },
  10. {
  11. "variant_name":"A",
  12. "x":3000,
  13. "y":90,
  14. "beats_control":0.23469,
  15. "to_be_best":0.04671
  16. },
  17. {
  18. "variant_name":"B",
  19. "x":3000,
  20. "y":110,
  21. "beats_control":0.7580899999999999,
  22. "to_be_best":0.7271
  23. }
  24. ]
  25. }

Original article