def _fit(self, dataset: Dataset) -> Preprocessor: if self.strategy == "mean": aggregates = [Mean(col) for col in self.columns] self.stats_ = dataset.aggregate(*aggregates) elif self.strategy == "most_frequent": self.stats_ = _get_most_frequent_values(dataset, *self.columns) return self
def get_max_a(ds: Dataset): # Calculate max value for column A. max_a = ds.aggregate(Max("A")) return max_a
def get_max(ds: Dataset): return ds.aggregate(Max("value"))
def _fit(self, dataset: Dataset) -> Preprocessor: aggregates = [Agg(col) for Agg in [Min, Max] for col in self.columns] self.stats_ = dataset.aggregate(*aggregates) return self
def _fit(self, dataset: Dataset) -> Preprocessor: mean_aggregates = [Mean(col) for col in self.columns] std_aggregates = [Std(col, ddof=self.ddof) for col in self.columns] self.stats_ = dataset.aggregate(*mean_aggregates, *std_aggregates) return self