Documentation
¶
Overview ¶
Package features provides sklearn-style feature engineering transformers and pipelines.
Index ¶
- func BaseFitTransform(est Estimator, df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)
- type Estimator
- type Fittable
- type Pipeline
- func (p *Pipeline) Add(name string, estimator Estimator) *Pipeline
- func (p *Pipeline) Fit(df *dataframe.DataFrame, target ...string) error
- func (p *Pipeline) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)
- func (p *Pipeline) GetStep(index int) *PipelineStep
- func (p *Pipeline) GetStepByName(name string) *PipelineStep
- func (p *Pipeline) IsFitted() bool
- func (p *Pipeline) Len() int
- func (p *Pipeline) Save(path string) error
- func (p *Pipeline) SaveMetadata(path string) error
- func (p *Pipeline) Steps() []PipelineStep
- func (p *Pipeline) Transform(df *dataframe.DataFrame) (*dataframe.DataFrame, error)
- type PipelineMetadata
- type PipelineStep
- type SerializedPipeline
- type SerializedStep
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Estimator ¶
type Estimator interface {
// Fit learns parameters from the training data.
// The target parameter is optional and used by supervised transformers (e.g., TargetEncoder).
Fit(df *dataframe.DataFrame, target ...string) error
// Transform applies the learned transformation to the data.
// Returns a new DataFrame with the transformation applied.
Transform(df *dataframe.DataFrame) (*dataframe.DataFrame, error)
}
Estimator learns from data and transforms it. This follows the sklearn fit/transform pattern.
type Fittable ¶
type Fittable interface {
// IsFitted returns true if the estimator has been fitted.
IsFitted() bool
}
Fittable indicates whether an estimator has been fitted.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline chains multiple transformers in sequence. Each step is fitted and applied in order.
func LoadPipeline ¶
LoadPipeline loads a pipeline from a JSON file.
func (*Pipeline) Add ¶
Add appends a transformer to the pipeline. Returns the pipeline for method chaining.
func (*Pipeline) Fit ¶
Fit trains all transformers in the pipeline. Each transformer is fitted on the output of the previous transformer.
func (*Pipeline) FitTransform ¶
func (p *Pipeline) FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)
FitTransform fits the pipeline and transforms the data in one operation.
func (*Pipeline) GetStep ¶
func (p *Pipeline) GetStep(index int) *PipelineStep
GetStep returns the step at the given index. Returns nil if the index is out of bounds.
func (*Pipeline) GetStepByName ¶
func (p *Pipeline) GetStepByName(name string) *PipelineStep
GetStepByName returns the first step with the given name. Returns nil if no step with that name exists.
func (*Pipeline) SaveMetadata ¶
SaveMetadata saves only the pipeline metadata (useful for inspection).
func (*Pipeline) Steps ¶
func (p *Pipeline) Steps() []PipelineStep
Steps returns a copy of the pipeline steps.
type PipelineMetadata ¶
type PipelineMetadata struct {
Version string `json:"version"`
CreatedAt time.Time `json:"created_at"`
GopherDataVersion string `json:"gopherdata_version"`
}
PipelineMetadata contains metadata about a saved pipeline.
type PipelineStep ¶
type PipelineStep struct {
Name string
Estimator Estimator
// contains filtered or unexported fields
}
PipelineStep represents a single transformation step in a pipeline.
type SerializedPipeline ¶
type SerializedPipeline struct {
Metadata PipelineMetadata `json:"metadata"`
Steps []SerializedStep `json:"steps"`
}
SerializedPipeline represents a complete pipeline in JSON format.
type SerializedStep ¶
type SerializedStep struct {
Name string `json:"name"`
Type string `json:"type"`
Params map[string]any `json:"params"`
Fitted bool `json:"fitted"`
State map[string]any `json:"state,omitempty"`
}
SerializedStep represents a pipeline step in JSON format.
type Transformer ¶
type Transformer interface {
Estimator
// FitTransform fits the estimator and transforms the data in one step.
// This is often more efficient than calling Fit and Transform separately.
FitTransform(df *dataframe.DataFrame, target ...string) (*dataframe.DataFrame, error)
}
Transformer combines Fit and Transform operations. Most estimators implement this interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package creators provides feature creation transformers.
|
Package creators provides feature creation transformers. |
|
Package encoders provides categorical encoding transformers.
|
Package encoders provides categorical encoding transformers. |
|
Package imputers provides missing value imputation transformers.
|
Package imputers provides missing value imputation transformers. |
|
Package scalers provides data normalization and standardization transformers.
|
Package scalers provides data normalization and standardization transformers. |
|
Package selectors provides feature selection transformers.
|
Package selectors provides feature selection transformers. |