Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] remove non usable input in ftns and add **kwargs #30

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mqboost/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _rho(error: np.ndarray, alpha: float) -> np.ndarray:
return -error * _grad_rho(error=error, alpha=alpha)


def _hess_rho(error: np.ndarray, alpha: float) -> np.ndarray:
def _hess_rho(error: np.ndarray, **kwargs) -> np.ndarray:
"""Compute the Hessian of the check."""
return np.ones_like(error)

Expand All @@ -36,7 +36,7 @@ def _grad_huber(error: np.ndarray, alpha: float, delta: float) -> np.ndarray:
return _r * _smaller_delta + _grad * _bigger_delta


def _hess_huber(error: np.ndarray, alpha: float, delta: float) -> np.ndarray:
def _hess_huber(error: np.ndarray, **kwargs) -> np.ndarray:
"""Compute the Hessian of the huber loss function."""
return np.ones_like(error)

Expand All @@ -48,7 +48,7 @@ def _grad_approx(error: np.ndarray, alpha: float, epsilon: float):
return _grad


def _hess_approx(error: np.ndarray, alpha: float, epsilon: float):
def _hess_approx(error: np.ndarray, epsilon: float, **kwargs):
"""Compute the Hessian of the approx of the smooth approximated check loss function."""
_hess = 1 / (2 * (epsilon + np.abs(error)))
return _hess
Expand All @@ -70,7 +70,7 @@ def _compute_grads_hess(
alphas: list[float],
grad_fn: Callable[[np.ndarray, float, Any], np.ndarray],
hess_fn: Callable[[np.ndarray, float, Any], np.ndarray],
**kwargs: Any,
**kwargs: dict[str, float],
) -> tuple[np.ndarray, np.ndarray]:
"""Compute gradients and hessians for the given loss function."""
_len_alpha = len(alphas)
Expand Down
Loading