Skip to content

AustynGriegoMSU/Not_So_Accurate_Weather_App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Not So Accurate Weather App

Flask web app that predicts local weather conditions from zipcode-based historical weather patterns.

The project combines geolocation lookup, historical weather retrieval, feature engineering, and pretrained neural network models to estimate:

  • daily high temperature (TMAX)
  • daily low temperature (TMIN)
  • precipitation (PRCP)
  • snowfall (SNOW)
  • average wind speed (AWND)

Overview

This project started as a machine learning weather forecasting experiment focused on Colorado. A user enters a US zipcode, the app resolves the location, gathers recent historical weather data for nearby stations, builds the same feature set used during training, and runs local models to generate a forecast.

To keep the app demoable without private credentials, the runtime supports multiple data paths:

  • NOAA + local ML model: preferred path using NOAA station history and local pretrained models
  • Open-Meteo historical + local ML model: no-token fallback that still predicts from historical weather patterns
  • Open-Meteo fallback: last-resort direct weather fallback when the historical/model path is unavailable

Tech Stack

  • Python
  • Flask
  • TensorFlow / Keras
  • pandas / NumPy / scikit-learn
  • NOAA CDO API
  • Zippopotam.us API
  • Open-Meteo API

Project Structure

.
├── weather_app.py          # root compatibility wrapper for the Flask app
├── src/
│   ├── app/
│   │   ├── main.py         # Flask app and inference pipeline
│   │   ├── __init__.py
│   │   └── templates/
│   │       └── index.html  # single-page UI
│   ├── training/
│   │   ├── model_training.py # training and model generation workflow
│   │   └── __init__.py
│   ├── tests/
│   │   └── test_app_main.py
│   └── models/
│       ├── scaler.pkl      # persisted feature scaler
│       ├── TMAX_model.pkl  # trained model artifact
│       ├── TMIN_model.pkl  # trained model artifact
│       ├── PRCP_model.pkl  # trained model artifact
│       ├── SNOW_model.pkl  # trained model artifact
│       └── AWND_model.pkl  # trained model artifact
├── requirements.txt        # Python dependencies
└── README.md

How It Works

  1. The user enters a US zipcode.
  2. The app resolves latitude and longitude with Zippopotam.us.
  3. The app collects weather history from NOAA when a token is available.
  4. If NOAA is unavailable, the app falls back to Open-Meteo archive history and still builds prediction features.
  5. The app applies the same transformations used during training, including interaction features and log1p scaling.
  6. The pretrained neural networks generate predictions for temperature, precipitation, snowfall, and wind.

Running Locally

Prerequisites

  • Python 3.12
  • pip

Installation

git clone https://github.com/AustynGriegoMSU/Not_So_Accurate_Weather_App.git
cd Not_So_Accurate_Weather_App
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

Optional NOAA Token

The app works without a NOAA token, but the preferred forecast path uses one.

export NOAA_API_TOKEN="your_token_here"

Start the App

python weather_app.py

Then open http://127.0.0.1:5000 in a browser.

The root app entrypoint is intentionally kept as a wrapper so existing commands still work after the folder reorganization.

Run Tests

python -m pytest -q

Continuous Integration

GitHub Actions is configured to run tests on pushes and pull requests to main. Workflow file: .github/workflows/ci.yml

Automatic Local Checks Before Commit

Install hooks once:

python -m pre_commit install

After this, tests run automatically before each commit.

Production-Style Run (Optional)

For local development, python weather_app.py is still the primary entrypoint. For a production-style WSGI run:

FLASK_DEBUG=0 gunicorn --bind 0.0.0.0:5000 src.app.main:app

You can also disable Flask debug mode for the standard entrypoint:

FLASK_DEBUG=0 python weather_app.py

Model Notes

  • The local models were trained on weather features engineered from historical observations.
  • Temperature, precipitation, snowfall, and wind inputs are transformed before inference.
  • Forecast quality is strongest in the region the model was originally tuned around, especially Colorado.

Known Limitations

  • Forecast accuracy is inconsistent outside the model's strongest geography.
  • Fallback historical sources do not perfectly match NOAA station features.
  • Prediction quality can vary by zipcode depending on station coverage and feature drift.
  • This is a project/demo app, not a production weather service.

What This Project Demonstrates

  • Building a small end-to-end ML application
  • Working with multiple external APIs
  • Data cleaning and feature engineering for inference
  • Serving local model artifacts through a Flask web interface
  • Improving reliability with fallback data paths and runtime validation

Future Improvements

  • Retrain models on broader and newer data
  • Add forecast confidence or error bands
  • Add charts showing the historical window used for prediction
  • Refactor training and inference code into reusable modules
  • Add tests for zipcode handling, feature construction, and fallback behavior

Credits

  • NOAA CDO API
  • Zippopotam.us
  • Open-Meteo
  • Heroku (Originally deployed)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors