Last active
September 3, 2018 18:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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