Skip to content

Commit

Permalink
Merge pull request #118 from abess-team/create-pull-request/patch
Browse files Browse the repository at this point in the history
Fixes by format action
  • Loading branch information
Mamba413 authored Aug 7, 2024
2 parents 87c7e91 + 6aa2d63 commit a173b2b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions skscope/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def check_y_survival(y_or_event, *args, allow_all_censored=False):
if len(args) == 0:
y = y_or_event

if not isinstance(y, np.ndarray) or y.dtype.fields is None or len(y.dtype.fields) != 2:
if (
not isinstance(y, np.ndarray)
or y.dtype.fields is None
or len(y.dtype.fields) != 2
):
raise ValueError(
"y must be a structured array with the first field"
" being a binary class event indicator and the second field"
Expand All @@ -47,7 +51,9 @@ def check_y_survival(y_or_event, *args, allow_all_censored=False):

event = check_array(y_event, ensure_2d=False)
if not np.issubdtype(event.dtype, np.bool_):
raise ValueError(f"elements of event indicator must be boolean, but found {event.dtype}")
raise ValueError(
f"elements of event indicator must be boolean, but found {event.dtype}"
)

if not (allow_all_censored or np.any(event)):
raise ValueError("all samples are censored")
Expand All @@ -60,7 +66,9 @@ def check_y_survival(y_or_event, *args, allow_all_censored=False):

yt = check_array(yt, ensure_2d=False)
if not np.issubdtype(yt.dtype, np.number):
raise ValueError(f"time must be numeric, but found {yt.dtype} for argument {i + 2}")
raise ValueError(
f"time must be numeric, but found {yt.dtype} for argument {i + 2}"
)

return_val.append(yt)

Expand Down Expand Up @@ -195,7 +203,9 @@ def logistic_loss(params):
The GIC is calculated using the formula:
GIC = 2 * objective_value + effective_params_num * np.log(np.log(train_size)) * np.log(dimensionality)
"""
return 2 * objective_value + effective_params_num * np.log(np.log(train_size)) * np.log(dimensionality)
return 2 * objective_value + effective_params_num * np.log(
np.log(train_size)
) * np.log(dimensionality)


def EBIC(
Expand Down Expand Up @@ -230,7 +240,9 @@ def logistic_loss(params):
The E is calculated using the formula:
EBIC = 2 * objective_value + effective_params_num * (np.log(train_size) + 2 * np.log(dimensionality))
"""
return 2 * objective_value + effective_params_num * (np.log(train_size) + 2 * np.log(dimensionality))
return 2 * objective_value + effective_params_num * (
np.log(train_size) + 2 * np.log(dimensionality)
)


def LinearSIC(
Expand Down Expand Up @@ -267,6 +279,6 @@ def linear_loss(params):
The LinearSIC is calculated using the formula:
LinearSIC = train_size * np.log(objective_value) + 2 * effective_params_num * np.log(np.log(train_size)) * np.log(dimensionality)
"""
return train_size * np.log(objective_value) + 2 * effective_params_num * np.log(np.log(train_size)) * np.log(
dimensionality
)
return train_size * np.log(objective_value) + 2 * effective_params_num * np.log(
np.log(train_size)
) * np.log(dimensionality)

0 comments on commit a173b2b

Please sign in to comment.