geocif 0.1.77__tar.gz → 0.1.78__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {geocif-0.1.77/geocif.egg-info → geocif-0.1.78}/PKG-INFO +1 -1
- {geocif-0.1.77 → geocif-0.1.78}/geocif/analysis.py +32 -14
- geocif-0.1.78/geocif/cei/indices.py +917 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/geocif.py +18 -10
- {geocif-0.1.77 → geocif-0.1.78}/geocif/geocif_runner.py +54 -30
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner.py +1 -1
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_angola.py +2 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_madagascar.py +2 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_malawi.py +2 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_mozambique.py +2 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_south_africa.py +2 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_zambia.py +2 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_zimbabwe.py +2 -0
- geocif-0.1.78/geocif/mm.py +446 -0
- {geocif-0.1.77 → geocif-0.1.78/geocif.egg-info}/PKG-INFO +1 -1
- {geocif-0.1.77 → geocif-0.1.78}/setup.py +1 -1
- geocif-0.1.77/geocif/cei/indices.py +0 -880
- geocif-0.1.77/geocif/mm.py +0 -298
- {geocif-0.1.77 → geocif-0.1.78}/LICENSE +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/MANIFEST.in +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/README.md +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/geoagmet.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/plot.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/utils.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/constants.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/features.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/geo.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/geocif.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/metadata.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/models.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/cei/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/cei/definitions.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/experiments.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/logger.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/correlations.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/embedding.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/feature_engineering.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/feature_selection.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/outliers.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/outlook.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/output.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/spatial_autocorrelation.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/stages.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/stats.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/trainers.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/trend.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/xai.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/aa.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/area.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/automl.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/download_esi.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/enso.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/eval.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/gamtest.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/gee_access.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/misc.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/play_xagg.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/reg.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/sustain.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/test_catboost.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp2.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp3.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp4.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp5.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/wolayita_maize_mask.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/risk/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/risk/impact_assessment.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/utils.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/__init__.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/gt.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/plot.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/tmp.py +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/SOURCES.txt +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/dependency_links.txt +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/not-zip-safe +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/top_level.txt +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/requirements.txt +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/setup.cfg +0 -0
- {geocif-0.1.77 → geocif-0.1.78}/tests/test_geocif.py +0 -0
@@ -347,7 +347,9 @@ class Geoanalysis:
|
|
347
347
|
df_tmp = df_region.copy()
|
348
348
|
|
349
349
|
# Fill
|
350
|
-
df_tmp[area_ha] = df_tmp.groupby("Country")[area_ha].transform(
|
350
|
+
df_tmp[area_ha] = df_tmp.groupby("Country")[area_ha].transform(
|
351
|
+
lambda x: x.fillna(x.median())
|
352
|
+
)
|
351
353
|
|
352
354
|
# Log that we are filling missing values with the median
|
353
355
|
self.logger.info(
|
@@ -379,7 +381,11 @@ class Geoanalysis:
|
|
379
381
|
"""
|
380
382
|
Plot observed vs predicted yield for all regions and all years.
|
381
383
|
"""
|
382
|
-
from sklearn.metrics import
|
384
|
+
from sklearn.metrics import (
|
385
|
+
mean_squared_error,
|
386
|
+
r2_score,
|
387
|
+
mean_absolute_percentage_error,
|
388
|
+
)
|
383
389
|
|
384
390
|
# Ensure 'Harvest Year' is numeric
|
385
391
|
df.loc[:, "Harvest Year"] = pd.to_numeric(df["Harvest Year"], errors="coerce")
|
@@ -391,7 +397,9 @@ class Geoanalysis:
|
|
391
397
|
|
392
398
|
# Generate colors for years
|
393
399
|
cmap = plt.cm.viridis # Colormap for years
|
394
|
-
norm = plt.Normalize(
|
400
|
+
norm = plt.Normalize(
|
401
|
+
vmin=years.min(), vmax=years.max()
|
402
|
+
) # Normalize years to colormap
|
395
403
|
colors = [cmap(norm(year)) for year in years]
|
396
404
|
|
397
405
|
# Create the plot
|
@@ -442,7 +450,9 @@ class Geoanalysis:
|
|
442
450
|
cbar.set_label("Harvest Year")
|
443
451
|
|
444
452
|
# Set equispaced ticks for exactly 5 points
|
445
|
-
ticks = np.linspace(
|
453
|
+
ticks = np.linspace(
|
454
|
+
years.min(), years.max(), 5, dtype=int
|
455
|
+
) # 5 equispaced ticks
|
446
456
|
cbar.set_ticks(ticks)
|
447
457
|
cbar.ax.set_yticklabels([str(tick) for tick in ticks])
|
448
458
|
|
@@ -454,10 +464,16 @@ class Geoanalysis:
|
|
454
464
|
plt.close()
|
455
465
|
|
456
466
|
def _plot_national_yield(self, df_national_yield):
|
457
|
-
from sklearn.metrics import
|
467
|
+
from sklearn.metrics import (
|
468
|
+
mean_squared_error,
|
469
|
+
r2_score,
|
470
|
+
mean_absolute_percentage_error,
|
471
|
+
)
|
458
472
|
|
459
473
|
# Ensure 'Harvest Year' is numeric
|
460
|
-
df_national_yield["Harvest Year"] = pd.to_numeric(
|
474
|
+
df_national_yield["Harvest Year"] = pd.to_numeric(
|
475
|
+
df_national_yield["Harvest Year"], errors="coerce"
|
476
|
+
)
|
461
477
|
|
462
478
|
# Extract data
|
463
479
|
x = df_national_yield["Harvest Year"]
|
@@ -516,7 +532,9 @@ class Geoanalysis:
|
|
516
532
|
# Add legend for years
|
517
533
|
sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
|
518
534
|
sm.set_array([])
|
519
|
-
cbar = fig.colorbar(
|
535
|
+
cbar = fig.colorbar(
|
536
|
+
sm, ax=ax, aspect=50, pad=0.02
|
537
|
+
) # Specify the axis explicitly
|
520
538
|
cbar.set_label("Harvest Year")
|
521
539
|
|
522
540
|
# Set equispaced ticks for exactly 5 points
|
@@ -579,10 +597,8 @@ class Geoanalysis:
|
|
579
597
|
)
|
580
598
|
|
581
599
|
# Merge the median yield columns with the % of total production dataframe
|
582
|
-
df_historic = (
|
583
|
-
|
584
|
-
.merge(df_median_2018_2022, on="Region", how="left")
|
585
|
-
.merge(df_median_2013_2017, on="Region", how="left")
|
600
|
+
df_historic = df_pct.merge(df_median_2018_2022, on="Region", how="left").merge(
|
601
|
+
df_median_2013_2017, on="Region", how="left"
|
586
602
|
)
|
587
603
|
|
588
604
|
return df_historic
|
@@ -1081,7 +1097,7 @@ class RegionalMapper(Geoanalysis):
|
|
1081
1097
|
df_tmp = df_model[
|
1082
1098
|
(df_model["% of total Area (ha)"] < 0.5)
|
1083
1099
|
& (df_model["Mean Absolute Percentage Error"] > 100)
|
1084
|
-
|
1100
|
+
]
|
1085
1101
|
|
1086
1102
|
df_model = df_model.drop(df_tmp.index)
|
1087
1103
|
|
@@ -1113,7 +1129,9 @@ class RegionalMapper(Geoanalysis):
|
|
1113
1129
|
# )
|
1114
1130
|
|
1115
1131
|
plt.tight_layout()
|
1116
|
-
plt.savefig(
|
1132
|
+
plt.savefig(
|
1133
|
+
self.dir_analysis / f"histogram_region_{model}_mape.png", dpi=250
|
1134
|
+
)
|
1117
1135
|
plt.close()
|
1118
1136
|
|
1119
1137
|
def plot_mape_map(self):
|
@@ -1140,7 +1158,7 @@ class RegionalMapper(Geoanalysis):
|
|
1140
1158
|
col = "Mean Absolute Percentage Error"
|
1141
1159
|
countries = df_model["Country"].unique().tolist()
|
1142
1160
|
countries = [country.title().replace("_", " ") for country in countries]
|
1143
|
-
crop = df_model["Crop"].unique()[0].title().replace(
|
1161
|
+
crop = df_model["Crop"].unique()[0].title().replace("_", " ")
|
1144
1162
|
df = df_model[df_model["Country"].isin(countries)]
|
1145
1163
|
self.dg = self.dg[self.dg["ADM0_NAME"].isin(countries)]
|
1146
1164
|
|