ionic_liquids/utils.py
def train_model(model, data_file, test_percent, save=True):
    """
    Choose the regression model

    Input
    ------
    model: string, the model to use
    data_file: dataframe, cleaned csv data
    test_percent: float, the percentage of data held for testing

    Returns
    ------
    obj: objective, the regressor
    X: dataframe, normlized input feature
    y: targeted electrical conductivity

    """
    df, y_error = read_data(data_file)
    X, y = molecular_descriptors(df)
    X_train, X_test, y_train, y_test = \
        train_test_split(X, y, test_size=(test_percent/100))
    X_train, X_mean, X_std = normalization(X_train)

    model = model.replace(' ', '_')
    # print("training model is ",model)
    if (model.lower() == 'lasso'):
        obj = methods.do_lasso(X_train, y_train)
    elif (model.lower() == 'mlp_regressor'):
        obj = methods.do_MLP_regressor(X_train, y_train)
    elif (model.lower() == 'svr'):
        obj = methods.do_svr(X_train, y_train)
    else:
        raise ValueError('Invalid model type!')

    return obj, X_train, y_train, X_mean, X_std

    Choose the regression model

    Input
    ------
    model: string, the model to use
    data_file: dataframe, cleaned csv data
    test_percent: float, the percentage of data held for testing

    Returns
    ------
    obj: objective, the regressor
    X: dataframe, normlized input feature
    y: targeted electrical conductivity

    
Choose the regression model
Input

string, the model to use
data_file: dataframe, cleaned csv data
test_percent: float, the percentage of data held for testing

Returns

objective, the regressor
X: dataframe, normlized input feature
y: targeted electrical conductivity
Choose the regression model Input string the model to use data_file : dataframe cleaned csv data test_percent : float the percentage of data held for testing Returns objective the regressor X : dataframe normlized input feature y : targeted electrical conductivity
def train_model(model, data_file, test_percent, save=True):
    df, y_error = read_data(data_file)
    X, y = molecular_descriptors(df)
    X_train, X_test, y_train, y_test = \
        train_test_split(X, y, test_size=(test_percent/100))
    X_train, X_mean, X_std = normalization(X_train)
    model = model.replace(' ', '_')
    if (model.lower() == 'lasso'):
        obj = methods.do_lasso(X_train, y_train)
    elif (model.lower() == 'mlp_regressor'):
        obj = methods.do_MLP_regressor(X_train, y_train)
    elif (model.lower() == 'svr'):
        obj = methods.do_svr(X_train, y_train)
    else:
        raise ValueError('Invalid model type!')
    return obj, X_train, y_train, X_mean, X_std
def train_model ( model , data_file , test_percent , save = True ) : df , y_error = read_data ( data_file ) X , y = molecular_descriptors ( df ) X_train , X_test , y_train , y_test = train_test_split ( X , y , test_size = ( test_percent / 100 ) ) X_train , X_mean , X_std = normalization ( X_train ) model = model . replace ( ' ' , '_' ) if ( model . lower ( ) == 'lasso' ) : obj = methods . do_lasso ( X_train , y_train ) elif ( model . lower ( ) == 'mlp_regressor' ) : obj = methods . do_MLP_regressor ( X_train , y_train ) elif ( model . lower ( ) == 'svr' ) : obj = methods . do_svr ( X_train , y_train ) else : raise ValueError ( 'Invalid model type!' ) return obj , X_train , y_train , X_mean , X_std
Choose the regression model
Input
Choose the regression model Input
"""
    Choose the regression model

    Input
    ------
    model: string, the model to use
    data_file: dataframe, cleaned csv data
    test_percent: float, the percentage of data held for testing

    Returns
    ------
    obj: objective, the regressor
    X: dataframe, normlized input feature
    y: targeted electrical conductivity

    """ # print("training model is ",model)
model
data_file
test_percent
save