models/train_classifier.py
def load_data(database_filepath):
    """
    Load data from a SQL db, oversample the minor categories and return data ready to model.
    :param database_filepath:
    :return:
    X: Array. Array with messages to use as input
    Y: Array. Array containing labels
    categories: List. List of strings containing names for each column of 'Y'
    """
    # load data from database
    engine = create_engine('sqlite:///' + str(database_filepath))
    df = pd.read_sql_table('message', con=engine)

    print("Oversampling Data...")
    df = oversample_nlp(df)

    # Drop Duplicates
    df.drop_duplicates(inplace=True)

    X = df['message']
    Y = df.drop(columns=['id', 'message', 'original', 'genre'], axis=1)
    for column in Y.columns:
        Y[column] = pd.to_numeric(Y[column])
    categories = list(Y.columns)

    return X, Y, categories

    Load data from a SQL db, oversample the minor categories and return data ready to model.
    :param database_filepath:
    :return:
    X: Array. Array with messages to use as input
    Y: Array. Array containing labels
    categories: List. List of strings containing names for each column of 'Y'
    
Load data from a SQL db, oversample the minor categories and return data ready to model.
Load data from a SQL db oversample the minor categories and return data ready to model .
def load_data(database_filepath):
    engine = create_engine('sqlite:///' + str(database_filepath))
    df = pd.read_sql_table('message', con=engine)
    print("Oversampling Data...")
    df = oversample_nlp(df)
    df.drop_duplicates(inplace=True)
    X = df['message']
    Y = df.drop(columns=['id', 'message', 'original', 'genre'], axis=1)
    for column in Y.columns:
        Y[column] = pd.to_numeric(Y[column])
    categories = list(Y.columns)
    return X, Y, categories
def load_data ( database_filepath ) : engine = create_engine ( 'sqlite:///' + str ( database_filepath ) ) df = pd . read_sql_table ( 'message' , con = engine ) print ( "Oversampling Data..." ) df = oversample_nlp ( df ) df . drop_duplicates ( inplace = True ) X = df [ 'message' ] Y = df . drop ( columns = [ 'id' , 'message' , 'original' , 'genre' ] , axis = 1 ) for column in Y . columns : Y [ column ] = pd . to_numeric ( Y [ column ] ) categories = list ( Y . columns ) return X , Y , categories
Load data from a SQL db, oversample the minor categories and return data ready to model.
Load data from a SQL db oversample the minor categories and return data ready to model .
"""
    Load data from a SQL db, oversample the minor categories and return data ready to model.
    :param database_filepath:
    :return:
    X: Array. Array with messages to use as input
    Y: Array. Array containing labels
    categories: List. List of strings containing names for each column of 'Y'
    """ # load data from database # Drop Duplicates
Array. Array with messages to use as input
Y: Array. Array containing labels
categories: List. List of strings containing names for each column of 'Y'
Array . Array with messages to use as input Y : Array . Array containing labels categories : List . List of strings containing names for each column of ' Y '
database_filepath
None