Open vjugor1 opened 1 year ago
Don't forget to delete old commented code (like here), or store it somewhere else
Another minor comment, within src.utils
keep to the same name convention: if you use variable name clf
in one function, do not use variable name model
for the same substance in another place
src.utils
docstring for this function looks outdates (missing one argument). This makes the unclear what does out_meta.update
method
Stopped here, will continue
crop_country
does not return anything, however, docstring stats that it should return 3 .tif
s. Seems like this function saves the results to a file. Please, change the dostring.
The same with crop_raster
yield_rolling_mean
I would rather divide split it into two. Something like 1 - read_faostat_rice_production
, 2 - prepare_rolling_mean
Here, when you do plt.show()
, it is more practical to omit it. By calling this method, you finalize and close to edit this figure. That might be inconvenient if you want to further update it in notebook.
Magical constant 5, please infer 5
from some argument
Why years[1]
here?
Seems like [const_2
]
(https://github.com/DariaTan/ArableLand2/blob/479cda1a21ce3570db363f79b0b08a2835d3ec5a/src/utils.py#L498) is redundant to have inside the nested loop. Moreover, considering the definition of const_array_0
, const_array_1
, const_array_2
, it is not clear why are they under loop over prefix
, since, for each iteration, you assemble them over the full set of prefix
es.
-Please, change the loop variable name prefix
or do not use variable name prefix
inside list comprehension in this loop, e.g., here. It is 1. misleading, 2. dangerous - something can be overwritten
Please rewrite this function fully, considering the advises above. At best, this function will be more time and resource efficient, at worst, we will locale a bug here. We can discuss it if you want, I might be wrong on some points.
The same applied for collect_future_data
Stopped at this
Why
years[1]
here? It happens because rolling mean procedure turns first and last values to nan. We should kinda drop themSeems like [
const_2
] ) is redundant to have inside the nested loop. Moreover, considering the definition ofconst_array_0
,const_array_1
,const_array_2
, it is not clear why are they under loop overprefix
, since, for each iteration, you assemble them over the full set ofprefix
es.Well, I can believe it looks ugly a bit. It is literally one hot encoding done by hand. Arrays are defined inside the loop since they are set of zeros. When we use them as features for object, you put 1 to the column related with the country (prefix here)
src.utils
neg_trend
It is not quite quite clear who is neg_trend
. Could you please elaborate on it in docstring or in a comment above the usage of it in the code?'2018'
It is better to move '2018'
here and here to the arguments of the function. It will make the code a) more flexible; b) clearersrc.models.crop_classifier.py
np.ndarray
(provided you have imported numpy as follows: import numpy as np
. As a convention, number of dimensions in this array should be mentioned after ':'.
By the way, you can state the argument types in the definition of function, e.g., def foo(x: int, y: int):
. In this case, docstring generators will automatically infer the information about the arguments type and mention it in the docstring in a proper way.params_xgb
It better to pass this as an argument of this function. You can make this parameters to be present by default, thus, you won't need change anything in you code further.params_skf
- similar commentparams_gs
- similar commentclassifier.model
This methods looks like a constructor, consider erasing this one and moving the functionality into the __init__
.src.models.fert_regression.py
train_pred_future_fert
and changed the docstring accordingly. At the moment of posting this, it says that this function create a model for each years, thus the name of the function and the docstring is misleading.fontsize
from hardcoded 14
here to the arguments of the model
functionI am moving to notebooks
README.md
diverse.py
Markdown
Dockerfile
Please wrap all your code into docker container
requirements.txt
-- see hereREADME.md
with docker instructionsnotebook_crop.ipynb
.py
file (incapsulate)notebook_yield.ipynb
Data
'.pkl' files
notebook_yield.ipynb
, mention it inREADME.md