scigo

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: MIT

README ยถ

SciGo ๐Ÿš€

SciGo Mascot Gopher

SciGo's official mascot - Ready, Set, SciGo!

The blazing-fast scikit-learn compatible ML library for Go

Say "Goodbye" to slow ML, "Sci-Go" to fast learning!

CI Go Report Card Go Version GoDoc


๐ŸŒŸ Why SciGo?

SciGo = Statistical Computing In Go

SciGo brings the power and familiarity of scikit-learn to the Go ecosystem, offering:

  • ๐Ÿ”ฅ Blazing Fast: Native Go implementation with built-in parallelization
  • ๐ŸŽฏ scikit-learn Compatible: Familiar Fit/Predict API for easy migration
  • ๐Ÿ“– Well Documented: Complete API documentation with examples on pkg.go.dev
  • ๐ŸŒŠ Streaming Support: Online learning algorithms for real-time data
  • ๐Ÿš€ Zero Heavy Dependencies: Pure Go implementation (only scientific essentials)
  • ๐Ÿ“Š Comprehensive: Regression, classification, clustering, and more
  • ๐Ÿงช Production Ready: Extensive tests, benchmarks, and error handling

๐Ÿ“ฆ Installation

go get github.com/YuminosukeSato/scigo

๐Ÿš€ Quick Start

๐Ÿ’ก Tip: For complete API documentation with examples, visit pkg.go.dev/scigo

package main

import (
    "fmt"
    "log"
    
    "github.com/YuminosukeSato/scigo/linear"
    "gonum.org/v1/gonum/mat"
)

func main() {
    // Create and train model - just like scikit-learn!
    model := linear.NewLinearRegression()
    
    // Training data
    X := mat.NewDense(4, 2, []float64{
        1, 1,
        1, 2,
        2, 2,
        2, 3,
    })
    y := mat.NewDense(4, 1, []float64{
        2, 3, 3, 4,
    })
    
    // Fit the model
    if err := model.Fit(X, y); err != nil {
        log.Fatal(err)
    }
    
    // Make predictions
    XTest := mat.NewDense(2, 2, []float64{
        1.5, 1.5,
        2.5, 3.5,
    })
    predictions, _ := model.Predict(XTest)
    
    fmt.Println("Ready, Set, SciGo! Predictions:", predictions)
}

๐Ÿ“š API Documentation

GoDoc

๐Ÿ“– Package Documentation
Package Description Go Doc
preprocessing Data preprocessing utilities (StandardScaler, MinMaxScaler, OneHotEncoder) GoDoc
linear Linear machine learning algorithms (LinearRegression) GoDoc
metrics Model evaluation metrics (MSE, RMSE, MAE, Rยฒ, MAPE) GoDoc
core/model Base model abstractions and interfaces GoDoc
๐Ÿ“‹ Complete API Examples

The documentation includes comprehensive examples for all major APIs. Visit the Go Doc links above or use go doc locally:

# View package documentation
go doc github.com/YuminosukeSato/scigo/preprocessing
go doc github.com/YuminosukeSato/scigo/linear
go doc github.com/YuminosukeSato/scigo/metrics

# View specific function documentation
go doc github.com/YuminosukeSato/scigo/preprocessing.StandardScaler.Fit
go doc github.com/YuminosukeSato/scigo/linear.LinearRegression.Predict
go doc github.com/YuminosukeSato/scigo/metrics.MSE

# Run example tests
go test -v ./preprocessing -run Example
go test -v ./linear -run Example
go test -v ./metrics -run Example

๐Ÿ“š Algorithms

Supervised Learning
Linear Models
  • โœ… Linear Regression - Classic OLS regression with parallel processing
  • โœ… SGD Regressor - Stochastic Gradient Descent for large-scale learning
  • โœ… SGD Classifier - Linear classifiers with SGD training
  • โœ… Passive-Aggressive - Online learning for classification and regression
Data Preprocessing
  • โœ… StandardScaler - Standardizes features by removing mean and scaling to unit variance
  • โœ… MinMaxScaler - Scales features to a given range (e.g., [0,1] or [-1,1])
  • โœ… OneHotEncoder - Encodes categorical features as one-hot numeric arrays
Tree-based Models
  • ๐Ÿšง Random Forest (Coming Soon)
  • ๐Ÿšง Gradient Boosting (Coming Soon)
  • ๐Ÿšง XGBoost compatibility (Coming Soon)
Unsupervised Learning
Clustering
  • โœ… MiniBatch K-Means - Scalable K-Means for large datasets
  • ๐Ÿšง DBSCAN (Coming Soon)
  • ๐Ÿšง Hierarchical Clustering (Coming Soon)
Special Features
Online Learning & Streaming
  • โœ… Incremental Learning - Update models with new data batches
  • โœ… Partial Fit - scikit-learn compatible online learning
  • โœ… Concept Drift Detection - DDM and ADWIN algorithms
  • โœ… Streaming Pipelines - Real-time data processing with channels

๐ŸŽฏ scikit-learn Compatibility

SciGo implements the familiar scikit-learn API:

// Just like scikit-learn!
model.Fit(X, y)              // Train the model
model.Predict(X)              // Make predictions  
model.Score(X, y)             // Evaluate the model
model.PartialFit(X, y)        // Incremental learning

// Streaming - unique to Go!
model.FitStream(ctx, dataChan) // Streaming training

๐Ÿ“Š Performance Benchmarks

SciGo leverages Go's concurrency for exceptional performance:

Algorithm Dataset Size SciGo scikit-learn (Python) Speedup
Linear Regression 1Mร—100 245ms 890ms 3.6ร—
SGD Classifier 500Kร—50 180ms 520ms 2.9ร—
MiniBatch K-Means 100Kร—20 95ms 310ms 3.3ร—
Streaming SGD 1M streaming 320ms 1.2s 3.8ร—

Benchmarks on MacBook Pro M2, 16GB RAM

Memory Efficiency
Dataset Size Memory Allocations
100ร—10 22.8KB 22
1,000ร—10 191.8KB 22
10,000ร—20 3.4MB 57
50,000ร—50 41.2MB 61

๐Ÿ—๏ธ Architecture

scigo/
โ”œโ”€โ”€ linear/           # Linear models
โ”œโ”€โ”€ sklearn/          # scikit-learn compatible implementations
โ”‚   โ”œโ”€โ”€ linear_model/ # SGD, Passive-Aggressive
โ”‚   โ”œโ”€โ”€ cluster/      # Clustering algorithms
โ”‚   โ””โ”€โ”€ drift/        # Concept drift detection
โ”œโ”€โ”€ metrics/          # Evaluation metrics
โ”œโ”€โ”€ core/            # Core abstractions
โ”‚   โ”œโ”€โ”€ model/       # Base model interfaces
โ”‚   โ”œโ”€โ”€ tensor/      # Tensor operations
โ”‚   โ””โ”€โ”€ parallel/    # Parallel processing
โ”œโ”€โ”€ datasets/        # Dataset utilities
โ””โ”€โ”€ examples/        # Usage examples

๐Ÿ“Š Metrics

Comprehensive evaluation metrics with full documentation:

๐Ÿงช Testing & Quality

# Run tests
go test ./...

# Run benchmarks
go test -bench=. -benchmem ./...

# Check coverage (76.7% overall coverage)
go test -cover ./...

# Run linter (errcheck, govet, ineffassign, staticcheck, unused, misspell)
make lint-full

# Run examples to see API usage
go test -v ./preprocessing -run Example
go test -v ./linear -run Example
go test -v ./metrics -run Example
go test -v ./core/model -run Example
Quality Gates
  • โœ… Test Coverage: 76.7% (target: 70%+)
  • โœ… Linting: golangci-lint with comprehensive checks
  • โœ… Documentation: Complete godoc for all public APIs
  • โœ… Examples: Comprehensive example functions for all major APIs

๐Ÿ“š Examples

Check out the examples directory:

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide.

Development Setup
# Clone the repository
git clone https://github.com/YuminosukeSato/scigo.git
cd scigo

# Install dependencies
go mod download

# Run tests
go test ./...

# Run linter
golangci-lint run

๐Ÿ—บ๏ธ Roadmap

Phase 1: Core ML (Current)
  • โœ… Linear models
  • โœ… Online learning
  • โœ… Basic clustering
  • ๐Ÿšง Tree-based models
Phase 2: Advanced Features
  • Neural Networks (MLP)
  • Deep Learning integration
  • Model serialization (ONNX export)
  • GPU acceleration
Phase 3: Enterprise Features
  • Distributed training
  • AutoML capabilities
  • Model versioning
  • A/B testing framework

๐Ÿ“– Documentation

Core Documentation
API Quick Reference
API Package Documentation
StandardScaler preprocessing pkg.go.dev/preprocessing.StandardScaler
MinMaxScaler preprocessing pkg.go.dev/preprocessing.MinMaxScaler
OneHotEncoder preprocessing pkg.go.dev/preprocessing.OneHotEncoder
LinearRegression linear pkg.go.dev/linear.LinearRegression
BaseEstimator core/model pkg.go.dev/model.BaseEstimator
Guides (Coming Soon)

๐Ÿ™ Acknowledgments

๐Ÿ“„ License

SciGo is licensed under the MIT License. See LICENSE for details.

๐Ÿ“ง Contact


๐Ÿš€ Ready, Set, SciGo! ๐Ÿš€

Where Science Meets Go - Say goodbye to slow ML!

Made with โค๏ธ and lots of โ˜• in Go

Directories ยถ

Path Synopsis
benchmarks
streaming command
core
model
Package model provides core abstractions and interfaces for machine learning models.
Package model provides core abstractions and interfaces for machine learning models.
examples
error_demo command
iris_regression command
streaming_demo command
Package linear provides linear machine learning algorithms and models.
Package linear provides linear machine learning algorithms and models.
Package metrics provides evaluation metrics for machine learning models.
Package metrics provides evaluation metrics for machine learning models.
pkg
errors
Package errors ใฏใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆๅ…จไฝ“ใฎใ‚จใƒฉใƒผใƒใƒณใƒ‰ใƒชใƒณใ‚ฐใจ่ญฆๅ‘Šใ‚ทใ‚นใƒ†ใƒ ใ‚’ๆไพ›ใ—ใพใ™ใ€‚
Package errors ใฏใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆๅ…จไฝ“ใฎใ‚จใƒฉใƒผใƒใƒณใƒ‰ใƒชใƒณใ‚ฐใจ่ญฆๅ‘Šใ‚ทใ‚นใƒ†ใƒ ใ‚’ๆไพ›ใ—ใพใ™ใ€‚
log
Package preprocessing provides data preprocessing utilities for machine learning.
Package preprocessing provides data preprocessing utilities for machine learning.
sklearn
lightgbm
Package lightgbm provides a pure Go implementation of LightGBM model inference with full compatibility for models trained in Python's LightGBM library.
Package lightgbm provides a pure Go implementation of LightGBM model inference with full compatibility for models trained in Python's LightGBM library.
pipeline
Package pipeline implements scikit-learn compatible Pipeline for chaining transformers and estimators.
Package pipeline implements scikit-learn compatible Pipeline for chaining transformers and estimators.

Jump to

Keyboard shortcuts

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