Exemplo n.º 1
0
def prediction():
    if request.method == 'POST':
        data = [int(x) for x in request.form.values()]
        data = np.array([data])
        print(data)
        data_df = pd.DataFrame(
            data=data, columns=["YearBuilt", "BedroomAbvGr", "KitchenAbvGr"])
        # data_df = pd.DataFrame()
        # data_df["YearBuilt"] = data[0]
        # data_df["BedroomAbvGr"] = data[1]
        # data_df["KitchenAbvGr"] = data[2]
        print("data frame after assigning values", data_df.head())
        # data preprocessing
        data_df = data_preprocessing(data_df)
        data_df["SalePrice"] = 0

        # feature extractor
        features, label = feature_extractor(data_df)
        model = read_model("output/model.pkl")
        label = predict_price(features, model)
        print(label)
        return render_template(
            'houseprice.html',
            predicted_house_price='House Price should be $ {}'.format(
                label[0][0]))
    else:
        return render_template('houseprice.html')
Exemplo n.º 2
0
if __name__ == '__main__':
    message = "defining stubs"
    print(message)
    # read data
    data = pd.read_csv(dataset_path)
    print(data.shape)
    print(data.head(5))

    # data selection
    data = data_selection(data, selected_variables)
    print(data.shape)
    print(data.head(5))

    # data preprocessing
    data = data_preprocessing(data)
    print(data.shape)
    print(data.head(5))

    data[target_varibale[0]] = 0
    print(data.shape)
    print(data.head(5))

    # feature extractor
    featueres, label = feature_extractor(data)
    print(featueres.shape)
    print(featueres.head(5))
    print(label.shape)
    print(label.head(5))

    model = read_model(model_path)