geocif 0.1.34__tar.gz → 0.1.35__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.
Files changed (54) hide show
  1. {geocif-0.1.34/geocif.egg-info → geocif-0.1.35}/PKG-INFO +1 -1
  2. {geocif-0.1.34 → geocif-0.1.35}/geocif/cei/indices.py +1 -0
  3. {geocif-0.1.34 → geocif-0.1.35}/geocif/geocif.py +3 -4
  4. {geocif-0.1.34 → geocif-0.1.35}/geocif/indices_runner_v2.py +10 -11
  5. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/correlations.py +32 -16
  6. {geocif-0.1.34 → geocif-0.1.35/geocif.egg-info}/PKG-INFO +1 -1
  7. {geocif-0.1.34 → geocif-0.1.35}/setup.py +1 -1
  8. {geocif-0.1.34 → geocif-0.1.35}/LICENSE +0 -0
  9. {geocif-0.1.34 → geocif-0.1.35}/MANIFEST.in +0 -0
  10. {geocif-0.1.34 → geocif-0.1.35}/README.md +0 -0
  11. {geocif-0.1.34 → geocif-0.1.35}/geocif/__init__.py +0 -0
  12. {geocif-0.1.34 → geocif-0.1.35}/geocif/agmet/__init__.py +0 -0
  13. {geocif-0.1.34 → geocif-0.1.35}/geocif/agmet/geoagmet.py +0 -0
  14. {geocif-0.1.34 → geocif-0.1.35}/geocif/agmet/plot.py +0 -0
  15. {geocif-0.1.34 → geocif-0.1.35}/geocif/agmet/utils.py +0 -0
  16. {geocif-0.1.34 → geocif-0.1.35}/geocif/analysis.py +0 -0
  17. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/__init__.py +0 -0
  18. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/constants.py +0 -0
  19. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/features.py +0 -0
  20. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/geo.py +0 -0
  21. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/geocif.py +0 -0
  22. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/metadata.py +0 -0
  23. {geocif-0.1.34 → geocif-0.1.35}/geocif/backup/models.py +0 -0
  24. {geocif-0.1.34 → geocif-0.1.35}/geocif/cei/__init__.py +0 -0
  25. {geocif-0.1.34 → geocif-0.1.35}/geocif/cei/definitions.py +0 -0
  26. {geocif-0.1.34 → geocif-0.1.35}/geocif/indices_runner.py +0 -0
  27. {geocif-0.1.34 → geocif-0.1.35}/geocif/logger.py +0 -0
  28. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/__init__.py +0 -0
  29. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/correlations_backup.py +0 -0
  30. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/embedding.py +0 -0
  31. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/feature_engineering.py +0 -0
  32. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/feature_selection.py +0 -0
  33. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/outliers.py +0 -0
  34. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/outlook.py +0 -0
  35. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/output.py +0 -0
  36. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/spatial_autocorrelation.py +0 -0
  37. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/stages.py +0 -0
  38. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/stats.py +0 -0
  39. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/trainers.py +0 -0
  40. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/trend.py +0 -0
  41. {geocif-0.1.34 → geocif-0.1.35}/geocif/ml/xai.py +0 -0
  42. {geocif-0.1.34 → geocif-0.1.35}/geocif/playground/__init__.py +0 -0
  43. {geocif-0.1.34 → geocif-0.1.35}/geocif/playground/automl.py +0 -0
  44. {geocif-0.1.34 → geocif-0.1.35}/geocif/playground/misc.py +0 -0
  45. {geocif-0.1.34 → geocif-0.1.35}/geocif/utils.py +0 -0
  46. {geocif-0.1.34 → geocif-0.1.35}/geocif/viz/__init__.py +0 -0
  47. {geocif-0.1.34 → geocif-0.1.35}/geocif/viz/plot.py +0 -0
  48. {geocif-0.1.34 → geocif-0.1.35}/geocif.egg-info/SOURCES.txt +0 -0
  49. {geocif-0.1.34 → geocif-0.1.35}/geocif.egg-info/dependency_links.txt +0 -0
  50. {geocif-0.1.34 → geocif-0.1.35}/geocif.egg-info/not-zip-safe +0 -0
  51. {geocif-0.1.34 → geocif-0.1.35}/geocif.egg-info/top_level.txt +0 -0
  52. {geocif-0.1.34 → geocif-0.1.35}/requirements.txt +0 -0
  53. {geocif-0.1.34 → geocif-0.1.35}/setup.cfg +0 -0
  54. {geocif-0.1.34 → geocif-0.1.35}/tests/test_geocif.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.34
