Exemplo n.º 1
0
def test_data_random_forest():
    #fetch all the zipcodes for project
    zip_list = fetch_zip()
    #zip_list = fetch_all_zip()
    
    model = build.build_random_forest_model()
    for zipcode in zip_list:
        prediction, prediction_df = predict.run_model_for_prediction(zipcode, model)
        string = str(zipcode) + "," + prediction[0]
        print(string)
Exemplo n.º 2
0
def test_data_gaussian():
    #fetch all the zipcodes for project
    zip_list = fetch_zip()
    #zip_list = fetch_all_zip()
    
    #Train over Gaussian NB model
    model = build.build_gaussian_model()
    for zipcode in zip_list:
        prediction, prediction_df = predict.run_model_for_prediction(zipcode, model)
        string = str(zipcode) + "," + prediction[0]
        print(string)
Exemplo n.º 3
0
def app(zipcode, radius):
    start_time = time.time()
    
    #1. populate data in model_data for given radius
    #good data
    #good.populateData(radius, 'Y')
    #bad data
    #bad.populateData(radius, 'N')
    
    #2. Build model and train it
    model = build.build_random_forest_model()
    
    #3. Test model for given zipcode and radius
    prediction, prediction_df = predict.run_model_for_prediction(zipcode, model, radius)
    
    #if prediction is Yes 
    #check for elevation data
    if prediction[0] == 'Y':
        #elevation_data = attr.fetch_elevation_data(zipcode)
        #fetch water data
        water_data = attr.fetch_water_data(zipcode)
        #fetch water rules
        earthquake_data = attr.fetch_earthquake_data(zipcode)
        #fetch rules for drilling oil reserves
        rules = attr.fetch_rules()
        
        #make result object
        resultData = result_data(water_data, None, 
                                 earthquake_data, rules, prediction_df, prediction[0], zipcode)
    else:
        resultData = result_data(None, None, None, None, prediction_df, prediction[0],
                                 zipcode)
        #print(prediction[0])
    
    #print execution time
    print("--- %s seconds ---" % (time.time() - start_time))
        
    return resultData