本文整理汇总了Python中Orange.data.ContinuousVariable.compute_value方法的典型用法代码示例。如果您正苦于以下问题:Python ContinuousVariable.compute_value方法的具体用法?Python ContinuousVariable.compute_value怎么用?Python ContinuousVariable.compute_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.ContinuousVariable
的用法示例。
在下文中一共展示了ContinuousVariable.compute_value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform_continuous
# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import compute_value [as 别名]
def transform_continuous(var):
if self.normalize_continuous == Continuize.Leave:
return var
elif self.normalize_continuous == Continuize.NormalizeBySpan:
new_var = ContinuousVariable(var.name)
dma, dmi = dists[var_ptr].max(), dists[var_ptr].min()
diff = dma - dmi
if diff < 1e-15:
diff = 1
if self.zero_based:
new_var.compute_value = Normalizer(var, dmi, 1 / diff)
else:
new_var.compute_value = Normalizer(var, (dma + dmi) / 2,
2 / diff)
return new_var
elif self.normalize_continuous == Continuize.NormalizeBySD:
new_var = ContinuousVariable(var.name)
avg = dists[var_ptr].mean()
sd = dists[var_ptr].standard_deviation()
new_var.compute_value = Normalizer(var, avg, 1 / sd)
return new_var
示例2: transform_discrete
# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import compute_value [as 别名]
def transform_discrete(var):
if (len(var.values) < 2 or
treat == Continuize.Remove or
treat == Continuize.RemoveMultinomial and
len(var.values) > 2):
return []
if treat == Continuize.AsOrdinal:
new_var = ContinuousVariable(var.name)
new_var.compute_value = Identity(var)
return [new_var]
if treat == Continuize.AsNormalizedOrdinal:
new_var = ContinuousVariable(var.name)
n_values = max(1, len(var.values))
if self.zero_based:
new_var.compute_value = \
Normalizer(var, 0, 1 / (n_values - 1))
else:
new_var.compute_value = \
Normalizer(var, (n_values - 1) / 2, 2 / (n_values - 1))
return [new_var]
new_vars = []
if treat == Continuize.Indicators:
base = -1
elif treat in (Continuize.FirstAsBase,
Continuize.RemoveMultinomial):
base = max(var.base_value, 0)
else:
base = dists[var_ptr].modus()
ind_class = [Indicator1, Indicator][self.zero_based]
for i, val in enumerate(var.values):
if i == base:
continue
new_var = ContinuousVariable(
"{}={}".format(var.name, val))
new_var.compute_value = ind_class(var, i)
new_vars.append(new_var)
return new_vars