# ---
# 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 numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

import env
import eval_model
import wrangle3


from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.cluster import KMeans
from sklearn.preprocessing import MinMaxScaler, RobustScaler
from sklearn.model_selection import train_test_split
import warnings
warnings.filterwarnings('ignore')


pd.set_option("display.max_columns", None)
pd.set_option("display.max_rows", 100)
pd.set_option('display.float_format', lambda x: '%.5f' % x)



import gmaps
import gmaps.datasets

gmaps.configure(api_key="<KEY>")


#Modeling Tools
from sklearn.model_selection import train_test_split
from sklearn.impute import SimpleImputer
import statsmodels.api as sm
from statsmodels.formula.api import ols

from datetime import date
from scipy import stats


## Evaluation tools
from sklearn.metrics import mean_squared_error
from sklearn.metrics import r2_score
from math import sqrt

# -

train, X_train, y_train, X_validate, y_validate, X_test, y_test=wrangle3.wrangle()


X_train.head()

X_validate.head()

# Target: Logerror

y_train

plt.figure(figsize=(8,6))
plt.scatter(range(y_train.shape[0]), np.sort(y_train.values))
plt.xlabel('index', fontsize=12)
plt.ylabel('logerror', fontsize=12)
plt.show()

# +
#Remove outliers

ulimit = np.percentile(y_train.values, 99)
llimit = np.percentile(y_train.values, 1)
train_df['logerror'].ix[train_df['logerror']>ulimit] = ulimit
train_df['logerror'].ix[train_df['logerror']<llimit] = llimit
# -



plt.figure(figsize=(12,8))
plot = sns.distplot(y_train.values, bins=50, kde=False)
plt.xlabel('logerror', fontsize=12)
plot.set(xlim=(-.5,.5))
plt.show()



StarcoderdataJupyterScriptsDedupFiltered