scorecard_param¶
scorecard_param
¶
Classes¶
ScorecardParam (BaseParam)
¶
Define method used for transforming prediction score to credit score
Parameters¶
method : {"credit"}, default: 'credit' score method, currently only supports "credit"
offset : int or float, default: 500 score baseline
factor : int or float, default: 20 scoring step, when odds double, result score increases by this factor
factor_base : int or float, default: 2 factor base, value ln(factor_base) is used for calculating result score
upper_limit_ratio : int or float, default: 3 upper bound for odds, credit score upper bound is upper_limit_ratio * offset
lower_limit_value : int or float, default: 0 lower bound for result score
need_run : bool, default: True Indicate if this module needs to be run.
Source code in federatedml/param/scorecard_param.py
class ScorecardParam(BaseParam):
"""
Define method used for transforming prediction score to credit score
Parameters
----------
method : {"credit"}, default: 'credit'
score method, currently only supports "credit"
offset : int or float, default: 500
score baseline
factor : int or float, default: 20
scoring step, when odds double, result score increases by this factor
factor_base : int or float, default: 2
factor base, value ln(factor_base) is used for calculating result score
upper_limit_ratio : int or float, default: 3
upper bound for odds, credit score upper bound is upper_limit_ratio * offset
lower_limit_value : int or float, default: 0
lower bound for result score
need_run : bool, default: True
Indicate if this module needs to be run.
"""
def __init__(
self,
method="credit",
offset=500,
factor=20,
factor_base=2,
upper_limit_ratio=3,
lower_limit_value=0,
need_run=True):
super(ScorecardParam, self).__init__()
self.method = method
self.offset = offset
self.factor = factor
self.factor_base = factor_base
self.upper_limit_ratio = upper_limit_ratio
self.lower_limit_value = lower_limit_value
self.need_run = need_run
def check(self):
descr = "scorecard param"
if not isinstance(self.method, str):
raise ValueError(f"{descr}method {self.method} not supported, should be str type")
else:
user_input = self.method.lower()
if user_input == "credit":
self.method = consts.CREDIT
else:
raise ValueError(f"{descr} method {user_input} not supported")
if type(self.offset).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} offset must be numeric,"
f"received {type(self.offset)} instead.")
if type(self.factor).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} factor must be numeric,"
f"received {type(self.factor)} instead.")
if type(self.factor_base).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} factor_base must be numeric,"
f"received {type(self.factor_base)} instead.")
if type(self.upper_limit_ratio).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} upper_limit_ratio must be numeric,"
f"received {type(self.upper_limit_ratio)} instead.")
if type(self.lower_limit_value).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} lower_limit_value must be numeric,"
f"received {type(self.lower_limit_value)} instead.")
BaseParam.check_boolean(self.need_run, descr=descr + "need_run ")
LOGGER.debug("Finish Scorecard parameter check!")
return True
__init__(self, method='credit', offset=500, factor=20, factor_base=2, upper_limit_ratio=3, lower_limit_value=0, need_run=True)
special
¶
Source code in federatedml/param/scorecard_param.py
def __init__(
self,
method="credit",
offset=500,
factor=20,
factor_base=2,
upper_limit_ratio=3,
lower_limit_value=0,
need_run=True):
super(ScorecardParam, self).__init__()
self.method = method
self.offset = offset
self.factor = factor
self.factor_base = factor_base
self.upper_limit_ratio = upper_limit_ratio
self.lower_limit_value = lower_limit_value
self.need_run = need_run
check(self)
¶
Source code in federatedml/param/scorecard_param.py
def check(self):
descr = "scorecard param"
if not isinstance(self.method, str):
raise ValueError(f"{descr}method {self.method} not supported, should be str type")
else:
user_input = self.method.lower()
if user_input == "credit":
self.method = consts.CREDIT
else:
raise ValueError(f"{descr} method {user_input} not supported")
if type(self.offset).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} offset must be numeric,"
f"received {type(self.offset)} instead.")
if type(self.factor).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} factor must be numeric,"
f"received {type(self.factor)} instead.")
if type(self.factor_base).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} factor_base must be numeric,"
f"received {type(self.factor_base)} instead.")
if type(self.upper_limit_ratio).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} upper_limit_ratio must be numeric,"
f"received {type(self.upper_limit_ratio)} instead.")
if type(self.lower_limit_value).__name__ not in ["int", "long", "float"]:
raise ValueError(f"{descr} lower_limit_value must be numeric,"
f"received {type(self.lower_limit_value)} instead.")
BaseParam.check_boolean(self.need_run, descr=descr + "need_run ")
LOGGER.debug("Finish Scorecard parameter check!")
return True
最后更新:
2022-08-31