text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import pandas as pd
import numpy as np
import re
import math
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import metrics
from scipy import stats
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LassoCV
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing import PolynomialFeatures
from sklearn.ensemble import GradientBoostingRegressor
df = pd.read_csv('../input/Melbourne_housing_FULL.csv')

change_objects = ['Suburb', 'Address', 'Type', 'Method', 'SellerG', 'CouncilArea', 'Regionname']
for colname in change_objects:
    df[colname] = df[colname].astype('category')
change_numeric = ['Postcode']
for colname in change_numeric:
    df[colname] = df[colname].astype('category')
df['Date'] = pd.to_datetime(df['Date'])

df['Rooms v Bedroom2'] = df['Rooms'] - df['Bedroom2']

df = df.drop(['Bedroom2', 'Rooms v Bedroom2'], 1)

df = df[df['BuildingArea'] != 0]
df = df[df['YearBuilt'] > 1835]

df.isnull().sum()

df.dropna(inplace=True)

# Build Histogram to visualise price distribution
num_bins = 50
n, bins, patches = plt.hist(df.Price, num_bins, color='b', alpha=0.5, histtype = 'bar', ec = 'black')
plt.ylabel ('Frequency')
plt.xlabel ('Price ($)')
plt.xlim([0, 6000000])
plt.title ('Histogram House Prices')
plt.show()
plt.savefig('Histogram.png')

# Determine Numerical Values
df.select_dtypes(['float64', 'int64']).columns

# Pairplot variables to visualise inter-variable relationships
pair_plot = sns.pairplot(df[['Rooms', 'Price', 'Distance', 'Bathroom', 'Car', 'Landsize','BuildingArea', 'Propertycount', 'YearBuilt', 'Type']], hue = 'Type')
pair_plot.savefig('Pairplot.png')

df.info()