from hulearn.regression import *

FunctionRegressor

This class allows you to pass a function to make the predictions you're interested in.

Parameters

Name Type Description Default
func the function that can make predictions required
**kwargs extra keyword arguments will be pass to the function, can be grid-search-able {}

The functions that are passed need to be pickle-able. That means no lambda functions!

fit(self, X, y)

Show source code in regression/functionregressor.py
20
21
22
23
24
25
26
27
    def fit(self, X, y):
        """
        Fit the classifier. No-Op.
        """
        # Run it to confirm no error happened.
        _ = self.func(X, **self.kwargs)
        self.fitted_ = True
        return self

Fit the classifier. No-Op.

partial_fit(self, X, y=None)

Show source code in regression/functionregressor.py
29
30
31
32
33
34
35
36
    def partial_fit(self, X, y=None):
        """
        Fit the classifier partially. No-Op.
        """
        # Run it to confirm no error happened.
        _ = self.func(X, **self.kwargs)
        self.fitted_ = True
        return self

Fit the classifier partially. No-Op.

predict(self, X)

Show source code in regression/functionregressor.py
38
39
40
41
42
43
    def predict(self, X):
        """
        Make predictions using the passed function.
        """
        check_is_fitted(self, ["fitted_"])
        return self.func(X, **self.kwargs)

Make predictions using the passed function.