3
+ Version: 0.1.35
4
4
  Summary: Models to visualize and forecast crop conditions and yields
5
5
  Home-page: https://ritviksahajpal.github.io/yield_forecasting/
6
6
  Author: Ritvik Sahajpal
@@ -393,6 +393,7 @@ class CEIs:
393
393
  / self.admin_zone
394
394
  / self.country
395
395
  )
396
+
396
397
  os.makedirs(self.dir_output, exist_ok=True)
397
398
  os.makedirs(self.dir_intermediate, exist_ok=True)
398
399
 
@@ -487,10 +487,9 @@ class Geocif:
487
487
  "Harvest Year",
488
488
  "Stage Name",
489
489
  ]
490
- try:
491
- df.index = df.apply(lambda row: "_".join([str(row[col]) for col in index_columns]), axis=1)
492
- except Exception as e:
493
- breakpoint()
490
+ df.index = df.apply(
491
+ lambda row: "_".join([str(row[col]) for col in index_columns]), axis=1
492
+ )
494
493
 
495
494
  # name the index level
496
495
  df.index.set_names(["Index"], inplace=True)
@@ -155,22 +155,21 @@ class cei_runner(base.BaseGeo):
155
155
  "ndvi",
156
156
  False, # redo
157
157
  )
158
- for year in range(2001, ar.utcnow().year + 1)
158
+ for year in range(2024, ar.utcnow().year + 1)
159
159
  for status, path, filename, admin_zone, category in combinations
160
160
  ]
161
161
 
162
162
  # Only keep those entries in combinations where the third elemt is
163
163
  # mozambique, south_africa, angola or dem_people's_rep_of_korea
164
164
  # This is done to test the code for these countries
165
- #combinations = [
166
- # i
167
- # for i in combinations
168
- # if "ethiopia_maize_s1" in i[3]
169
- #]
170
- # "malawi" in i[2]]
171
-
172
- if True:
173
- num_cpu = int(cpu_count() * 0.8)
165
+ combinations = [
166
+ i
167
+ for i in combinations
168
+ if "malawi_maize_s1" in i[3]
169
+ ]
170
+
171
+ if False:
172
+ num_cpu = int(cpu_count() * 0.3)
174
173
  with Pool(num_cpu) as p:
175
174
  for i, _ in enumerate(p.imap_unordered(indices.process, combinations)):
176
175
  pass
@@ -198,7 +197,7 @@ def run(path_config_files=[]):
198
197
  indices.validate_index_definitions()
199
198
 
200
199
  for method in [
201
- "phenological_stages", # "dekad_r" # "dekad_r"
200
+ "biweekly_r", # "dekad_r" # "dekad_r"
202
201
  ]: # , "full_season", "phenological_stages", "fraction_season"]:
203
202
  obj = cei_runner(path_config_files)
204
203
  obj.main(method)
@@ -246,6 +246,7 @@ def all_correlated_feature_by_time(df, **kwargs):
246
246
  Returns:
247
247
 
