geocif 0.1.40__tar.gz → 0.1.41__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 (55) hide show
  1. {geocif-0.1.40/geocif.egg-info → geocif-0.1.41}/PKG-INFO +1 -1
  2. {geocif-0.1.40 → geocif-0.1.41}/geocif/experiments.py +20 -8
  3. {geocif-0.1.40 → geocif-0.1.41}/geocif/geocif.py +13 -5
  4. {geocif-0.1.40 → geocif-0.1.41}/geocif/indices_runner_v2.py +1 -1
  5. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/feature_engineering.py +1 -1
  6. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/output.py +2 -0
  7. {geocif-0.1.40 → geocif-0.1.41}/geocif/utils.py +1 -1
  8. {geocif-0.1.40 → geocif-0.1.41/geocif.egg-info}/PKG-INFO +1 -1
  9. {geocif-0.1.40 → geocif-0.1.41}/setup.py +1 -1
  10. {geocif-0.1.40 → geocif-0.1.41}/LICENSE +0 -0
  11. {geocif-0.1.40 → geocif-0.1.41}/MANIFEST.in +0 -0
  12. {geocif-0.1.40 → geocif-0.1.41}/README.md +0 -0
  13. {geocif-0.1.40 → geocif-0.1.41}/geocif/__init__.py +0 -0
  14. {geocif-0.1.40 → geocif-0.1.41}/geocif/agmet/__init__.py +0 -0
  15. {geocif-0.1.40 → geocif-0.1.41}/geocif/agmet/geoagmet.py +0 -0
  16. {geocif-0.1.40 → geocif-0.1.41}/geocif/agmet/plot.py +0 -0
  17. {geocif-0.1.40 → geocif-0.1.41}/geocif/agmet/utils.py +0 -0
  18. {geocif-0.1.40 → geocif-0.1.41}/geocif/analysis.py +0 -0
  19. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/__init__.py +0 -0
  20. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/constants.py +0 -0
  21. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/features.py +0 -0
  22. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/geo.py +0 -0
  23. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/geocif.py +0 -0
  24. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/metadata.py +0 -0
  25. {geocif-0.1.40 → geocif-0.1.41}/geocif/backup/models.py +0 -0
  26. {geocif-0.1.40 → geocif-0.1.41}/geocif/cei/__init__.py +0 -0
  27. {geocif-0.1.40 → geocif-0.1.41}/geocif/cei/definitions.py +0 -0
  28. {geocif-0.1.40 → geocif-0.1.41}/geocif/cei/indices.py +0 -0
  29. {geocif-0.1.40 → geocif-0.1.41}/geocif/indices_runner.py +0 -0
  30. {geocif-0.1.40 → geocif-0.1.41}/geocif/logger.py +0 -0
  31. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/__init__.py +0 -0
  32. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/correlations.py +0 -0
  33. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/correlations_backup.py +0 -0
  34. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/embedding.py +0 -0
  35. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/feature_selection.py +0 -0
  36. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/outliers.py +0 -0
  37. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/outlook.py +0 -0
  38. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/spatial_autocorrelation.py +0 -0
  39. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/stages.py +0 -0
  40. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/stats.py +0 -0
  41. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/trainers.py +0 -0
  42. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/trend.py +0 -0
  43. {geocif-0.1.40 → geocif-0.1.41}/geocif/ml/xai.py +0 -0
  44. {geocif-0.1.40 → geocif-0.1.41}/geocif/playground/__init__.py +0 -0
  45. {geocif-0.1.40 → geocif-0.1.41}/geocif/playground/automl.py +0 -0
  46. {geocif-0.1.40 → geocif-0.1.41}/geocif/playground/misc.py +0 -0
  47. {geocif-0.1.40 → geocif-0.1.41}/geocif/viz/__init__.py +0 -0
  48. {geocif-0.1.40 → geocif-0.1.41}/geocif/viz/plot.py +0 -0
  49. {geocif-0.1.40 → geocif-0.1.41}/geocif.egg-info/SOURCES.txt +0 -0
  50. {geocif-0.1.40 → geocif-0.1.41}/geocif.egg-info/dependency_links.txt +0 -0
  51. {geocif-0.1.40 → geocif-0.1.41}/geocif.egg-info/not-zip-safe +0 -0
  52. {geocif-0.1.40 → geocif-0.1.41}/geocif.egg-info/top_level.txt +0 -0
  53. {geocif-0.1.40 → geocif-0.1.41}/requirements.txt +0 -0
  54. {geocif-0.1.40 → geocif-0.1.41}/setup.cfg +0 -0
  55. {geocif-0.1.40 → geocif-0.1.41}/tests/test_geocif.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.40
