Professional Documents
Culture Documents
ML EXP 2 Code
ML EXP 2 Code
In [9]: data=pd.read_csv("C:/Users/ASUS/Downloads/tips.csv")
In [10]: data.head()
Out[10]: Payment
total_bill tip gender smoker day time size price_per_person Payer Name CC Number
ID
Christy
0 16.99 1.01 Female No Sun Dinner 2 8.49 3.560330e+15 Sun2959
Cunningham
Douglas
1 10.34 1.66 Male No Sun Dinner 3 3.45 4.478070e+15 Sun4608
Tucker
Travis
2 21.01 3.50 Male No Sun Dinner 3 7.00 6.011810e+15 Sun4458
Walters
Nathaniel
3 23.68 3.31 Male No Sun Dinner 2 11.84 4.676140e+15 Sun5260
Harris
4 24.59 3.61 Female No Sun Dinner 4 6.15 Tonya Carter 4.832730e+15 Sun2251
In [14]: #Scatter plots are used to observe relationships between variables and
#uses dots to represent the relationship between them.
#The scatter() method in the matplotlib library is used to draw a scatter plot.
plt.scatter(data['day'], data['tip'])
plt.title('scatter plot')
plt.xlabel('Day')
plt.ylabel('tip')
plt.show()
plt.bar(data['day'], data['tip'])
plt.title("Bar Chart")
plt.xlabel('Day')
plt.ylabel('Tip')
plt.show()
In [21]: #Histogram
plt.hist(data['total_bill'])
plt.title("Histogram")
plt.show()
In [22]: #Line Plot
#Line Plot in Seaborn plotted using the lineplot() method. In this, we can
#pass only the data argument also.
plt.show()
In [27]: #Histogram
<AxesSubplot:xlabel='total_bill', ylabel='Count'>
Out[27]:
In [30]: data.tail(250)
Out[30]: Payment
total_bill tip gender smoker day time size price_per_person Payer Name CC Number
ID
Christy
0 16.99 1.01 Female No Sun Dinner 2 8.49 3.560330e+15 Sun2959
Cunningham
Douglas
1 10.34 1.66 Male No Sun Dinner 3 3.45 4.478070e+15 Sun4608
Tucker
Travis
2 21.01 3.50 Male No Sun Dinner 3 7.00 6.011810e+15 Sun4458
Walters
Nathaniel
3 23.68 3.31 Male No Sun Dinner 2 11.84 4.676140e+15 Sun5260
Harris
4 24.59 3.61 Female No Sun Dinner 4 6.15 Tonya Carter 4.832730e+15 Sun2251
... ... ... ... ... ... ... ... ... ... ... ...
Michael
239 29.03 5.92 Male No Sat Dinner 3 9.68 5.296070e+15 Sat2657
Avila
Monica
240 27.18 2.00 Female Yes Sat Dinner 2 13.59 3.506810e+15 Sat1766
Sanders
241 22.67 2.00 Male Yes Sat Dinner 2 11.34 Keith Wong 6.011890e+15 Sat3880
Dennis
242 17.82 1.75 Male No Sat Dinner 2 8.91 4.375220e+12 Sat17
Dixon
Michelle
243 18.78 3.00 Female No Thur Dinner 2 9.39 3.511450e+15 Thur672
Hardin
<seaborn.axisgrid.PairGrid at 0x1c296f1fe50>
Out[34]:
In [ ]: