teachpyx.practice.ml_skl

class teachpyx.practice.ml_skl.PositiveOrNegativeLinearRegression(epsilon: float = 1.0, max_iter: int = 100, positive: bool = True)[source][source]

Trains a linear regression with coefficients of the same sign. The order of inheritance must be RegressorMixin, BaseEstimator otherwise the tags are wrong.

Paramètres:
  • epsilon – gradient step

  • max_iter – number maximum of iterations

  • positive – only positive weights (or negative if False)

Tags can be changed.

def __sklearn_tags__(self):
    tags = RegressorMixin.__sklearn_tags__(self)
    return tags

    return Tags(
        estimator_type=None,
        target_tags=TargetTags(required=False),
        transformer_tags=None,
        regressor_tags=None,
        classifier_tags=None,
    )

Or:

def __sklearn_tags__(self):
    return Tags(
        estimator_type="regressor",
        classifier_tags=None,
        regressor_tags=RegressorTags(),
        transformer_tags=None,
        target_tags=TargetTags(required=True),
    )
fit(X, y)[source][source]

Trains.

predict(X)[source][source]

Predicts.