File size: 1,383 Bytes
db26c81 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
def continuous_feature(name):
return ContinuousFeature(name)
class ContinuousFeature:
def __init__(self, name):
self.name = name
def global_category(name, size):
return GlobalCategory(name, size)
class GlobalCategory:
def __init__(self, name, size):
self.name = name
self.size = size
def local_category(name):
return LocalCategory(name)
class LocalCategory:
def __init__(self, name):
assert name.startswith('task_'), \
"only task feature supported: {}".format(name)
self.name = name
def local_feature(name):
return LocalFeature(name)
class LocalFeature:
def __init__(self, name):
assert name.startswith('task_'), \
"only task feature supported: {}".format(name)
self.name = name
def sparse_local_feature(index, value):
return SparseLocalFeature(index, value)
class SparseLocalFeature:
def __init__(self, index, value):
assert index.startswith('task_'), \
"only task feature supported for index: {}".format(index)
assert value.startswith('task_'), \
"only task feature supported for value: {}".format(value)
self.index = index
self.value = value
def variable_feature(name):
return VariableFeature(name)
class VariableFeature:
def __init__(self, name):
self.name = name
|