Predicting house prices: import graphlab # Load some house sales data sales = graphlab.SFrame("home_data.gl") sales id date proce bedrooms bathrooms sqft_living sqft_lot floors view conditions # Exploring the data for housing graphlab.canvas.set_target('ipynb') sales.show(view="Scatter Plot",x="sqft_living",y="price") #Create a simple regression model of sqft_living to price train_data, test_data = sales.random_split(.8,seed=0) # Build the regression model sqft_model = graphlab.linear_regression.create(train_data, target='price',features=['sqft_living']) # Evaluate the simple model print test_data['price'].mean() print sqft_model.evaluate(test_data) # Let's show what our predictions look like import mathplotlib.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.get('coefficients') # Explore other features in the data myfeatures = ['bedrooms','bathrooms,'sqft_living','sqft_lot','floors','zipcode'] sales[myfeatures].show() sales.show(view='BoxWhisker Plot', x-'zipcode', y='price') # Build a regression model with more features my_features_model = graphlab.linear_regression.create(train_data, target='price',features = my_features) print my_features print sqft_model.evaluate(test_data) print my_features_model.evaluate(test_data) # Apply learned model to predict prices of 2 houses house1 = sales(sales['id']=='5309101299'] print house1['price'] print sqft_model.predict(house1) print my_features_model.predict(house1) # Prediction for a second, fancier house house2 = sales[sales['id'] == '1925069082'] print sqft_model.predict(house2) print my_features_model.predict(hourse2) # Explore more those data!!!