A robust C library for time series forecasting and analysis, designed for resource planning and demand prediction in high-performance environments.
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.
-
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
git clone https://github.com/vijaybartaula/c-timeforge.git
cd c-timeforge
make#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;
}typedef struct {
double *data;
int length;
char *date_format;
} TimeSeries;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;TimeSeries* init_time_series(int length)void free_time_series(TimeSeries* ts)TimeSeries* load_from_csv(const char* filename, int column_index)
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)
double calculate_mae(TimeSeries* actual, TimeSeries* forecast)double calculate_rmse(TimeSeries* actual, TimeSeries* forecast)
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
- Server load prediction
- Network traffic analysis
- Sales forecasting
- Resource allocation
- Capacity planning
- Anomaly detection
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Box-Jenkins methodology
- Forecasting: Principles and Practice by Rob J Hyndman and George Athanasopoulos