selectors

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: 4 Imported by: 0

Documentation

Overview

Package selectors provides feature selection transformers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RFE

type RFE struct {
	// NFeatures is the number of features to select
	NFeatures int

	// Step is the number of features to remove at each iteration
	Step int
	// contains filtered or unexported fields
}

RFE (Recursive Feature Elimination) selects features by recursively removing the least important features. Uses correlation with target and mutual feature redundancy for importance scoring.

func NewRFE

func NewRFE(nFeatures int) *RFE

NewRFE creates a new RFE selector.

func (*RFE) Fit

func (r *RFE) Fit(df *dataframe.DataFrame, target ...string) error

Fit performs recursive feature elimination using correlation-based importance.

func (*RFE) FitTransform

func (r *RFE) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)

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

func (*RFE) GetSelectedFeatures

func (r *RFE) GetSelectedFeatures() []string

GetSelectedFeatures returns the list of selected feature names.

func (*RFE) IsFitted

func (r *RFE) IsFitted() bool

IsFitted returns true if the selector has been fitted.

func (*RFE) Transform

func (r *RFE) Transform(df *dataframe.DataFrame) (*dataframe.DataFrame, error)

Transform returns a DataFrame with selected features.

type SelectKBest

type SelectKBest struct {
	// K is the number of features to select
	K int
	// contains filtered or unexported fields
}

SelectKBest selects the K best features based on a scoring function. This is a simplified implementation using correlation with target.

func NewSelectKBest

func NewSelectKBest(k int) *SelectKBest

NewSelectKBest creates a new SelectKBest selector.

func (*SelectKBest) Fit

func (s *SelectKBest) Fit(df *dataframe.DataFrame, target ...string) error

Fit computes scores for each feature and selects top K.

func (*SelectKBest) FitTransform

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

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

func (*SelectKBest) GetScores

func (s *SelectKBest) GetScores() map[string]float64

GetScores returns the computed scores for each feature.

func (*SelectKBest) GetSelectedFeatures

func (s *SelectKBest) GetSelectedFeatures() []string

GetSelectedFeatures returns the list of selected feature names.

func (*SelectKBest) IsFitted

func (s *SelectKBest) IsFitted() bool

IsFitted returns true if the selector has been fitted.

func (*SelectKBest) Transform

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

Transform returns a DataFrame with only the K best features.

type SelectPercentile

type SelectPercentile struct {
	// Percentile (0-100) of features to keep
	Percentile float64
	// contains filtered or unexported fields
}

SelectPercentile selects features based on a percentile of the highest scores.

func NewSelectPercentile

func NewSelectPercentile(percentile float64) *SelectPercentile

NewSelectPercentile creates a new SelectPercentile selector.

func (*SelectPercentile) Fit

func (s *SelectPercentile) Fit(df *dataframe.DataFrame, target ...string) error

Fit computes scores and selects features above the percentile threshold.

func (*SelectPercentile) FitTransform

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

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

func (*SelectPercentile) GetSelectedFeatures

func (s *SelectPercentile) GetSelectedFeatures() []string

GetSelectedFeatures returns the list of selected feature names.

func (*SelectPercentile) IsFitted

func (s *SelectPercentile) IsFitted() bool

IsFitted returns true if the selector has been fitted.

func (*SelectPercentile) Transform

Transform returns a DataFrame with selected features.

type VarianceThreshold

type VarianceThreshold struct {
	// Threshold is the minimum variance required
	Threshold float64
	// contains filtered or unexported fields
}

VarianceThreshold removes features with variance below a threshold. Features with low variance are typically not useful for prediction.

func NewVarianceThreshold

func NewVarianceThreshold(threshold float64) *VarianceThreshold

NewVarianceThreshold creates a new VarianceThreshold selector.

func (*VarianceThreshold) Fit

func (v *VarianceThreshold) Fit(df *dataframe.DataFrame, _ ...string) error

Fit computes the variance for each numeric column and selects features.

func (*VarianceThreshold) FitTransform

func (v *VarianceThreshold) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)

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

func (*VarianceThreshold) GetSelectedFeatures

func (v *VarianceThreshold) GetSelectedFeatures() []string

GetSelectedFeatures returns the list of selected feature names.

func (*VarianceThreshold) IsFitted

func (v *VarianceThreshold) IsFitted() bool

IsFitted returns true if the selector has been fitted.

func (*VarianceThreshold) Transform

Transform returns a DataFrame with only the selected features.

Jump to

Keyboard shortcuts

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