Example #1
0
def random_stub():
    # pylint: disable = unused-variable
    import numpy.random as numpy_module
    from nums.core.array.random import NumsRandomState
    from nums.core.application_manager import instance
    app = instance()
    sys = app.system
    rs_inst = NumsRandomState(system=sys, seed=1337)
    numpy_items = sorted(
        systems_utils.get_module_functions(numpy_module).items())
    nums_items = sorted(systems_utils.get_instance_functions(rs_inst).items())
    raise NotImplementedError()
Example #2
0
    def __init__(
        self,
        penalty="none",
        alpha=1.0,
        l1_ratio=0.5,
        tol=0.0001,
        max_iter=100,
        solver="newton",
        lr=0.01,
        random_state=None,
        fit_intercept=True,
        normalize=False,
    ):

        if fit_intercept is False:
            raise NotImplementedError(
                "fit_incercept=False currently not supported.")
        if normalize is True:
            raise NotImplementedError(
                "normalize=True currently not supported.")

        self._app = _instance()
        if random_state is None:
            self.rs: NumsRandomState = self._app.random
        elif array_utils.is_int(random_state):
            self.rs: NumsRandomState = NumsRandomState(cm=self._app.cm,
                                                       seed=random_state)
        elif isinstance(random_state, NumsRandomState):
            self.rs: NumsRandomState = random_state
        else:
            raise Exception("Unexpected type for random_state %s" %
                            str(type(random_state)))
        self._penalty = None if penalty == "none" else penalty
        if self._penalty not in (None, "l1", "l2", "elasticnet"):
            raise NotImplementedError("%s penalty not supported" %
                                      self._penalty)
        # All sources use lambda as regularization term, and alpha l1/l2 ratio.
        self._lambda = alpha
        self._l1penalty = None
        self._l1penalty_vec = None
        self._l2penalty = None
        self._l2penalty_vec = None
        self._l2penalty_diag = None
        self.alpha = l1_ratio
        self._tol = tol
        self._max_iter = max_iter
        self._opt = solver
        self._lr = lr
        self._beta = None
        self._beta0 = None
Example #3
0
File: glms.py Project: dlzou/nums
    def __init__(
        self,
        penalty="none",
        C=1.0,
        tol=0.0001,
        max_iter=100,
        solver="newton-cg",
        lr=0.01,
        random_state=None,
        fit_intercept=True,
        normalize=False,
    ):

        if fit_intercept is False:
            raise NotImplementedError("fit_incercept=False currently not supported.")
        if normalize is True:
            raise NotImplementedError("normalize=True currently not supported.")

        self._app = _instance()
        if random_state is None:
            self.rs: NumsRandomState = self._app.random
        elif array_utils.is_int(random_state):
            self.rs: NumsRandomState = NumsRandomState(
                cm=self._app.cm, seed=random_state
            )
        elif isinstance(random_state, NumsRandomState):
            self.rs: NumsRandomState = random_state
        else:
            raise Exception(
                "Unexpected type for random_state %s" % str(type(random_state))
            )
        self._penalty = None if penalty == "none" else penalty
        if not (self._penalty is None or self._penalty == "l2"):
            raise NotImplementedError("%s penalty not supported" % self._penalty)
        self._lambda = 1.0 / C
        self._lambda_vec = None
        self._tol = tol
        self._max_iter = max_iter
        self._opt = solver
        self._lr = lr
        self._beta = None
        self._beta0 = None
Example #4
0
 def random_state(self, seed=None):
     return NumsRandomState(self.cm, seed)