models/train_classifier.py
def build_model():
    ''' This function is the training model. It uses a pipeline object to group the transformers and predictors together. 
    
    These are the CountVectorizer, TfidfTransformer, and MultiOutputClassifier.
    
    As the dependent variable has multiple targets (i.e. many categorical columns),
    Using MultiOutputClassifier to run the RandomForestClassifier is a better fit for our ML model. 
    
    This function also makes use of the GridSearch method to improve the model.
    
    If the input is invalid or the data does not exist, this function will raise an error.
    
    INPUT:
    pipeline --> the ML model pipeline containing the transformers and predictor 
    parameters --> defined values for the GridSearch method
    
    OUTPUT:
    cv --> the created GridSearch object
    '''
    
    #First, we define the model pipeline
    pipeline = Pipeline([
        ('vect', CountVectorizer(tokenizer=tokenize)),
        ('tfidf', TfidfTransformer()),
        ('clf', MultiOutputClassifier(RandomForestClassifier()))
    ])
    
    #Next, we specify parameters for the GridSearch method
    parameters = {
        'vect__max_features': [None, 100, 1000]
    }

    #Now, we create a GridSearch object to return
    cv = GridSearchCV(pipeline, param_grid=parameters)
    
    return cv
 This function is the training model. It uses a pipeline object to group the transformers and predictors together. 
    
    These are the CountVectorizer, TfidfTransformer, and MultiOutputClassifier.
    
    As the dependent variable has multiple targets (i.e. many categorical columns),
    Using MultiOutputClassifier to run the RandomForestClassifier is a better fit for our ML model. 
    
    This function also makes use of the GridSearch method to improve the model.
    
    If the input is invalid or the data does not exist, this function will raise an error.
    
    INPUT:
    pipeline --> the ML model pipeline containing the transformers and predictor 
    parameters --> defined values for the GridSearch method
    
    OUTPUT:
    cv --> the created GridSearch object
    
This function is the training model. It uses a pipeline object to group the transformers and predictors together.

As the dependent variable has multiple targets ,
Using MultiOutputClassifier to run the RandomForestClassifier is a better fit for our ML model.

This function also makes use of the GridSearch method to improve the model.

If the input is invalid or the data does not exist, this function will raise an error.

-> the ML model pipeline containing the transformers and predictor
parameters --> defined values for the GridSearch method

-> the created GridSearch object
This function is the training model . It uses a pipeline object to group the transformers and predictors together . As the dependent variable has multiple targets Using MultiOutputClassifier to run the RandomForestClassifier is a better fit for our ML model . This function also makes use of the GridSearch method to improve the model . If the input is invalid or the data does not exist this function will raise an error . - > the ML model pipeline containing the transformers and predictor parameters -- > defined values for the GridSearch method - > the created GridSearch object
def build_model():
    pipeline = Pipeline([
        ('vect', CountVectorizer(tokenizer=tokenize)),
        ('tfidf', TfidfTransformer()),
        ('clf', MultiOutputClassifier(RandomForestClassifier()))
    ])
    parameters = {
        'vect__max_features': [None, 100, 1000]
    }
    cv = GridSearchCV(pipeline, param_grid=parameters)
    return cv
def build_model ( ) : pipeline = Pipeline ( [ ( 'vect' , CountVectorizer ( tokenizer = tokenize ) ) , ( 'tfidf' , TfidfTransformer ( ) ) , ( 'clf' , MultiOutputClassifier ( RandomForestClassifier ( ) ) ) ] ) parameters = { 'vect__max_features' : [ None , 100 , 1000 ] } cv = GridSearchCV ( pipeline , param_grid = parameters ) return cv
This function is the training model.
This function is the training model .
''' This function is the training model. It uses a pipeline object to group the transformers and predictors together. 
    
    These are the CountVectorizer, TfidfTransformer, and MultiOutputClassifier.
    
    As the dependent variable has multiple targets (i.e. many categorical columns),
    Using MultiOutputClassifier to run the RandomForestClassifier is a better fit for our ML model. 
    
    This function also makes use of the GridSearch method to improve the model.
    
    If the input is invalid or the data does not exist, this function will raise an error.
    
    INPUT:
    pipeline --> the ML model pipeline containing the transformers and predictor 
    parameters --> defined values for the GridSearch method
    
    OUTPUT:
    cv --> the created GridSearch object
    ''' #First, we define the model pipeline #Next, we specify parameters for the GridSearch method #Now, we create a GridSearch object to return