248
248
  """
249
+ THRESHOLD = 0.1
249
250
  national_correlation = kwargs.get("national_correlation")
250
251
  group_by = kwargs.get("groupby")
251
252
  combined_dict = kwargs.get("combined_dict")
@@ -264,8 +265,16 @@ def all_correlated_feature_by_time(df, **kwargs):
264
265
  df_corr = df_corr.dropna(thresh=len(df_corr) / 2, axis=1)
265
266
 
266
267
  if not df_corr.empty:
267
- df_tmp = df_corr[df_corr.columns[(df_corr.mean() > 0.1)]]
268
- dict_selected_features[region_id] = df_tmp.columns
268
+ df_tmp = df_corr[df_corr.columns[(abs(df_corr.mean()) > THRESHOLD)]]
269
+ # Add the columns to dict_selected_features along with the absolute mean value
270
+ absolute_medians = df_tmp.abs().median()
271
+
272
+ # Create a DataFrame to display the column names and their absolute median values
273
+ absolute_median_df = absolute_medians.reset_index()
274
+ absolute_median_df.columns = ['CEI', 'Median']
275
+
276
+ # Add the CEI and Median value to dict_selected_features
277
+ dict_selected_features[region_id] = absolute_median_df
269
278
 
270
279
  df_tmp2 = (
271
280
  df_tmp.median(axis=0)
@@ -293,24 +302,31 @@ def all_correlated_feature_by_time(df, **kwargs):
293
302
  else:
294
303
  # HACK
295
304
  df_corr = _all_correlated_feature_by_time(df, **kwargs)
296
- dict_selected_features[region_id] = df_corr.columns
297
- dict_best_cei[region_id] = {}
298
305
 
299
- # dict_selected_features[region_id] = dict_selected_features[0]
300
- # dict_best_cei[region_id] = dict_best_cei[0]
301
- # Combine all unique values from the existing dictionary elements
302
- # combined_metrics = set()
303
- # for key in dict_selected_features:
304
- # breakpoint()
305
- # combined_metrics.update(dict_selected_features[key])
306
- #
307
- # # Add the combined set as a new element with key 3
308
- # dict_selected_features[region_id] = sorted(list(combined_metrics))
306
+ df_tmp = df_corr[df_corr.columns[(abs(df_corr.mean()) > THRESHOLD)]]
307
+ # Add the columns to dict_selected_features along with the absolute mean value
308
+ absolute_medians = df_tmp.abs().median()
309
+
310
+ # Create a DataFrame to display the column names and their absolute median values
311
+ absolute_median_df = absolute_medians.reset_index()
312
+ absolute_median_df.columns = ['CEI', 'Median']
313
+
314
+ # Add the CEI and Median value to dict_selected_features
315
+ dict_selected_features[region_id] = absolute_median_df
316
+ dict_best_cei[region_id] = {}
309
317
  else:
310
318
  df_corr = _all_correlated_feature_by_time(df, **kwargs)
311
- dict_selected_features[0] = df_corr.columns
319
+ df_tmp = df_corr[df_corr.columns[(abs(df_corr.mean()) > THRESHOLD)]]
320
+ # Add the columns to dict_selected_features along with the absolute mean value
321
+ absolute_medians = df_tmp.abs().median()
322
+
323
+ # Create a DataFrame to display the column names and their absolute median values
324
+ absolute_median_df = absolute_medians.reset_index()
325
+ absolute_median_df.columns = ['CEI', 'Median']
326
+
327
+ # Add the CEI and Median value to dict_selected_features
328
+ dict_selected_features[0] = absolute_median_df
312
329
 
313
- df_corr = df_corr[df_corr.columns[(df_corr.mean() > 0.1)]]
314
330
  plot_feature_corr_by_time(df_corr, **kwargs)
315
331
 
316
332
  return dict_selected_features, dict_best_cei
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.34
3
+ Version: 0.1.35
4
4
  Summary: Models to visualize and forecast crop conditions and yields
5
5
  Home-page: https://ritviksahajpal.github.io/yield_forecasting/
6
6
  Author: Ritvik Sahajpal
@@ -50,6 +50,6 @@ setup(
50
50
  test_suite="tests",
51
51
  tests_require=test_requirements,
52
52
  url="https://ritviksahajpal.github.io/yield_forecasting/",
53
- version="0.1.34",
53
+ version="0.1.35",
54
54
  zip_safe=False,
55
55
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes