src/random_forest.py
def train_random_forest(final_df):
    '''
    This function accepts a dataframe as an input and train the machine using
    this data on randomforest algorithm to generate a model and returns the model.

    Arg1 : dataframe on which model has to be trained.
    '''

    print('********* inside training random forest **************')
    print('********* inside training random forest ************')
    print('********* inside training random forest ************')


    rf = RandomForestClassifier(labelCol = "label", featuresCol = "indexedFeatures", numTrees = 20, maxDepth = 8, maxBins = 32)
    #training the model
    rfModel = rf.fit(final_df)

    print('********** returning from random forest *************')
    print('********** returning from random forest *************')
    print('********** returning from random forest *************')


    return rfModel

    This function accepts a dataframe as an input and train the machine using
    this data on randomforest algorithm to generate a model and returns the model.

    Arg1 : dataframe on which model has to be trained.
    
This function accepts a dataframe as an input and train the machine using
this data on randomforest algorithm to generate a model and returns the model.

Arg1 : dataframe on which model has to be trained.
This function accepts a dataframe as an input and train the machine using this data on randomforest algorithm to generate a model and returns the model . Arg1 : dataframe on which model has to be trained .
def train_random_forest(final_df):
    print('********* inside training random forest **************')
    print('********* inside training random forest ************')
    print('********* inside training random forest ************')
    rf = RandomForestClassifier(labelCol = "label", featuresCol = "indexedFeatures", numTrees = 20, maxDepth = 8, maxBins = 32)
    rfModel = rf.fit(final_df)
    print('********** returning from random forest *************')
    print('********** returning from random forest *************')
    print('********** returning from random forest *************')
    return rfModel
def train_random_forest ( final_df ) : print ( '********* inside training random forest **************' ) print ( '********* inside training random forest ************' ) print ( '********* inside training random forest ************' ) rf = RandomForestClassifier ( labelCol = "label" , featuresCol = "indexedFeatures" , numTrees = 20 , maxDepth = 8 , maxBins = 32 ) rfModel = rf . fit ( final_df ) print ( '********** returning from random forest *************' ) print ( '********** returning from random forest *************' ) print ( '********** returning from random forest *************' ) return rfModel
This function accepts a dataframe as an input and train the machine using
this data on randomforest algorithm to generate a model and returns the model.
This function accepts a dataframe as an input and train the machine using this data on randomforest algorithm to generate a model and returns the model .
'''
    This function accepts a dataframe as an input and train the machine using
    this data on randomforest algorithm to generate a model and returns the model.

    Arg1 : dataframe on which model has to be trained.
    ''' #training the model
final_df