d3m.primitive_interfaces.clustering¶
-
class
d3m.primitive_interfaces.clustering.
ClusteringDistanceMatrixMixin
(*args, **kwds)[source]¶ Bases:
Generic
[[typing.Inputs
,typing.Outputs
,typing.Params
,typing.Hyperparams
],typing.DistanceMatrixOutput
]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
-
abstract
produce_distance_matrix
(*, inputs, timeout=None, iterations=None)[source]¶ Semantics of this call are the same as the call to a regular
produce
method, just that the output is a distance matrix instead of a membership map.Implementations of this method should use
inputs_across_samples
decorator to markinputs
as being computed across samples.When this mixin is used with ClusteringTransformerPrimitiveBase,
Params
type variable should be set toNone
.- Parameters
- Return type
CallResult
[~DistanceMatrixOutput]- Returns
The distance matrix of shape [num_inputs, num_inputs, …] wrapped inside
CallResult
, where (i, j) element of the matrix represent a distance between i-th and j-th sample in the inputs.
-
abstract
-
class
d3m.primitive_interfaces.clustering.
ClusteringLearnerPrimitiveBase
(*, hyperparams, random_seed=0, docker_containers=None, volumes=None, temporary_directory=None)[source]¶ Bases:
d3m.primitive_interfaces.unsupervised_learning.UnsupervisedLearnerPrimitiveBase
[[typing.Inputs
,typing.Outputs
,typing.Params
],typing.Hyperparams
]A base class for primitives implementing a clustering algorithm which learns clusters.
-
abstract
produce
(*, inputs, timeout=None, iterations=None)[source]¶ produce
method should return a membership map.A data structure that for each input sample tells to which cluster that sample was assigned to. So
Outputs
should have the same number of samples thanInputs
, and the value at each output sample should represent a cluster. Consider representing it with just a simple numeric identifier.- Parameters
- Return type
CallResult
[~Outputs]- Returns
The outputs of shape [num_inputs, 1] wrapped inside
CallResult
for a simple numeric cluster identifier.
-
docker_containers
: Dict[str, d3m.primitive_interfaces.base.DockerContainer][source]¶ A dict mapping Docker image keys from primitive’s metadata to (named) tuples containing container’s address under which the container is accessible by the primitive, and a dict mapping exposed ports to ports on that address.
-
logger
: ClassVar[logging.Logger][source]¶ Primitive’s logger. Available as a class attribute. This gets automatically set to primitive’s logger in metaclass.
-
metadata
: ClassVar[d3m.metadata.base.PrimitiveMetadata][source]¶ Primitive’s metadata. Available as a class attribute. Primitive author should provide all fields which cannot be determined automatically inside the code. In this way metadata is close to the code and it is easier for consumers to make sure metadata they are using is really matching the code they are using. PrimitiveMetadata class updates itself with metadata about code and other things it can extract automatically.
-
abstract
-
class
d3m.primitive_interfaces.clustering.
ClusteringTransformerPrimitiveBase
(*, hyperparams, random_seed=0, docker_containers=None, volumes=None, temporary_directory=None)[source]¶ Bases:
d3m.primitive_interfaces.transformer.TransformerPrimitiveBase
[[typing.Inputs
,typing.Outputs
],typing.Hyperparams
]A base class for primitives implementing a clustering algorithm without learning any sort of model.
-
abstract
produce
(*, inputs, timeout=None, iterations=None)[source]¶ produce
method should return a membership map.A data structure that for each input sample tells to which cluster that sample was assigned to. So
Outputs
should have the same number of samples thanInputs
, and the value at each output sample should represent a cluster. Consider representing it with just a simple numeric identifier.If an implementation of this method computes clusters based on the whole set of input samples, use
inputs_across_samples
decorator to markinputs
as being computed across samples.- Parameters
- Return type
CallResult
[~Outputs]- Returns
The outputs of shape [num_inputs, 1] wrapped inside
CallResult
for a simple numeric cluster identifier.
-
docker_containers
: Dict[str, d3m.primitive_interfaces.base.DockerContainer][source]¶ A dict mapping Docker image keys from primitive’s metadata to (named) tuples containing container’s address under which the container is accessible by the primitive, and a dict mapping exposed ports to ports on that address.
-
logger
: ClassVar[logging.Logger][source]¶ Primitive’s logger. Available as a class attribute. This gets automatically set to primitive’s logger in metaclass.
-
metadata
: ClassVar[d3m.metadata.base.PrimitiveMetadata][source]¶ Primitive’s metadata. Available as a class attribute. Primitive author should provide all fields which cannot be determined automatically inside the code. In this way metadata is close to the code and it is easier for consumers to make sure metadata they are using is really matching the code they are using. PrimitiveMetadata class updates itself with metadata about code and other things it can extract automatically.
-
abstract