naitik991 commited on
Commit
6c9098d
·
verified ·
1 Parent(s): 27c61cf

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +21 -0
  2. app.py +33 -0
  3. baseline_heavy_metals_multi.csv +10 -0
  4. geo_metals_model.joblib +3 -0
  5. model.py +15 -0
README.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: GeoMetals App
3
+ emoji: 🌍
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: streamlit
7
+ sdk_version: "1.30.0"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # GeoMetals App
13
+
14
+ This app uses a trained Gradient Boosting regression model to estimate heavy metal contamination in soil based on geolocation.
15
+
16
+ ### Features:
17
+ - Interactive map for geospatial input
18
+ - Predicts Fe, Cr, Mn, Mo, In, Ta in ppm
19
+ - Warns if values exceed EPA thresholds
20
+
21
+ Trained on SEM-EDS environmental sampling data from Arizona.
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ import folium
4
+ from streamlit_folium import st_folium
5
+ from model import predict_metals
6
+
7
+ st.set_page_config(page_title="GeoMetals Predictor", layout="wide")
8
+
9
+ st.title("Heavy Metal Concentration Estimator 🌎")
10
+ st.markdown("Click on the map to select a location. The app will predict heavy metal concentrations based on geolocation and trained SEM-EDS data.")
11
+
12
+ with st.expander("How it works"):
13
+ st.markdown("""
14
+ This app predicts concentrations of heavy metals in ppm (parts per million) using a trained Gradient Boosting model.
15
+ It accounts for location-based proximity to industrial zones and was trained on SEM-EDS data from Arizona.
16
+ """)
17
+
18
+ default_coords = [33.4484, -112.0740] # Phoenix center
19
+
20
+ m = folium.Map(location=default_coords, zoom_start=10)
21
+ click = st_folium(m, height=500, width=700)
22
+
23
+ if click and click["last_clicked"]:
24
+ lat, lon = click["last_clicked"]["lat"], click["last_clicked"]["lng"]
25
+ st.success(f"Selected Location: Latitude {lat:.4f}, Longitude {lon:.4f}")
26
+
27
+ prediction = predict_metals(lat, lon)
28
+ st.subheader("Predicted Heavy Metal Concentrations (ppm):")
29
+ for metal, val in prediction.items():
30
+ warning = ""
31
+ if (metal == "Fe_ppm" and val > 300) or (metal == "Cr_ppm" and val > 100) or (metal == "Mn_ppm" and val > 200) or (metal == "Mo_ppm" and val > 10) or (metal == "In_ppm" and val > 1) or (metal == "Ta_ppm" and val > 0.5):
32
+ warning = "⚠️ Above EPA Threshold"
33
+ st.markdown(f"**{metal}**: {val:.2f} ppm {warning}")
baseline_heavy_metals_multi.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ lat,lon,Fe,Cr,Mn,Mo,In,Ta
2
+ 33.3,-112.3,27415.86769483495,51.3699669529441,373.942541888569,1.5349232940362272,0.053601690021355154,0.006718599374013687
3
+ 33.3,-112.1,26299.1057740642,44.48211950049188,406.6022298641086,0.9348349532298319,0.059686284846273446,0.005645732788723248
4
+ 33.3,-111.9,26818.234649837654,44.2797535086274,403.8412320567538,1.3555984952160824,0.03851945093844259,0.004397743797117824
5
+ 33.5,-112.3,22271.049325705106,49.57302757797042,334.7535249204071,2.109642757787766,0.03235873100699918,0.006499888675675197
6
+ 33.5,-112.1,23637.91893464434,47.805165337355305,377.42659899019395,2.002124447817415,0.05043702668084274,0.006073682012098753
7
+ 33.5,-111.9,25114.072059844577,46.76479987769451,418.4831996205925,1.3413828043500886,0.037197088717647445,0.003698396674258
8
+ 33.7,-112.3,25076.263853704233,42.5567995730596,335.6242972045018,1.6538823752374487,0.03781510358713415,0.003839674974730694
9
+ 33.7,-112.1,24937.560948569615,40.49942170963043,403.67516495018555,2.0920382674807674,0.046209423538176794,0.003940420853783351
10
+ 33.7,-111.9,25272.260466440966,41.12384103166156,400.7125444599324,1.5946907930043717,0.04964803061537517,0.005056558949589168
geo_metals_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03bf0dd7e5f6c26b24bebd200665f5f798c1b6054104623287c7fcfbf6216fcf
3
+ size 594126
model.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # model.py
2
+ import joblib
3
+ import pandas as pd
4
+
5
+ MODEL_PATH = "geo_metals_model.joblib"
6
+ model = joblib.load(MODEL_PATH)
7
+
8
+ def predict_metals(lat, lon):
9
+ input_data = pd.DataFrame([{
10
+ 'Latitude': lat,
11
+ 'Longitude': lon
12
+ }])
13
+ prediction = model.predict(input_data)[0]
14
+ metals = ['Fe_ppm', 'Cr_ppm', 'Mn_ppm', 'Mo_ppm', 'In_ppm', 'Ta_ppm']
15
+ return dict(zip(metals, prediction))