phase5 code
phase5 code
import pickle
import random
return elevation
def load_rainfall_data():
return rainfall
return water_accum
plt.imshow(water_accum, cmap='Blues')
plt.savefig(filename)
plt.close()
def train_flood_model():
features = np.random.rand(100, 5)
labels = np.random.choice(["Low", "High"], 100)
model = RandomForestClassifier(n_estimators=100)
model.fit(features, labels)
pickle.dump(model, f)
return model
def predict_flood_risk(model):
test_features = np.random.rand(1, 5)
prediction = model.predict(test_features)
return prediction[0]
def get_sensor_data():
return {
"Drain_Location_1": round(random.uniform(0.1, 0.5), 2),
}
# 5. Dashboard
if risk == "High":
print("ALERT: High flood risk detected!")
def run_drainage_system():
elevation = load_terrain_data()
rainfall = load_rainfall_data()
visualize_water_flow(water)
model = train_flood_model()
risk_prediction = predict_flood_risk(model)
sensors = get_sensor_data()
dashboard(sensors, risk_prediction)
if __name__ == "__main__":
run_drainage_system()