dssg / police-eis

DSaPP police early intervention system: using machine learning to predict adverse incidents
Other
50 stars 20 forks source link

Clean run_models.py #224

Open nanounanue opened 7 years ago

nanounanue commented 7 years ago

I am just pasting two pending review request from PR #223

(NOTE: Both requests are for run_models.py lines 457-460)

  1. I think is a better idea not to hard code the number of individual features, maybe we chould add this as an argument to the method, so, the code will be:
result = pd.DataFrame(columns=['risk_%i'%i for i in range(1, num_of_individual_features + 1)])
  1. You don't need to concatenate (is not the recommended way of doing this), you could create a list of tuples and then creating the pandas DataFrame (and you could remove the previous comment... but this needs more careful thinking, so you could leave this code here in this version.

For reference see: https://stackoverflow.com/questions/28056171/how-to-build-and-fill-pandas-dataframe-from-for-loop