varshitha22 commited on
Commit
57ccae9
·
verified ·
1 Parent(s): d712615

Update pages/EDA.py

Browse files
Files changed (1) hide show
  1. pages/EDA.py +9 -10
pages/EDA.py CHANGED
@@ -147,17 +147,17 @@ viz_option = st.selectbox("Select a feature visualization:", options=list(featur
147
  crop_counts = df['Crop'].value_counts()
148
  explode = [0.1 if i == 0 else 0 for i in range(len(crop_counts))]
149
 
150
- fig, ax = plt.subplots(figsize=(5, 3)) # Reduced plot size
151
  ax.pie(
152
  crop_counts, labels=crop_counts.index, autopct='%1.1f%%',
153
  startangle=140, explode=explode, colors=sns.color_palette("rainbow", len(crop_counts)),
154
- textprops={'fontsize': 4} # Decreased label size
155
  )
156
  ax.set_title("Proportion of Crops", fontsize=10)
157
  st.pyplot(fig)
158
 
159
  # Above-Average Nutrient Requirement Crops
160
- st.markdown("#### ✔ Crops that require above-average soil nutrients & climate factors")
161
 
162
  # Calculate average nutrient levels
163
  avg_nitrogen = df['Nitrogen'].mean()
@@ -167,7 +167,7 @@ avg_potassium = df['Potassium'].mean()
167
  # Function to plot bar charts
168
  def plot_nutrient_crops(data, title):
169
  crop_counts = data.value_counts()
170
- fig, ax = plt.subplots(figsize=(4, 2)) # Adjusted plot size for better display
171
  crop_counts.plot(kind='bar', color='skyblue', ax=ax)
172
  ax.set_xlabel('Crops', fontsize=8)
173
  ax.set_ylabel('Count', fontsize=8)
@@ -199,14 +199,13 @@ st.markdown("""
199
  }
200
  </style>
201
  <div class='insights-box'>
202
- 1️⃣ Banana is the most frequent crop, indicating it requires high soil nutrients.<br>
203
- 2️⃣ Rice, Papaya, and Jute also need good nutrients but less than Banana.
204
  </div>
205
  """, unsafe_allow_html=True)
206
 
207
  # Below-Average Nutrient Requirement Crops
208
- st.markdown("#### ✔ Crops that require below-average soil nutrients & climate factors")
209
- st.markdown("<p style='color:blue; font-size:16px;'>Orange, Mango, Coconut.</p>", unsafe_allow_html=True)
210
 
211
  # Plot: Crops in Nutrient-Poor Soil
212
  less_avg_of_soil_nutrients = df[
@@ -231,7 +230,7 @@ st.markdown("""
231
  }
232
  </style>
233
  <div class='insights-box'>
234
- 1️⃣ Orange, Mango, and Coconut are the most frequent crops found in nutrient-poor soil.<br>
235
- 2️⃣ These crops are well-adapted to low-fertility conditions and can grow even when nutrient levels are below average..
236
  </div>
237
  """, unsafe_allow_html=True)
 
147
  crop_counts = df['Crop'].value_counts()
148
  explode = [0.1 if i == 0 else 0 for i in range(len(crop_counts))]
149
 
150
+ fig, ax = plt.subplots(figsize=(4, 2)) # Reduced plot size
151
  ax.pie(
152
  crop_counts, labels=crop_counts.index, autopct='%1.1f%%',
153
  startangle=140, explode=explode, colors=sns.color_palette("rainbow", len(crop_counts)),
154
+ textprops={'fontsize': 3} # Decreased label size
155
  )
156
  ax.set_title("Proportion of Crops", fontsize=10)
157
  st.pyplot(fig)
158
 
159
  # Above-Average Nutrient Requirement Crops
160
+ st.markdown("#### ✔ Crops that require above-average soil nutrients")
161
 
162
  # Calculate average nutrient levels
163
  avg_nitrogen = df['Nitrogen'].mean()
 
167
  # Function to plot bar charts
168
  def plot_nutrient_crops(data, title):
169
  crop_counts = data.value_counts()
170
+ fig, ax = plt.subplots(figsize=(3, 1)) # Adjusted plot size for better display
171
  crop_counts.plot(kind='bar', color='skyblue', ax=ax)
172
  ax.set_xlabel('Crops', fontsize=8)
173
  ax.set_ylabel('Count', fontsize=8)
 
199
  }
200
  </style>
201
  <div class='insights-box'>
202
+ 1. Banana is the most frequent crop, indicating it requires high soil nutrients.<br>
203
+ 2. Rice, Papaya, and Jute also need good nutrients but less than Banana.
204
  </div>
205
  """, unsafe_allow_html=True)
206
 
207
  # Below-Average Nutrient Requirement Crops
208
+ st.markdown("#### ✔ Crops that require below-average soil nutrients")
 
209
 
210
  # Plot: Crops in Nutrient-Poor Soil
211
  less_avg_of_soil_nutrients = df[
 
230
  }
231
  </style>
232
  <div class='insights-box'>
233
+ 1. Orange, Mango, and Coconut are the most frequent crops found in nutrient-poor soil.<br>
234
+ 2. These crops are well-adapted to low-fertility conditions and can grow even when nutrient levels are below average..
235
  </div>
236
  """, unsafe_allow_html=True)