def estimate(self, X, **kwargs):
if not isinstance(X, Iterable):
if isinstance(X, np.ndarray) or \
(isinstance(X, (list, tuple)) and len(X) > 0 and all([isinstance(x, np.ndarray) for x in X])):
X = DataInMemory(X, self.chunksize)
self.data_producer = X
else:
raise ValueError("no np.ndarray or non-empty list of np.ndarrays given")
# run estimation
try:
super(StreamingTransformer, self).estimate(X, **kwargs)
except NotConvergedWarning as ncw:
self._logger.info(
"Presumely finished estimation. Message: %s" % ncw)
# memory mode? Then map all results. Avoid recursion here, if parametrization
# is triggered from get_output
if self.in_memory and not self._mapping_to_mem_active:
self._map_to_memory()
self._estimated = True
return self
评论列表
文章目录