A modern web application for avalanche risk prediction using machine learning models. This project analyzes weather data to predict avalanche danger levels using multiple ML algorithms.
- Interactive Dashboard: Modern, responsive web interface built with Flask and Bootstrap
- Multiple ML Models:
- Neural Network (MLP Classifier)
- Logistic Regression
- Hierarchical Agglomerative Clustering (HAC)
- Data Visualization:
- Interactive charts using Plotly
- Geographic mapping with Leaflet
- Weather statistics and correlation matrices
- Real-time Prediction: Input weather conditions and get instant avalanche risk predictions
- Data Exploration: Comprehensive analysis of historical avalanche and weather data
- Python 3.8 or higher
- uv package manager
-
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | shOr on Windows:
pip install uv
-
Clone or navigate to the project directory:
cd avalanche-forcast -
Install dependencies and run the application:
uv sync uv run python app.py
Or use the convenient startup script:
./start.sh # Linux/Mac start.bat # Windows
-
Open your browser and navigate to:
http://localhost:5000
- Push your code to GitHub
- Go to railway.app
- Connect your GitHub repo
- Railway auto-deploys your Docker app!
- Get a live URL like:
https://avalanche-forcast-production.up.railway.app
- Push your code to GitHub
- Go to render.com
- Connect your GitHub repo
- Select "Docker" environment
- Deploy with one click!
# Quick deployment
./deploy.sh
# Manual Docker deployment
docker-compose up --build -d# Install dependencies
pip install -r requirements.txt
# Start with Gunicorn (production WSGI server)
gunicorn --bind 0.0.0.0:5000 --workers 4 wsgi:appThe application uses the following weather features for prediction:
maxtempC: Maximum temperature in CelsiusmintempC: Minimum temperature in CelsiustotalSnow_cm: Total snowfall in centimeterstempC: Current temperature in CelsiuswindspeedKmph: Wind speed in km/hwinddirDegree: Wind direction in degreesprecipMM: Precipitation in millimetershumidity: Humidity percentage
- Multi-layer perceptron classifier
- Hidden layers: 64, 32 neurons
- Uses early stopping and validation
- Provides probability scores
- Linear classification model
- Fast training and prediction
- Good baseline model
- Provides probability scores
- Unsupervised clustering approach
- Groups similar weather patterns
- Binary classification (safe/dangerous)
- Navigate to the dashboard at
http://localhost:5000 - Enter weather conditions in the prediction form:
- Temperature ranges (min/max/current)
- Snow accumulation
- Wind conditions
- Precipitation and humidity
- Select a model from the dropdown
- Click "Predict Risk" to get results
- View the prediction with confidence scores
- Statistics Overview: View total records, dangerous events, and locations
- Weather Charts: Analyze weather feature distributions
- Correlation Matrix: Understand feature relationships
- Interactive Map: Explore avalanche locations geographically
avalanche-forcast/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ templates/
β βββ index.html # Main dashboard template
βββ data/ # Data files and model outputs
βββ process/ # Original ML model scripts
βββ preprocess/ # Data preprocessing scripts
βββ scraper/ # Data collection scripts
βββ README.md # This file
GET /api/data- Get dataset statisticsGET /api/locations- Get location data for mappingGET /api/weather_stats- Get weather feature statisticsGET /api/correlation- Get feature correlation matrixPOST /api/predict- Make avalanche risk prediction
The models are trained on historical avalanche data with the following features:
- Weather conditions (temperature, wind, precipitation)
- Snow accumulation data
- Geographic location information
- Historical avalanche occurrence records
uv sync- Install dependencies from pyproject.tomluv run python app.py- Run the applicationuv add <package>- Add a new dependencyuv remove <package>- Remove a dependencyuv lock- Generate/update the lock file
- New ML Models: Add to the
AvalanchePredictorclass inapp.py - Visualizations: Extend the JavaScript functions in
index.html - API Endpoints: Add new routes to the Flask app
To update the dataset with new avalanche records:
-
Run the improved scraper to get latest avalanche data:
cd scraper uv run python scraper_improved.py -
Merge new avalanche data with existing coordinates:
uv run python merge_new_data.py avalanches_scraped_YYYYMMDD_HHMMSS.csv ../avalanches_lat_long.csv avalanches_enhanced.csv
To fetch historical weather data for new avalanche records:
-
Set up OpenWeatherMap API key:
cd scraper uv run python setup_api.pyOr manually set the environment variable:
export OPENWEATHER_API_KEY='your_api_key_here'
-
Fetch weather data:
uv run python update_weather_data.py
-
Restart the application to use the updated dataset:
uv run python app.py
To manually update the dataset:
- Replace
allData.csvwith new data - Ensure the same column structure
- Restart the application to retrain models
This webapp is built on top of the original avalanche forecasting project that included:
- Weather data scraping and preprocessing
- Multiple ML model implementations
- Feature selection and optimization
- Model performance analysis
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
This tool is for educational and research purposes only. Always consult with professional avalanche forecasters and local authorities before making safety decisions in avalanche terrain.
Built with β€οΈ using Flask, scikit-learn, and modern web technologies