Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/dronabopche/100-ML-AI-Project/llms.txt

Use this file to discover all available pages before exploring further.

Time series forecasting trains models on ordered, timestamped observations to predict future values. Unlike static tabular learning, these models must capture temporal dependencies—trends, seasonality, and autocorrelation—across sequences that can span seconds, days, or years. The projects in this section span financial markets, meteorology, and safety-critical healthcare, demonstrating how sequence models like LSTM and statistical methods like ARIMA apply across domains with very different data characteristics and latency requirements.
Objective: Predict the directional trend of a stock (up, down, or flat) over a future window using historical price and volume data.Algorithm / Model: Long Short-Term Memory (LSTM) recurrent neural network. LSTMs are well-suited to financial time series because their gating mechanism allows the model to selectively remember or forget long-range dependencies in price sequences.Dataset and Features:
  • Historical OHLCV data (Open, High, Low, Close, Volume) sourced from platforms such as Yahoo Finance or Kaggle financial datasets
  • Derived technical indicators: moving averages (SMA, EMA), RSI, MACD, Bollinger Bands
  • Sequences are windowed into fixed-length lookback periods (e.g., 60 trading days) fed as input to the LSTM
How to Run:
cd 70_Stock_Trend_Predictor
pip install -r requirements.txt
python SRC/App.py
Objective: Forecast daily or hourly temperature values for a location given recent meteorological observations.Algorithm / Model: ARIMA (AutoRegressive Integrated Moving Average) for baseline statistical forecasting, with an LSTM variant for capturing non-linear seasonal patterns. ARIMA is effective when the series is stationary after differencing; LSTM takes over when complex non-linearities or multi-variate inputs are needed.Dataset and Features:
  • Historical weather records including temperature, humidity, dew point, wind speed, and precipitation
  • Data sourced from open meteorological repositories (e.g., NOAA, Open-Meteo, or Kaggle weather datasets)
  • Features are normalized and missing values are interpolated before feeding into the model
How to Run:
cd 72_Weather_Temp_Forecast
pip install -r requirements.txt
python SRC/App.py
Objective: Stream patient vitals every second from a smart ambulance, detect anomalies early, and produce a triage risk score with confidence—exposed via a REST API.Algorithm / Model: Windowed time-series anomaly detection model (e.g., Isolation Forest or LSTM autoencoder) trained on synthetic patient vitals. Artifact detection is applied as an explicit pre-processing step before anomaly scoring.Dataset and Features:
  • Synthetic time-series (~30 minutes per patient at 1 Hz) covering: Heart Rate (HR), SpO₂, Blood Pressure (systolic/diastolic), and Motion/Vibration
  • Scenarios include normal transport, patient deterioration, and sensor noise artifacts (motion-induced SpO₂ drops, HR spikes from road vibration, signal dropouts)
  • Features are extracted in sliding windows; the pipeline applies artifact correction before inference
How to Run:
cd 71_Smart_Ambulance_RapidResponse
pip install -r requirements.txt

# Train the anomaly model
python -m src.training.train

# Start the FastAPI service
python -m src.api.main
Example API call:
curl -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json" \
  -d '{"timestamp": 1700000000, "hr": 92, "spo2": 97, "bp_sys": 120, "bp_dia": 78, "motion": 0.12}'
Example response:
{
  "anomaly": false,
  "risk_score": 0.18,
  "confidence": 0.82
}

Typical LSTM time series setup

The following snippet shows a minimal but complete LSTM forecasting pipeline in PyTorch. It covers sequence windowing, model definition, and the training loop—the same pattern used by the Stock Trend Predictor and the Weather Forecast projects.
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, TensorDataset

# --- 1. Windowing ---
def create_sequences(data: np.ndarray, lookback: int = 60):
    """Slide a window of length `lookback` over 1-D time series data."""
    X, y = [], []
    for i in range(len(data) - lookback):
        X.append(data[i : i + lookback])
        y.append(data[i + lookback])
    return np.array(X), np.array(y)

# Assume `series` is a normalised numpy array of shape (T,)
series = np.sin(np.linspace(0, 20 * np.pi, 2000))  # placeholder
X, y = create_sequences(series, lookback=60)

X_t = torch.tensor(X, dtype=torch.float32).unsqueeze(-1)  # (N, 60, 1)
y_t = torch.tensor(y, dtype=torch.float32).unsqueeze(-1)  # (N, 1)

loader = DataLoader(TensorDataset(X_t, y_t), batch_size=64, shuffle=True)

# --- 2. Model ---
class LSTMForecaster(nn.Module):
    def __init__(self, input_size=1, hidden_size=64, num_layers=2):
        super().__init__()
        self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True)
        self.fc   = nn.Linear(hidden_size, 1)

    def forward(self, x):
        out, _ = self.lstm(x)
        return self.fc(out[:, -1, :])  # use last timestep

model    = LSTMForecaster()
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
criterion = nn.MSELoss()

# --- 3. Training loop ---
for epoch in range(20):
    model.train()
    total_loss = 0.0
    for xb, yb in loader:
        optimizer.zero_grad()
        loss = criterion(model(xb), yb)
        loss.backward()
        optimizer.step()
        total_loss += loss.item()
    print(f"Epoch {epoch+1:02d} | loss: {total_loss / len(loader):.4f}")

# --- 4. Inference ---
model.eval()
with torch.no_grad():
    sample = X_t[:1]          # shape (1, 60, 1)
    pred   = model(sample)
    print(f"Next-step prediction: {pred.item():.4f}")

Project comparison

ProjectDomainModelInput FeaturesPrediction Target
70 – Stock Trend PredictorFinanceLSTMOHLCV + technical indicatorsPrice trend direction
72 – Weather Temp ForecastMeteorologyARIMA / LSTMTemperature, humidity, windFuture temperature
71 – Smart AmbulanceHealthcare / IoTAnomaly detection (windowed)HR, SpO₂, BP, motionAnomaly flag + risk score
Time series models require sufficient historical data to learn meaningful patterns. As a rule of thumb, aim for at least several hundred timesteps per seasonal cycle before training. Always handle missing values explicitly—common strategies include forward-fill for short gaps, interpolation for smoother signals, and dropping or masking longer outages. For safety-critical applications like Project 71, explicitly detect and correct sensor artifacts before feeding data to the anomaly model; otherwise, motion noise will dominate the signal and inflate the false-alert rate.

Build docs developers (and LLMs) love