How mouse234/ml works
Project Type and Purpose
This is a standalone machine‐learning pipeline for time‐series forecasting of gold prices based on astronomical (planetary degree) and temporal features. It is neither a web app nor microservice landscape but a structured ETL + training + prediction workflow with both batch preprocessing and interactive analysis components.
High‐Level Components
a. Data Ingestion & Storage
• Raw CSV data (Gold_Inr.csv)
• Persisted pickles: X_train.pkl, X_test.pkl, y_train.pkl, y_test.pkl, test_dates.pkl
b. Preprocessing & Feature Engineering
• Script: prepare_data.py
• Operations: temporal feature extraction, cyclical encoding, planetary aspect computation, chronological train/test split, StandardScaler fit/transform
• Persisted artifacts: scaler.pkl, feature_columns.json, X_train_scaled.pkl, X_test_scaled.pkl
c. Model Training & Evaluation
• Script: train_models.py
• Models: Linear Regression, Random Forest, XGBoost
• Validation: TimeSeriesSplit via GridSearchCV
• Outputs: best_gold_price_model.joblib, all_models.joblib, model_results.json, timeseries_cv_results.json
d. Prediction Interface
• Script: predict_gold_price.py
• Loads: best model, scaler, feature spec
• Input: command‐line args for date + deg0–deg12
• Output: formatted predicted price
e. Interactive Analysis
• Notebook: gold_price_analysis.ipynb
• Exploratory plots, feature importance, CV visualizations
Relationships & Data Flow
Raw CSV → prepare_data.py →
• temporal + aspect features → scale → pickle artifacts →
train_models.py consumes scaled train/test →
• hyperparameter tuning → final models + metrics JSON →
gold_price_analysis.ipynb reads artifacts + results for EDA →
predict_gold_price.py reads scaler + best model + feature spec for on‐demand inference
Architectural Patterns & Principles
• ETL Pipeline: clear separation of ingestion, transformation, persistence
• Batch Training: scripts driven by chronological, reproducible splits
• Modular Artifacts: pickle and JSON files describe intermediate state for reuse
• Single Responsibility: each script does one job (prepare, train, predict)
• Time‐Series Aware: no random splits; use TimeSeriesSplit
Essential Elements
• Clear component names matching file names
• Annotations for key design principles (e.g., “chronological split,” “GridSearchCV,” “StandardScaler”)