Skip to content

vijaybartaula/c-timeforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

C-TimeForge

A robust C library for time series forecasting and analysis, designed for resource planning and demand prediction in high-performance environments.

Build Status Version License

Overview

C-TimeForge provides efficient implementations of various time series forecasting algorithms in pure C. It's designed for applications where performance matters, such as server load prediction, capacity planning, network traffic analysis, and sales forecasting.

Features

  • Multiple Forecasting Methods:

    • Simple Moving Average (SMA)
    • Exponential Smoothing (ETS)
    • Double Exponential Smoothing (Holt's method)
    • Triple Exponential Smoothing (Holt-Winters method)
  • Utilities:

    • CSV data import/export
    • Forecasting future values
    • Error metrics calculation (MAE, RMSE)
    • Memory-efficient data structures
  • Performance Optimized:

    • Minimal dependencies (only standard C libraries)
    • Low memory footprint
    • Suitable for embedded systems and high-performance applications

Installation

git clone https://github.com/vijaybartaula/c-timeforge.git
cd c-timeforge
make

Usage Example

#include "timeforge.h"

int main() {
    // Create or load a time series
    TimeSeries* server_load = load_from_csv("server_metrics.csv", 2);
    
    // Apply forecasting algorithm
    TimeSeries* forecast = forecast_future(server_load, 0.3, 0.1, 24);
    
    // Calculate accuracy metrics
    double mae = calculate_mae(server_load, forecast);
    printf("Mean Absolute Error: %.2f\n", mae);
    
    // Export results
    export_to_csv(forecast, "forecast_results.csv");
    
    // Clean up
    free_time_series(server_load);
    free_time_series(forecast);
    
    return 0;
}

API Documentation

Core Data Structures

TimeSeries

typedef struct {
    double *data;
    int length;
    char *date_format;
} TimeSeries;

ExponentialSmoothingParams

typedef struct {
    double alpha;       // Smoothing factor for level
    double beta;        // Smoothing factor for trend
    double gamma;       // Smoothing factor for seasonality
    int season_length;  // Length of seasonality period
} ExponentialSmoothingParams;

Key Functions

Time Series Creation and Management

  • TimeSeries* init_time_series(int length)
  • void free_time_series(TimeSeries* ts)
  • TimeSeries* load_from_csv(const char* filename, int column_index)

Forecasting Methods

  • TimeSeries* moving_average(TimeSeries* ts, int window_size)
  • TimeSeries* exponential_smoothing(TimeSeries* ts, double alpha)
  • TimeSeries* double_exponential_smoothing(TimeSeries* ts, double alpha, double beta)
  • TimeSeries* triple_exponential_smoothing(TimeSeries* ts, ExponentialSmoothingParams params)
  • TimeSeries* forecast_future(TimeSeries* ts, double alpha, double beta, int forecast_horizon)

Evaluation Metrics

  • double calculate_mae(TimeSeries* actual, TimeSeries* forecast)
  • double calculate_rmse(TimeSeries* actual, TimeSeries* forecast)

Performance Considerations

C-TimeForge is designed for efficiency, with the following benchmarks on a standard system:

  • Processing 1 million data points: < 1 second
  • Memory usage for 1 million points: ~8MB
  • Forecasting 10,000 future points: < 100ms

Applications

  • Server load prediction
  • Network traffic analysis
  • Sales forecasting
  • Resource allocation
  • Capacity planning
  • Anomaly detection

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Acknowledgments

  • Box-Jenkins methodology
  • Forecasting: Principles and Practice by Rob J Hyndman and George Athanasopoulos

About

A robust C library for time series forecasting and analysis.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages