Spaces:
Build error
Build error
Upload 4 files
Browse files- .gitattributes +1 -0
- Sel.pkl +3 -0
- app.py +98 -0
- requirements.txt +4 -0
- train.csv +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
train.csv filter=lfs diff=lfs merge=lfs -text
|
Sel.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f875071006b23f5174d755d93b09139562d1c47081b27d7e92fc1ae9e3066269
|
| 3 |
+
size 195742
|
app.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
from sklearn.preprocessing import StandardScaler
|
| 6 |
+
from sklearn.model_selection import train_test_split
|
| 7 |
+
from sklearn.compose import ColumnTransformer
|
| 8 |
+
|
| 9 |
+
# Load data and update column names
|
| 10 |
+
df = pd.read_csv('train.csv')
|
| 11 |
+
|
| 12 |
+
# Select dependent and independent variables
|
| 13 |
+
x = df.drop(['id', 'FloodProbability'], axis=1)
|
| 14 |
+
y = df[['FloodProbability']]
|
| 15 |
+
|
| 16 |
+
# Split data into training and testing sets
|
| 17 |
+
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.20, random_state=42)
|
| 18 |
+
|
| 19 |
+
# Preprocessing (StandardScaler)
|
| 20 |
+
preprocessor = ColumnTransformer(
|
| 21 |
+
transformers=[
|
| 22 |
+
('num', StandardScaler(), ['MonsoonIntensity', 'TopographyDrainage', 'RiverManagement', 'Deforestation',
|
| 23 |
+
'Urbanization', 'ClimateChange', 'DamsQuality', 'Siltation',
|
| 24 |
+
'AgriculturalPractices', 'Encroachments', 'IneffectiveDisasterPreparedness',
|
| 25 |
+
'DrainageSystems', 'CoastalVulnerability', 'Landslides', 'Watersheds',
|
| 26 |
+
'DeterioratingInfrastructure', 'PopulationScore', 'WetlandLoss',
|
| 27 |
+
'InadequatePlanning', 'PoliticalFactors'])
|
| 28 |
+
]
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Streamlit application
|
| 32 |
+
def sel_pred(MonsoonIntensity, TopographyDrainage, RiverManagement, Deforestation, Urbanization,
|
| 33 |
+
ClimateChange, DamsQuality, Siltation, AgriculturalPractices, Encroachments,
|
| 34 |
+
IneffectiveDisasterPreparedness, DrainageSystems, CoastalVulnerability, Landslides,
|
| 35 |
+
Watersheds, DeterioratingInfrastructure, PopulationScore, WetlandLoss,
|
| 36 |
+
InadequatePlanning, PoliticalFactors):
|
| 37 |
+
input_data = pd.DataFrame({
|
| 38 |
+
'MonsoonIntensity': [MonsoonIntensity],
|
| 39 |
+
'TopographyDrainage': [TopographyDrainage],
|
| 40 |
+
'RiverManagement': [RiverManagement],
|
| 41 |
+
'Deforestation': [Deforestation],
|
| 42 |
+
'Urbanization': [Urbanization],
|
| 43 |
+
'ClimateChange': [ClimateChange],
|
| 44 |
+
'DamsQuality': [DamsQuality],
|
| 45 |
+
'Siltation': [Siltation],
|
| 46 |
+
'AgriculturalPractices': [AgriculturalPractices],
|
| 47 |
+
'Encroachments': [Encroachments],
|
| 48 |
+
'IneffectiveDisasterPreparedness': [IneffectiveDisasterPreparedness],
|
| 49 |
+
'DrainageSystems': [DrainageSystems],
|
| 50 |
+
'CoastalVulnerability': [CoastalVulnerability],
|
| 51 |
+
'Landslides': [Landslides],
|
| 52 |
+
'Watersheds': [Watersheds],
|
| 53 |
+
'DeterioratingInfrastructure': [DeterioratingInfrastructure],
|
| 54 |
+
'PopulationScore': [PopulationScore],
|
| 55 |
+
'WetlandLoss': [WetlandLoss],
|
| 56 |
+
'InadequatePlanning': [InadequatePlanning],
|
| 57 |
+
'PoliticalFactors': [PoliticalFactors]
|
| 58 |
+
})
|
| 59 |
+
input_data_transformed = preprocessor.fit_transform(input_data)
|
| 60 |
+
|
| 61 |
+
model = joblib.load('Sel.pkl')
|
| 62 |
+
|
| 63 |
+
prediction = model.predict(input_data_transformed)
|
| 64 |
+
|
| 65 |
+
return float(prediction[0])
|
| 66 |
+
|
| 67 |
+
st.title("Flood Risk Regression Model")
|
| 68 |
+
st.write("Enter Input Data")
|
| 69 |
+
|
| 70 |
+
MonsoonIntensity = st.number_input('MonsoonIntensity', min_value=int(df['MonsoonIntensity'].min()), max_value=int(df['MonsoonIntensity'].max()), step=1)
|
| 71 |
+
TopographyDrainage = st.number_input('TopographyDrainage', min_value=int(df['TopographyDrainage'].min()), max_value=int(df['TopographyDrainage'].max()), step=1)
|
| 72 |
+
RiverManagement = st.number_input('RiverManagement', min_value=int(df['RiverManagement'].min()), max_value=int(df['RiverManagement'].max()), step=1)
|
| 73 |
+
Deforestation = st.number_input('Deforestation', min_value=int(df['Deforestation'].min()), max_value=int(df['Deforestation'].max()), step=1)
|
| 74 |
+
Urbanization = st.number_input('Urbanization', min_value=int(df['Urbanization'].min()), max_value=int(df['Urbanization'].max()), step=1)
|
| 75 |
+
ClimateChange = st.number_input('ClimateChange', min_value=int(df['ClimateChange'].min()), max_value=int(df['ClimateChange'].max()), step=1)
|
| 76 |
+
DamsQuality = st.number_input('DamsQuality', min_value=int(df['DamsQuality'].min()), max_value=int(df['DamsQuality'].max()), step=1)
|
| 77 |
+
Siltation = st.number_input('Siltation', min_value=int(df['Siltation'].min()), max_value=int(df['Siltation'].max()), step=1)
|
| 78 |
+
AgriculturalPractices = st.number_input('AgriculturalPractices', min_value=int(df['AgriculturalPractices'].min()), max_value=int(df['AgriculturalPractices'].max()), step=1)
|
| 79 |
+
Encroachments = st.number_input('Encroachments', min_value=int(df['Encroachments'].min()), max_value=int(df['Encroachments'].max()), step=1)
|
| 80 |
+
IneffectiveDisasterPreparedness = st.number_input('IneffectiveDisasterPreparedness', min_value=int(df['IneffectiveDisasterPreparedness'].min()), max_value=int(df['IneffectiveDisasterPreparedness'].max()), step=1)
|
| 81 |
+
DrainageSystems = st.number_input('DrainageSystems', min_value=int(df['DrainageSystems'].min()), max_value=int(df['DrainageSystems'].max()), step=1)
|
| 82 |
+
CoastalVulnerability = st.number_input('CoastalVulnerability', min_value=int(df['CoastalVulnerability'].min()), max_value=int(df['CoastalVulnerability'].max()), step=1)
|
| 83 |
+
Landslides = st.number_input('Landslides', min_value=int(df['Landslides'].min()), max_value=int(df['Landslides'].max()), step=1)
|
| 84 |
+
Watersheds = st.number_input('Watersheds', min_value=int(df['Watersheds'].min()), max_value=int(df['Watersheds'].max()), step=1)
|
| 85 |
+
DeterioratingInfrastructure = st.number_input('DeterioratingInfrastructure', min_value=int(df['DeterioratingInfrastructure'].min()), max_value=int(df['DeterioratingInfrastructure'].max()), step=1)
|
| 86 |
+
PopulationScore = st.number_input('PopulationScore', min_value=int(df['PopulationScore'].min()), max_value=int(df['PopulationScore'].max()), step=1)
|
| 87 |
+
WetlandLoss = st.number_input('WetlandLoss', min_value=int(df['WetlandLoss'].min()), max_value=int(df['WetlandLoss'].max()), step=1)
|
| 88 |
+
InadequatePlanning = st.number_input('InadequatePlanning', min_value=int(df['InadequatePlanning'].min()), max_value=int(df['InadequatePlanning'].max()), step=1)
|
| 89 |
+
PoliticalFactors = st.number_input('PoliticalFactors', min_value=int(df['PoliticalFactors'].min()), max_value=int(df['PoliticalFactors'].max()), step=1)
|
| 90 |
+
|
| 91 |
+
if st.button('Predict'):
|
| 92 |
+
sel = sel_pred(MonsoonIntensity, TopographyDrainage, RiverManagement, Deforestation, Urbanization,
|
| 93 |
+
ClimateChange, DamsQuality, Siltation, AgriculturalPractices, Encroachments,
|
| 94 |
+
IneffectiveDisasterPreparedness, DrainageSystems, CoastalVulnerability, Landslides,
|
| 95 |
+
Watersheds, DeterioratingInfrastructure, PopulationScore, WetlandLoss,
|
| 96 |
+
InadequatePlanning, PoliticalFactors)
|
| 97 |
+
st.write(f'The predicted flood probability is: {sel:.2f}')
|
| 98 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
scikit-learn
|
| 3 |
+
pandas
|
| 4 |
+
tensorflow
|
train.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c9adeacec0537306a80b957a69e57bf6d389e3c02c1ff33ca0a7dcb5a9b30fb
|
| 3 |
+
size 59127674
|