# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# %matplotlib inline
import re
from pandas.plotting import scatter_matrix

from sklearn.linear_model import LinearRegression, Ridge, Lasso
from sklearn.pipeline import Pipeline
from sklearn.model_selection import train_test_split, KFold
from sklearn.preprocessing import StandardScaler
from sklearn.base import clone
from sklearn.metrics import mean_squared_error
import math

# %matplotlib inline
import matplotlib.pyplot as plt
# -

from src.clean_data import clean_df


def rmsle(actual, predictions):
    log_diff = np.log(predictions+1) - np.log(actual+1)
    return np.sqrt(np.mean(log_diff**2))


auction_train = pd.read_csv('data/Train.csv', low_memory=False)
auction_test = pd.read_csv('data/test.csv', low_memory=False)

clean_train = clean_df(auction_train)
clean_test = clean_df(auction_test)

clean_test.head()

example_output = pd.read_csv('data/Example_Output.csv')

end_of_day = pd.read_csv('data/end_of_day/test_actual.csv')

end_of_day.head()

y_train = np.array(clean_train['SalePrice'])
X_train = np.array(clean_train.drop(columns='SalePrice'))

model = Pipeline([('standardize', StandardScaler()),
                   ('regressor', Ridge())])

model.fit(X_train, y_train)

predicted_sale_price = model.predict(np.array(clean_test))

predicted_sale_price = math.e ** predicted_sale_price 

rmsle(end_of_day.loc[:,'SalePrice'],predicted_sale_price)



StarcoderdataJupyterScriptsDedupFiltered