Spaces:
Sleeping
Sleeping
Update pages/EDA.py
Browse files- pages/EDA.py +112 -0
pages/EDA.py
CHANGED
|
@@ -354,4 +354,116 @@ st.markdown("""
|
|
| 354 |
2. Chickpea and Lentil Grow Okay : They can manage in dry conditions but need some care, like proper soil and water.<br>
|
| 355 |
3. Moth Beans and Pigeon Peas Struggle : These crops don’t grow well in dry weather and need more rain and better soil.<br>
|
| 356 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
""", unsafe_allow_html=True)
|
|
|
|
| 354 |
2. Chickpea and Lentil Grow Okay : They can manage in dry conditions but need some care, like proper soil and water.<br>
|
| 355 |
3. Moth Beans and Pigeon Peas Struggle : These crops don’t grow well in dry weather and need more rain and better soil.<br>
|
| 356 |
</div>
|
| 357 |
+
""", unsafe_allow_html=True)
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
st.markdown("<h2 style='color: #D35400; font-size: 23px;'>proportion of crops Growing in rich soil Nutrients and climate factors</h2>", unsafe_allow_html=True)
|
| 365 |
+
# Calculate average values for nutrients & climate factors
|
| 366 |
+
avg_nitrogen = df['Nitrogen'].mean()
|
| 367 |
+
avg_phosphorus = df['Phosphorus'].mean()
|
| 368 |
+
avg_potassium = df['Potassium'].mean()
|
| 369 |
+
avg_temperature = df['Temperature'].mean()
|
| 370 |
+
avg_humidity = df['Humidity'].mean()
|
| 371 |
+
avg_pH_value = df['pH_Value'].mean()
|
| 372 |
+
avg_rainfall = df['Rainfall'].mean()
|
| 373 |
+
|
| 374 |
+
# Filter Crops Growing in Rich Nutrient & Climate Conditions
|
| 375 |
+
Crop_recommendation = df[
|
| 376 |
+
(df['Nitrogen'] >= avg_nitrogen) & (df['Phosphorus'] >= avg_phosphorus) &
|
| 377 |
+
(df['Potassium'] >= avg_potassium) & (df['Temperature'] >= avg_temperature) &
|
| 378 |
+
(df['Humidity'] >= avg_humidity) & (df['pH_Value'] >= avg_pH_value) &
|
| 379 |
+
(df['Rainfall'] >= avg_rainfall)
|
| 380 |
+
]['Crop']
|
| 381 |
+
|
| 382 |
+
crop_counts = Crop_recommendation.value_counts()
|
| 383 |
+
explode = [0.1 if i == 0 else 0 for i in range(len(crop_counts))]
|
| 384 |
+
|
| 385 |
+
# Create Pie Chart for Crops Growing in Rich Nutrient & Climate Conditions
|
| 386 |
+
fig, ax = plt.subplots(figsize=(5, 3)) # Reduced plot size
|
| 387 |
+
ax.pie(
|
| 388 |
+
crop_counts, labels=crop_counts.index, autopct='%1.1f%%',
|
| 389 |
+
startangle=140, explode=explode, colors=sns.color_palette("rainbow", len(crop_counts)),
|
| 390 |
+
textprops={'fontsize': 6} # Smaller label size
|
| 391 |
+
)
|
| 392 |
+
ax.set_title("Proportion of Crops in Rich Nutrients & Climate", fontsize=9)
|
| 393 |
+
st.pyplot(fig)
|
| 394 |
+
|
| 395 |
+
# Insights for Nutrient-Rich Crops
|
| 396 |
+
st.markdown("<h2 style='color: #D35400; font-size: 23px;'>Insights:</h2>", unsafe_allow_html=True)
|
| 397 |
+
st.markdown("""
|
| 398 |
+
<style>
|
| 399 |
+
.insights-box {
|
| 400 |
+
font-size: 19px;
|
| 401 |
+
color: #333;
|
| 402 |
+
background-color: #f9f9f9;
|
| 403 |
+
padding: 8px;
|
| 404 |
+
border-radius: 8px;
|
| 405 |
+
border-left: 4px solid #2E86C1;
|
| 406 |
+
}
|
| 407 |
+
</style>
|
| 408 |
+
<div class='insights-box'>
|
| 409 |
+
1. If your land has high soil nutrients (Nitrogen, Phosphorus, Potassium) and favorable climate conditions (good temperature, humidity, pH, and rainfall), these are the best crops to grow
|
| 410 |
+
</div>
|
| 411 |
+
""", unsafe_allow_html=True)
|
| 412 |
+
|
| 413 |
+
st.markdown("<h2 style='color: #D35400; font-size: 23px;'>proportion of crops Growing in less soil Nutrients and climate factors</h2>", unsafe_allow_html=True)
|
| 414 |
+
# Filter Crops Growing in Poor Nutrient & Climate Conditions
|
| 415 |
+
Crop_recommendation1 = df[
|
| 416 |
+
(df['Nitrogen'] < avg_nitrogen) & (df['Phosphorus'] < avg_phosphorus) &
|
| 417 |
+
(df['Potassium'] < avg_potassium) & (df['Temperature'] < avg_temperature) &
|
| 418 |
+
(df['Humidity'] < avg_humidity) & (df['pH_Value'] < avg_pH_value) &
|
| 419 |
+
(df['Rainfall'] < avg_rainfall)
|
| 420 |
+
]['Crop']
|
| 421 |
+
|
| 422 |
+
crop_counts1 = Crop_recommendation1.value_counts()
|
| 423 |
+
explode = [0.1 if i == 0 else 0 for i in range(len(crop_counts1))]
|
| 424 |
+
|
| 425 |
+
# Create Pie Chart for Crops Growing in Poor Nutrient & Climate Conditions
|
| 426 |
+
fig, ax = plt.subplots(figsize=(5, 3)) # Reduced plot size
|
| 427 |
+
ax.pie(
|
| 428 |
+
crop_counts1, labels=crop_counts1.index, autopct='%1.1f%%',
|
| 429 |
+
startangle=140, explode=explode, colors=sns.color_palette("rainbow", len(crop_counts1)),
|
| 430 |
+
textprops={'fontsize': 6} # Smaller label size
|
| 431 |
+
)
|
| 432 |
+
ax.set_title("Proportion of Crops in Poor Nutrients & Climate", fontsize=9)
|
| 433 |
+
st.pyplot(fig)
|
| 434 |
+
|
| 435 |
+
# Insights for Nutrient-Poor Crops
|
| 436 |
+
st.markdown("<h2 style='color: #D35400; font-size: 23px;'>Insights:</h2>", unsafe_allow_html=True)
|
| 437 |
+
st.markdown("""
|
| 438 |
+
<style>
|
| 439 |
+
.insights-box {
|
| 440 |
+
font-size: 19px;
|
| 441 |
+
color: #333;
|
| 442 |
+
background-color: #f9f9f9;
|
| 443 |
+
padding: 8px;
|
| 444 |
+
border-radius: 8px;
|
| 445 |
+
border-left: 4px solid #2E86C1;
|
| 446 |
+
}
|
| 447 |
+
</style>
|
| 448 |
+
<div class='insights-box'>
|
| 449 |
+
1. If your land has low soil nutrients (Nitrogen, Phosphorus, Potassium) and unfavorable climate conditions (low temperature, humidity, pH, and rainfall), Moth Beans is the best option.
|
| 450 |
+
</div>
|
| 451 |
+
""", unsafe_allow_html=True)
|
| 452 |
+
st.markdown("<h2 style='color: #D35400; font-size: 23px;'>Why MothBeans ?</h2>", unsafe_allow_html=True)
|
| 453 |
+
st.markdown("""
|
| 454 |
+
<style>
|
| 455 |
+
.insights-box {
|
| 456 |
+
font-size: 19px;
|
| 457 |
+
color: #333;
|
| 458 |
+
background-color: #f9f9f9;
|
| 459 |
+
padding: 8px;
|
| 460 |
+
border-radius: 8px;
|
| 461 |
+
border-left: 4px solid #2E86C1;
|
| 462 |
+
}
|
| 463 |
+
</style>
|
| 464 |
+
<div class='insights-box'>
|
| 465 |
+
1. It grows well in dry and poor soil where other crops struggle.
|
| 466 |
+
2. Requires very little water and nutrients, making it cost-effective.
|
| 467 |
+
3. Has a stable market demand
|
| 468 |
+
</div>
|
| 469 |
""", unsafe_allow_html=True)
|