Skip to content

Instantly share code, notes, and snippets.

@TavoGLC
Created April 29, 2020 18:10
Show Gist options
  • Select an option

  • Save TavoGLC/69d6f3225524c77ee5e182ddae6fff73 to your computer and use it in GitHub Desktop.

Select an option

Save TavoGLC/69d6f3225524c77ee5e182ddae6fff73 to your computer and use it in GitHub Desktop.
def TrainOnPopulation(TotalFeatures,Data,Size):
"""
Parameters
----------
TotalFeatures : List
List with the names of the categorical values in the data.
Data : Pandas dataframe
Training data for the model.
Size : int
Number of models to be trained.
Returns
-------
FitnessContainer : list
Contains the ROC AUC score for each model.
IndexContainer : list
Contains the categorical features used for the model.
"""
maxFeatures=len(TotalFeatures)
PopulationIndex=MakeRandomSizePopulation(maxFeatures,Size)
IndexContainer=[]
FitnessContainer=[]
for k in range(Size):
localIndex=PopulationIndex[k]
localFeatures=[TotalFeatures[val]for val in localIndex]
FitnessContainer.append(TrainModel(localFeatures,Data))
IndexContainer.append(localIndex)
return FitnessContainer,IndexContainer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment