<jupyter_start><jupyter_text>Fireup Graphlab create<jupyter_code>import graphlab<jupyter_output><empty_output><jupyter_text>Load some house sales data<jupyter_code>sales = graphlab.SFrame('home_data.gl/')
sales.save('home_sales.csv', format='csv')
sales<jupyter_output><empty_output><jupyter_text>Exploring the data for housing sales<jupyter_code>#graphlab.canvas.set_target('ipynb')
graphlab.canvas.set_target('browser')
sales.show(view="Scatter Plot", x="sqft_living", y="price")<jupyter_output>Canvas is accessible via web browser at the URL: http://localhost:49199/index.html
Opening Canvas in default web browser.<jupyter_text>Create simple regession model of sqft_living to price<jupyter_code>training_data, test_data = sales.random_split(.8, seed=0)<jupyter_output><empty_output><jupyter_text>Build the regression model<jupyter_code>sqft_model = graphlab.linear_regression.create(training_data, target='price', features=['sqft_living'])<jupyter_output>PROGRESS: Creating a validation set from 5 percent of training data. This may take a while.
          You can set ``validation_set=None`` to disable validation tracking.<jupyter_text>Evaluate the simple model<jupyter_code>print test_data['price'].mean()
print sqft_model.evaluate(test_data)<jupyter_output>{'max_error': 4156269.632260985, 'rmse': 255166.23936085022}<jupyter_text>Lets show what our predictions look like<jupyter_code>import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(test_data['sqft_living'], test_data['price'], '.', test_data['sqft_living'], sqft_model.predict(test_data), '-')
sqft_model.coefficients<jupyter_output><empty_output><jupyter_text>explore other features in the data<jupyter_code>my_features = ['bedrooms', 'bathrooms', 'sqft_living', 'sqft_lot', 'floors', 'zipcode']
sales[my_features].show()
sales.show(view='BoxWhisker Plog', x='zipcode', y='price')
my_features_model = graphlab.linear_regression.create(training_data, target='price', features=my_features)
print sqft_model.evaluate(test_data)
print my_features_model.evaluate(test_data)<jupyter_output>{'max_error': 4156269.632260985, 'rmse': 255166.23936085022}
{'max_error': 3533892.07212167, 'rmse': 184441.95401202946}<jupyter_text>Apply learned models to predict 3 house prices<jupyter_code>house1 = sales[sales['id']=='5309101200']
house1<jupyter_output><empty_output><jupyter_text><jupyter_code>print house1['price']
print sqft_model.predict(house1)
print my_features_model.predict(house1)
house2 = sales[sales['id']=='1925069082']
house2
print house2['price']
print sqft_model.predict(house2)
print my_features_model.predict(house2)<jupyter_output>[2200000]
[1256718.091902175]
[1431549.9450503518]<jupyter_text>Last house is super fancy<jupyter_code>bill_gates = {'bedrooms':[8], 
              'bathrooms':[25], 
              'sqft_living':[50000], 
              'sqft_lot':[225000],
              'floors':[4], 
              'zipcode':['98039'], 
              'condition':[10], 
              'grade':[10],
              'waterfront':[1],
              'view':[4],
              'sqft_above':[37500],
              'sqft_basement':[12500],
              'yr_built':[1994],
              'yr_renovated':[2010],
              'lat':[47.627606],
              'long':[-122.242054],
              'sqft_living15':[5000],
              'sqft_lot15':[40000]}
print sqft_model.predict(graphlab.SFrame(bill_gates))
print my_features_model.predict(graphlab.SFrame(bill_gates))<jupyter_output>[13974904.155132469]
[13471349.617239237]
{'fraction_non_alphanumeric': 0.136519748139668, 'fraction_numerical': 0.0815684029765312, 'mean_word_length': 5.920792079207921, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '527443', 'license': 'Apache-2.0', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1219, 'n_words': 184, 'path': 'linear_regression/Predicting house prices.ipynb', 'repo_name': 'jessechahal/graphlab-basics', 'size': '3494'}