MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / fit

Method fit

numpy_ml/preprocessing/general.py:72–84  ·  view source on GitHub ↗

Create mappings between columns and category labels. Parameters ---------- categories : list of length `C` List of the unique category labels for the items to encode.

(self, categories)

Source from the content-addressed store, hash-verified

70 return self.transform(labels)
71
72 def fit(self, categories):
73 """
74 Create mappings between columns and category labels.
75
76 Parameters
77 ----------
78 categories : list of length `C`
79 List of the unique category labels for the items to encode.
80 """
81 self.parameters["categories"] = categories
82 self.cat2idx = {c: i for i, c in enumerate(categories)}
83 self.idx2cat = {i: c for i, c in enumerate(categories)}
84 self._is_fit = True
85
86 def transform(self, labels, categories=None):
87 """

Callers 1

transformMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected