def _fit(self, X):
        X = iter(X)
        try:
            first = next(X)
        except (TypeError, __HOLE__):
            raise ValueError("Cannot fit with an empty dataset")
        logger.debug("Starting flattener.fit")
        # Build basic schema
        self._fit_first(first)

        if self.str_tuple_indexes or self.bag_indexes:
            # Is there anything to one-hot encode or bag-of-words encode?
            # See all datapoints looking for one-hot encodeable feature values
            for datapoint in self._iter_valid(X, first=first):
                self._fit_step(datapoint)

        logger.debug("Finished flattener.fit")
        logger.debug("Input tuple size %s, output vector size %s" %
                    (len(first), len(self.indexes)))
        return self
dataset/ETHPy150Open machinalis/featureforge/featureforge/flattener.py/FeatureMappingFlattener._fit