imputers

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package imputers provides missing value imputation transformers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IterativeImputer

type IterativeImputer struct {
	// MaxIter is the maximum number of imputation rounds
	MaxIter int

	// Tolerance for convergence
	Tolerance float64

	// InitialStrategy for first imputation ("mean" or "median")
	InitialStrategy string
	// contains filtered or unexported fields
}

IterativeImputer fills missing values using an iterative approach (MICE algorithm). Each feature with missing values is modeled as a function of other features. This is a simplified implementation placeholder.

func NewIterativeImputer

func NewIterativeImputer() *IterativeImputer

NewIterativeImputer creates a new IterativeImputer.

func (*IterativeImputer) Fit

func (i *IterativeImputer) Fit(df *dataframe.DataFrame, _ ...string) error

Fit prepares the imputer by analyzing data structure.

func (*IterativeImputer) FitTransform

func (i *IterativeImputer) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)

FitTransform fits the imputer and transforms the data in one step.

func (*IterativeImputer) IsFitted

func (i *IterativeImputer) IsFitted() bool

IsFitted returns true if the imputer has been fitted.

func (*IterativeImputer) Transform

Transform applies iterative imputation using MICE (Multivariate Imputation by Chained Equations).

type KNNImputer

type KNNImputer struct {
	// NNeighbors is the number of neighbors to use
	NNeighbors int

	// Weights specifies the weight function:
	// - "uniform": all neighbors have equal weight
	// - "distance": weight inversely proportional to distance
	Weights string
	// contains filtered or unexported fields
}

KNNImputer fills missing values using k-Nearest Neighbors. For each sample with missing values, it finds k nearest neighbors and uses their values (weighted by distance) for imputation.

func NewKNNImputer

func NewKNNImputer(nNeighbors int) *KNNImputer

NewKNNImputer creates a new KNNImputer.

func (*KNNImputer) Fit

func (k *KNNImputer) Fit(df *dataframe.DataFrame, _ ...string) error

Fit stores the reference data for neighbor lookup.

func (*KNNImputer) FitTransform

func (k *KNNImputer) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)

FitTransform fits the imputer and transforms the data in one step.

func (*KNNImputer) IsFitted

func (k *KNNImputer) IsFitted() bool

IsFitted returns true if the imputer has been fitted.

func (*KNNImputer) Transform

func (k *KNNImputer) Transform(df *dataframe.DataFrame) (*dataframe.DataFrame, error)

Transform applies KNN imputation to the data.

type SimpleImputer

type SimpleImputer struct {
	// Columns to impute. If nil, all columns with nulls are imputed.
	Columns []string

	// Strategy for imputation:
	// - "mean": replace with mean (numeric only)
	// - "median": replace with median (numeric only)
	// - "most_frequent": replace with mode
	// - "constant": replace with FillValue
	Strategy string

	// FillValue is used when Strategy="constant"
	FillValue any
	// contains filtered or unexported fields
}

SimpleImputer fills missing values using basic strategies.

func NewSimpleImputer

func NewSimpleImputer(columns []string, strategy string) *SimpleImputer

NewSimpleImputer creates a new SimpleImputer with the given strategy.

func (*SimpleImputer) Fit

func (s *SimpleImputer) Fit(df *dataframe.DataFrame, _ ...string) error

Fit computes the statistics for imputation.

func (*SimpleImputer) FitTransform

func (s *SimpleImputer) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)

FitTransform fits the imputer and transforms the data in one step.

func (*SimpleImputer) GetStats

func (s *SimpleImputer) GetStats() map[string]any

GetStats returns the computed statistics for each column.

func (*SimpleImputer) IsFitted

func (s *SimpleImputer) IsFitted() bool

IsFitted returns true if the imputer has been fitted.

func (*SimpleImputer) Transform

func (s *SimpleImputer) Transform(df *dataframe.DataFrame) (*dataframe.DataFrame, error)

Transform applies the imputation to the data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL