crandas.crlearn

class crandas.crlearn.logistic_regression.CLogisticRegression(instance=None)

Bases: CModel

Logistic Regression Classifier Object with the same parameters as the Scikit-learn Logistic Regression Class

See here for its parameters.

Parameters:

  • type: type (binomial/multinomial/ordinal)

  • optimizer: optimizer used to fit the model (see crandas.crlearn.optimizer.OptimizerParams)

  • max_iter: number of iterations to perform

  • warm_start: whether to continue fitting from the previous optimizer state

Attributes:

  • feature_names_in_: input feature names

  • n_classes_: number of output classes

  • feature_name_out_: output feature name

  • optimizer_: attributes of the optimizer used to fit the model (see crandas.crlearn.optimizer.OptimizerAttributes)

  • beta_: (encrypted) fitted parameters (intercept(s) and coefficients)

fit(X, y, *, n_classes=None, sample_weight=None, **query_args)

Fit a Linear Regression model on the data

Parameters:
  • X (CDataFrame) – Training data

  • y (CDataFrame) – Target data (should have only 1 column)

  • n_classes (int or None) – Number of output classes (categories). For binomial models, if not given, n_classes is assumed to be equal to two. For other models, if not given, the number of classes is derived from the metadata of y.

  • sample_weight (None) – Not supported

  • query_args – See queryargs

Returns:

self

Return type:

CLogisticRegression

from_beta(*, type='binomial', n_classes=2, feature_names_in, feature_name_out='out')

Upload pre-fittted logistic regression model

Parameters:
  • beta (list[float]) – Fitted parameters

  • type (str, default "binomial") – Type of model (“binomial”/”multinomial”/”ordinal”)

  • n_classes (int, default 2) – Number of classes

  • feature_names_in (list[str]) – Input feature names

  • feature_name_out (str, default "out") – Output feature name

Returns:

Logistic regression model with given parameters

Return type:

CLogisticRegression

predict(X, decision_boundary=0.5, **query_args)

Make (binary) predictions on a dataset using a logistic regression model

Note: this returns binary predictions, not probabilities!

Parameters:
  • X (CDataFrame) – predictor variables

  • decision_boundary (float) – number between 0 and 1; records with a probability below this value are classified as 0, greater than or equal to as 1

  • query_args – See queryargs

Returns:

table containing the column consisting of the predicted target values

Return type:

CDataFrame

predict_proba(X, **query_args)

Make (probability) predictions on a dataset using a logistic regression model

Note: this returns probabilities, not binary predictions

Parameters:
  • X (CDataFrame) – predictor variables

  • query_args – See queryargs

Returns:

table with columns representing predicted class probabilities per input record

Return type:

CDataFrame

crandas.crlearn.logistic_regression.LogisticRegression(penalty='l2', *, optimizer='lbfgs', type='binomial', dual=False, tol=0.0001, C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, random_state=None, solver=None, max_iter=10, verbose=0, warm_start=False, n_jobs=None, l1_ratio=None, **query_args)

Create a new logistic regression model (CLogisticRegression).

See CLogisticRegression) for the meaning of the parameters. Parameters not listed in that class have the same meaning as in scikit-learn but cannot be changed from their defaults.