3
+ Version: 0.1.41
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
@@ -53,13 +53,25 @@ def run(path_config_files=[Path("../config/geocif.txt")]):
53
53
  logger.info("\tStarting GEOCIF Experiments")
54
54
  logger.info("=============================")
55
55
 
56
- # Experiment 1: include_lat_lon
56
+ # Experiment: Models
57
+ logger.info("Experiment 0: Models")
58
+ parser = main(
59
+ inputs,
60
+ logger,
61
+ parser,
62
+ "DEFAULT",
63
+ "model",
64
+ "str",
65
+ ["catboost", "merf", "linear"],
66
+ )
67
+
68
+ # Experiment: include_lat_lon
57
69
  logger.info("Experiment 1: include_lat_lon")
58
70
  parser = main(
59
71
  inputs, logger, parser, "ML", "include_lat_lon", "bool", [True, False]
60
72
  )
61
73
 
62
- # Experiment 2: feature_selection
74
+ # Experiment: feature_selection
63
75
  logger.info("Experiment 2: feature_selection")
64
76
  parser = main(
65
77
  inputs,
@@ -71,13 +83,13 @@ def run(path_config_files=[Path("../config/geocif.txt")]):
71
83
  ["SelectKBest", "BorutaPy", "Leshy", "RFECV", "RFE"],
72
84
  )
73
85
 
74
- # Experiment 3: lag_years
86
+ # Experiment: lag_years
75
87
  logger.info("Experiment 3: lag_years")
76
88
  parser = main(
77
89
  inputs, logger, parser, "ML", "lag_years", "int", [1, 2, 3, 4, 5]
78
90
  )
79
91
 
80
- # Experiment 4: lag_yield_as_feature
92
+ # Experiment: lag_yield_as_feature
81
93
  logger.info("Experiment 4: lag_yield_as_feature")
82
94
  parser = main(
83
95
  inputs,
@@ -89,13 +101,13 @@ def run(path_config_files=[Path("../config/geocif.txt")]):
89
101
  [True, False],
90
102
  )
91
103
 
92
- # Experiment 5: median_years
104
+ # Experiment: median_years
93
105
  logger.info("Experiment 5: median_years")
94
106
  parser = main(
95
107
  inputs, logger, parser, "ML", "median_years", "int", [2, 3, 4, 5]
96
108
  )
97
109
 
98
- # Experiment 6: median_yield_as_feature
110
+ # Experiment: median_yield_as_feature
99
111
  logger.info("Experiment 6: median_yield_as_feature")
100
112
  parser = main(
101
113
  inputs,
@@ -107,7 +119,7 @@ def run(path_config_files=[Path("../config/geocif.txt")]):
107
119
  [True, False],
108
120
  )
109
121
 
110
- # Experiment 7: analogous_year_yield_as_feature
122
+ # Experiment: analogous_year_yield_as_feature
111
123
  logger.info("Experiment 7: analogous_year_yield_as_feature")
112
124
  parser = main(
113
125
  inputs,
@@ -119,7 +131,7 @@ def run(path_config_files=[Path("../config/geocif.txt")]):
119
131
  [True, False],
120
132
  )
121
133
 
122
- # Experiment 8: optimize
134
+ # Experiment: optimize
123
135
  logger.info("Experiment 8: optimize")
