I have a CSV file. From this I have to create Histogram and do linear regression on it

时间:2018-02-15 12:30:26

标签: python csv histogram linear-regression

For my assignment, I have a CSV file.

Row ID  Product Name    Product Price   Monthly Sales   Shipping Type   Geographic region   No Of Customer Who Bought the Product   Customer Type
1   Bush Somerset Collection Bookcase   261.96  1047.84 Free    Hooker Creek    2   old
2   Hon Deluxe Fabric Upholstered Stacking Chairs, Rounded Back 731.94  4391.64 Free    Mount Hotham    3   old
3   Bretford CR4500 Series Slim Rectangular Table   957.5775    9575.775    Paid    Hughenden   5   new
4   Eldon Expressions Wood and Plastic Desk Accessories, Cherry Wood    48.86   684.04  Paid    Julia Creek 7   new
5   Chromcraft Rectangular Conference Tables    1706.184    30711.312   Paid    Kalbarri    9   new
6   Global Deluxe Stacking Chair, Gray  71.372  285.488 Free    King Island 2   old
7   Bretford CR4500 Series Slim Rectangular Table   1044.63 6267.78 Paid    Kalkgurung  3   new
8   Riverside Palais Royal Lawyers Bookcase, Royale Cherry Finish   3083.43 43168.02    Paid    Karumba 7   new
9   Howard Miller 13-3/4" Diameter Brushed Chrome Round Wall Clock  124.2   745.2   Paid    Kowanyama   3   new

I have to do the following things in it. a) Linear Regression on Product Price and Monthly Sales and Plot a Graph b) Plot Histogram over Geographic region and any other relationship c) Find Min and Max from the Product Price and display some entities of the row

This is what i have done so far:

import pandas as pd

dataframe = pd.read_csv('furniture_Dataset.csv', error_bad_lines=False)
x_variables = dataframe[['Monthly Sales']]
y_variables = dataframe[['Product Price']]

#train model on data
body_reg = linear_model.LinearRegression()
body_reg.fit(x_variables, y_variables)

#visualize results
plt.scatter(x_variables, y_variables)
plt.plot(x_variables, body_reg.predict(x_variables))
plt.show()

I haven't been able to do anthing apart from this. this is not generating the graph as i'm getting the error

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 9: invalid start byte

For the rest part, I don't know anything. Please Help Me.

0 个答案:

没有答案