Skip to content

Instantly share code, notes, and snippets.

@Elsaveram
Last active September 3, 2018 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elsaveram/8ab62b2aaf35b8396c076b0132cad37f to your computer and use it in GitHub Desktop.
Save Elsaveram/8ab62b2aaf35b8396c076b0132cad37f to your computer and use it in GitHub Desktop.
Sample of the house class for Kaggle housing prices in Iowa blog post
class House():
def __init__(self, train_data_file, test_data_file):
train = pd.read_csv(train_data_file)
test = pd.read_csv(test_data_file)
self.all = pd.concat([train,test], ignore_index=True)
self.all['test'] = self.all.SalePrice.isnull()
def train(self):
return(self.all[~self.all['test']])
def test(self):
return(self.all[self.all['test']])
def log_transform(self, variable):
plt.figure(figsize=(10,5))
plt.subplot(1,2,1)
sns.distplot(variable, bins=50)
plt.title('Original')
plt.subplot(1,2,2)
sns.distplot(np.log1p(variable), bins=50)
plt.title('Log transformed')
plt.tight_layout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment