Example #1
0
def compare_IRR():
    print "Loading model..."
    try:
        model = load_from_pickle('pickle/model.pkl')
    except OSError, IOError:
        print "Model not found. Initializing training process, this might take some time..."
        model = initialize_model()
Example #2
0
def compare_IRR():
    print "Loading model..."
    try:
        model = load_from_pickle("pickle/model.pkl")
    except OSError, IOError:
        print "Model not found. Initializing training process, this might take some time..."
        model = initialize_model()
Example #3
0
def run_process():
    '''
    Main process for app, invoked when administrator is at /refresh. Collects, 
    processes and stores data, as well as calculates expected IRR and other
    metrics for data table and charts.

    Returns:
    Loan details to populate data table at /index. numpy array.
    '''
    print "Requesting loan details..."
    loan_results, loan_details = request_loan_data()

    print "Inserting results of API request to database..."
    try:
        insert_into_mongodb(loan_results, loan_details)
    except Exception:
        print "MongoDB error, proceeding to next step..."

    print "Loading model..."
    try:
        model = load_from_pickle('pickle/model.pkl')
    except OSError, IOError:
        print "Model not found. Initializing training process, this might take some time..."
        model = initialize_model()
Example #4
0
    df_raw = pd.concat((df_3c, df_3b), axis=0)

    print "Pre-processing data..."
    df = process_features(df_raw)

    print "Initializing model..."
    model = StatusModel(model=RandomForestRegressor,
                        parameters={
                            'n_estimators': 100,
                            'max_depth': 10
                        })

    print "Training model..."
    try:
        model = load_from_pickle('pickle/model.pkl')
    except OSError, IOError:
        print "Model not found. Training model, this might take some time..."
        model.train_model(df)
        dump_to_pickle(model, 'pickle/model.pkl')

    print "Calculating IRR..."
    int_rate_dict = {
        'A1': 0.0603,
        'A2': 0.0649,
        'A3': 0.0699,
        'A4': 0.0749,
        'A5': 0.0819,
        'B1': 0.0867,
        'B2': 0.0949,
        'B3': 0.1049,
Example #5
0
        df_3c = pd.read_csv("data/LoanStats3c_securev1.csv", header=True).iloc[:-2, :]
        df_3b = pd.read_csv("data/LoanStats3b_securev1.csv", header=True).iloc[:-2, :]
    except OSError, IOError:
        print "Training data not found. Please install from https://www.lendingclub.com/info/download-data.action"

    df_raw = pd.concat((df_3c, df_3b), axis=0)

    print "Pre-processing data..."
    df = process_features(df_raw)

    print "Initializing model..."
    model = StatusModel(model=RandomForestRegressor, parameters={"n_estimators": 100, "max_depth": 10})

    print "Training model..."
    try:
        model = load_from_pickle("pickle/model.pkl")
    except OSError, IOError:
        print "Model not found. Training model, this might take some time..."
        model.train_model(df)
        dump_to_pickle(model, "pickle/model.pkl")

    print "Calculating IRR..."
    int_rate_dict = {
        "A1": 0.0603,
        "A2": 0.0649,
        "A3": 0.0699,
        "A4": 0.0749,
        "A5": 0.0819,
        "B1": 0.0867,
        "B2": 0.0949,
        "B3": 0.1049,