124
136
  parser = main(
125
137
  inputs, logger, parser, "DEFAULT", "optimize", "bool", [True, False]
@@ -132,6 +132,9 @@ class Geocif:
132
132
  self.median_yield_as_feature = self.parser.getboolean(
133
133
  "ML", "median_yield_as_feature"
134
134
  )
135
+ self.median_area_as_feature = self.parser.getboolean(
136
+ "ML", "median_area_as_feature"
137
+ )
135
138
  self.number_lag_years = self.parser.getint("ML", "lag_years")
136
139
  self.cluster_strategy = self.parser.get("ML", "cluster_strategy")
137
140
  self.feature_selection = self.parser.get("ML", "feature_selection")
@@ -736,10 +739,15 @@ class Geocif:
736
739
  df = fe.compute_last_year_yield(df)
737
740
 
738
741
  if self.median_yield_as_feature:
739
- df = fe.compute_median_yield(
742
+ df = fe.compute_median_statistics(
740
743
  df, self.all_seasons_with_yield, self.number_median_years
741
744
  )
742
745
 
746
+ if self.median_area_as_feature:
747
+ df = fe.compute_median_statistics(
748
+ df, self.all_seasons_with_area, self.number_median_years, "Area (ha)"
749
+ )
750
+
743
751
  if self.lag_yield_as_feature:
744
752
  df = fe.compute_lag_yield(
745
753
  df, self.all_seasons_with_yield, self.number_lag_years
@@ -1107,6 +1115,10 @@ def loop_execute(inputs):
1107
1115
  with PyCallGraph(output=graphviz, config=config):
1108
1116
  country, crop, season, model, logger, parser = inputs
1109
1117
 
1118
+ logger.info("=====================================================")
1119
+ logger.info(f"\tStarting GEOCIF: {country} {crop} {season} {model}")
1120
+ logger.info("=====================================================")
1121
+
1110
1122
  obj = Geocif(logger=logger, parser=parser)
1111
1123
  obj.read_data(country, crop, season)
1112
1124
 
@@ -1178,10 +1190,6 @@ def main(logger, parser):
1178
1190
  Returns:
1179
1191
 
1180
1192
  """
1181
- logger.info("===========================")
1182
- logger.info("\tStarting GEOCIF")
1183
- logger.info("===========================")
1184
-
1185
1193
  inputs = gather_inputs(parser)
1186
1194
  execute_models(inputs, logger, parser)
1187
1195
 
@@ -157,7 +157,7 @@ class cei_runner(base.BaseGeo):
157
157
  "ndvi",
158
158
  False, # redo
159
159
  )
160
- for year in range(2024, ar.utcnow().year + 1)
160
+ for year in range(2001, ar.utcnow().year + 1)
161
161
  for status, path, filename, admin_zone, category in combinations
162
162
  ]
163
163
 
@@ -62,7 +62,7 @@ def compute_closest_years(all_years, harvest_year, number_lag_years):
62
62
  return closest_years.tolist()
63
63
 
64
64
 
65
- def compute_median_yield(
65
+ def compute_median_statistics(
66
66
  df, all_seasons_with_yield, number_median_years, target_col="Yield (tn per ha)"
67
67
  ):
68
68
  """
@@ -107,6 +107,7 @@ def store(db_path, experiment_id, df, model, model_name):
107
107
  try:
108
108
  utils.to_db(db_path, experiment_id, df)
109
109
  except Exception as e:
110
+ breakpoint()
110
111
  print(f"Error: {e}")
111
112
 
112
113
  index_columns = ["Country", "Region", "Crop", "Harvest Year", "Stages"]
@@ -127,6 +128,7 @@ def store(db_path, experiment_id, df, model, model_name):
127
128
  df_model.index.set_names(["Index"], inplace=True)
128
129
  utils.to_db(db_path, "models", df_model)
129
130
  except Exception as e:
131
+ breakpoint()
130
132
  print(f"Error: {e}")
131
133
 
132
134
  con.commit()
@@ -332,7 +332,7 @@ def create_output_directory(method, admin_zone, country, crop, path_output):
332
332
 
333
333
  :return:
334
334
  """
335
- dir_output = path_output / "fao" / "indices" / method / admin_zone / country / crop
335
+ dir_output = path_output / "cei" / "indices" / method / admin_zone / country / crop
336
336
  os.makedirs(dir_output, exist_ok=True)
337
337
 
338
338
  return dir_output
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.40
3
+ Version: 0.1.41
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.40",
53
+ version="0.1.41",
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