models/train_classifier.py
def build_model():
    """
    Build and return a model.


    Returns:
    pipeline (sklearn pipeline): A pipeline to process text data
    """
    pipeline = Pipeline([
        ('vect', CountVectorizer(tokenizer=tokenize)),
        ('tfidf', TfidfTransformer()),
        ('clf', MultiOutputClassifier(
            RandomForestClassifier())) # the optmus values is 200, but it made the model too
                                   # big for heroku  
    ])
    
    parameters = {
        'vect__ngram_range': ((1, 1), (1, 2)),
        'vect__max_df': (0.5, 1.0),
        'vect__max_features': (None, 5000, 10000),
        'tfidf__use_idf': (True, False),
        'clf__estimator__n_estimators' : [50, 100, 200]
    }

    cv = GridSearchCV(pipeline, param_grid=parameters, verbose=3)
  
    return  cv

    Build and return a model.


    Returns:
    pipeline (sklearn pipeline): A pipeline to process text data
    
Build and return a model.
Build and return a model .
def build_model():
    pipeline = Pipeline([
        ('vect', CountVectorizer(tokenizer=tokenize)),
        ('tfidf', TfidfTransformer()),
        ('clf', MultiOutputClassifier(
            RandomForestClassifier())) 
    ])
    parameters = {
        'vect__ngram_range': ((1, 1), (1, 2)),
        'vect__max_df': (0.5, 1.0),
        'vect__max_features': (None, 5000, 10000),
        'tfidf__use_idf': (True, False),
        'clf__estimator__n_estimators' : [50, 100, 200]
    }
    cv = GridSearchCV(pipeline, param_grid=parameters, verbose=3)
    return  cv
def build_model ( ) : pipeline = Pipeline ( [ ( 'vect' , CountVectorizer ( tokenizer = tokenize ) ) , ( 'tfidf' , TfidfTransformer ( ) ) , ( 'clf' , MultiOutputClassifier ( RandomForestClassifier ( ) ) ) ] ) parameters = { 'vect__ngram_range' : ( ( 1 , 1 ) , ( 1 , 2 ) ) , 'vect__max_df' : ( 0.5 , 1.0 ) , 'vect__max_features' : ( None , 5000 , 10000 ) , 'tfidf__use_idf' : ( True , False ) , 'clf__estimator__n_estimators' : [ 50 , 100 , 200 ] } cv = GridSearchCV ( pipeline , param_grid = parameters , verbose = 3 ) return cv
Build and return a model.
Build and return a model .
"""
    Build and return a model.


    Returns:
    pipeline (sklearn pipeline): A pipeline to process text data
    """ # the optmus values is 200, but it made the model too # big for heroku  
None