varshitha22 commited on
Commit
8b4ff99
·
verified ·
1 Parent(s): d3effe1

Update pages/Recommendations.py

Browse files
Files changed (1) hide show
  1. pages/Recommendations.py +41 -6
pages/Recommendations.py CHANGED
@@ -5,21 +5,56 @@ import numpy as np
5
  df = pd.read_csv("https://huggingface.co/spaces/varshitha22/Crop_Recommendation/resolve/main/Crop_Recommendation.csv")
6
 
7
  st.markdown("<h2 style='color: #D35400; font-size: 23px;'> 🌱 Seasonal Crop Guide</h2>", unsafe_allow_html=True)
 
 
8
  summer_conditions = (df["Temperature"].between(20, 40)) & (df["Rainfall"].between(50, 200)) & (df["Humidity"].between(40, 70))
9
  rainy_conditions = (df["Temperature"].between(20, 30)) & (df["Rainfall"] > 200) & (df["Humidity"].between(65, 95))
10
  winter_conditions = (df["Temperature"].between(10, 20)) & (df["Rainfall"] < 150) & (df["Humidity"].between(30, 70))
11
 
12
- # **Get Unique Crops for Each Season**
13
  summer_crops = df[summer_conditions]["Crop"].unique().tolist()
14
  rainy_crops = df[rainy_conditions]["Crop"].unique().tolist()
15
  winter_crops = df[winter_conditions]["Crop"].unique().tolist()
16
 
17
- # **Display Crop Recommendations**
18
- st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'> ☀ Summer Crops</h2>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  st.markdown(f"<p style='font-size: 20px; color: black;'>{', '.join(summer_crops) if summer_crops else 'No crops suitable for summer.'}</p>", unsafe_allow_html=True)
20
 
21
- st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'> 🌧 Rainy Season Crops</h2>", unsafe_allow_html=True)
22
  st.markdown(f"<p style='font-size: 20px; color: black;'>{', '.join(rainy_crops) if rainy_crops else 'No crops suitable for the rainy season.'}</p>", unsafe_allow_html=True)
23
 
24
- st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'> ❄ Winter Crops</h2>", unsafe_allow_html=True)
25
- st.markdown(f"<p style='font-size: 20px; color: black;'>{', '.join(winter_crops) if winter_crops else 'No crops suitable for winter.'}</p>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
5
  df = pd.read_csv("https://huggingface.co/spaces/varshitha22/Crop_Recommendation/resolve/main/Crop_Recommendation.csv")
6
 
7
  st.markdown("<h2 style='color: #D35400; font-size: 23px;'> 🌱 Seasonal Crop Guide</h2>", unsafe_allow_html=True)
8
+
9
+ # Define conditions for each season
10
  summer_conditions = (df["Temperature"].between(20, 40)) & (df["Rainfall"].between(50, 200)) & (df["Humidity"].between(40, 70))
11
  rainy_conditions = (df["Temperature"].between(20, 30)) & (df["Rainfall"] > 200) & (df["Humidity"].between(65, 95))
12
  winter_conditions = (df["Temperature"].between(10, 20)) & (df["Rainfall"] < 150) & (df["Humidity"].between(30, 70))
13
 
14
+ # Get unique crops for each season
15
  summer_crops = df[summer_conditions]["Crop"].unique().tolist()
16
  rainy_crops = df[rainy_conditions]["Crop"].unique().tolist()
17
  winter_crops = df[winter_conditions]["Crop"].unique().tolist()
18
 
19
+ # Explanation Sections
20
+ with st.expander("☀ Summer Season Conditions"):
21
+ st.write("""
22
+ - **Temperature:** 20°C to 40°C
23
+ - **Rainfall:** 50mm to 200mm
24
+ - **Humidity:** 40% to 70%
25
+ - **Why these crops?** Summer crops are chosen based on their tolerance to high temperatures and moderate water availability.
26
+ """)
27
+
28
+ with st.expander("🌧 Rainy Season Conditions"):
29
+ st.write("""
30
+ - **Temperature:** 20°C to 30°C
31
+ - **Rainfall:** More than 200mm
32
+ - **Humidity:** 65% to 95%
33
+ - **Why these crops?** Rainy season crops thrive in high humidity and excess rainfall, requiring good drainage to prevent waterlogging.
34
+ """)
35
+
36
+ with st.expander("❄ Winter Season Conditions"):
37
+ st.write("""
38
+ - **Temperature:** 10°C to 20°C
39
+ - **Rainfall:** Less than 150mm
40
+ - **Humidity:** 30% to 70%
41
+ - **Why these crops?** Winter crops grow best in cooler temperatures with minimal water requirements, making them ideal for this season.
42
+ """)
43
+
44
+ # Display Crop Recommendations
45
+ st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'> ☀ Recommended Summer Crops</h2>", unsafe_allow_html=True)
46
  st.markdown(f"<p style='font-size: 20px; color: black;'>{', '.join(summer_crops) if summer_crops else 'No crops suitable for summer.'}</p>", unsafe_allow_html=True)
47
 
48
+ st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'> 🌧 Recommended Rainy Season Crops</h2>", unsafe_allow_html=True)
49
  st.markdown(f"<p style='font-size: 20px; color: black;'>{', '.join(rainy_crops) if rainy_crops else 'No crops suitable for the rainy season.'}</p>", unsafe_allow_html=True)
50
 
51
+ st.markdown("<h2 style='color: #2E86C1; font-size: 23px;'> ❄ Recommended Winter Crops</h2>", unsafe_allow_html=True)
52
+ st.markdown(f"<p style='font-size: 20px; color: black;'>{', '.join(winter_crops) if winter_crops else 'No crops suitable for winter.'}</p>", unsafe_allow_html=True)
53
+
54
+ # Additional Insights
55
+ st.markdown("<h2 style='color: #27AE60; font-size: 23px;'> 📌 Key Takeaways</h2>", unsafe_allow_html=True)
56
+ st.write("""
57
+ - Crop selection is based on environmental factors such as temperature, rainfall, and humidity.
58
+ - Proper soil management and irrigation play a crucial role in maximizing yield.
59
+ - Selecting crops according to the season enhances productivity and sustainability in farming.
60
+ """)