vis u ali z ing regressions
play

Vis u ali z ing regressions IN TR OD U C TION TO DATA VISU AL - PowerPoint PPT Presentation

Vis u ali z ing regressions IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON Br y an Van de Ven Core De v eloper of Bokeh Seaborn h p :// seaborn . p y data . org / INTRODUCTION TO DATA VISUALIZATION IN PYTHON Recap : pandas


  1. Vis u ali z ing regressions IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON Br y an Van de Ven Core De v eloper of Bokeh

  2. Seaborn h � p :// seaborn . p y data . org / INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  3. Recap : pandas DataFrames Labelled tab u lar data str u ct u re Labels on ro w s : index Labels on col u mns : columns Col u mns are pandas Series INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  4. Tips DataFrame total _ bill tip se x smoker da y time si z e 0 16.99 1.01 Female No S u n Dinner 2 1 10.34 1.66 Male No S u n Dinner 3 2 21.01 3.5 Male No S u n Dinner 3 3 23.68 3.31 Male No S u n Dinner 2 4 24.59 3.61 Female No S u n Dinner 4 ... ... ... ... ... ... ... ... INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  5. Linear regression plots 95% con � dence inter v al highlighted INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  6. Using lmplot () import pandas as pd import matplotlib.pyplot as plt import seaborn as sns tips = sns.load_dataset('tips') sns.lmplot(x='total_bill', y='tip', data=tips) plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  7. Factors total _ bill tip se x smoker da y time si z e 0 16.99 1.01 Female No S u n Dinner 2 1 10.34 1.66 Male No S u n Dinner 3 2 21.01 3.5 Male No S u n Dinner 3 3 23.68 3.31 Male No S u n Dinner 2 4 24.59 3.61 Female No S u n Dinner 4 ... ... ... ... ... ... ... ... INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  8. Gro u ping factors ( same plot ) INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  9. Using h u e sns.lmplot(x='total_bill', y='tip', data=tips, hue='sex', palette='Set1') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  10. Gro u ping factors ( s u bplots ) INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  11. Using col sns.lmplot(x='total_bill', y='tip', data=tips, col='sex') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  12. Resid u al plots INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  13. Using residplot () sns.residplot(x='age',y='fare', data=tips, color='indianred') plt.show() Similar arg u ments as lmplot() b u t more � e x ible x , y can be arra y s or strings data is DataFrame ( optional ) Optional arg u ments ( e . g ., color ) as in matplotlib INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  14. Let ' s practice ! IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON

  15. Vis u ali z ing u ni v ariate distrib u tions IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON Br y an Van de Ven Core De v eloper of Bokeh

  16. Vis u ali z ing data Uni v ariate → " one v ariable " Vis u ali z ation techniq u es for sampled u ni v ariate data Strip plots S w arm plots Violin plots INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  17. Strip plot INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  18. Using stripplot () sns.stripplot(y='tip', data=tips) plt.ylabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  19. Gro u ping w ith stripplot () sns.stripplot(x='day', y='tip', data=tip) plt.ylabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  20. Spreading o u t strip plots sns.stripplot(x='day', y='tip', data=tip, size=4, jitter=True) plt.ylabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  21. S w arm plot INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  22. Using s w armplot () sns.swarmplot(x='day', y='tip', data=tips) plt.ylabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  23. More gro u ping INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  24. More gro u ping w ith s w armplot () sns.swarmplot(x='day', y='tip', data=tips, hue='sex') plt.ylabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  25. Changing orientation INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  26. Changing orientation sns.swarmplot(x='tip', y='day', data=tips, hue='sex', orient='h') plt.xlabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  27. Violin plot INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  28. Using v iolinplot () plt.subplot(1,2,1) sns.boxplot(x='day', y='tip', data=tips) plt.ylabel('tip ($)') plt.subplot(1,2,2) sns.violinplot(x='day', y='tip', data=tips) plt.ylabel('tip ($)') plt.tight_layout() plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  29. Combining plots INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  30. Combining plots sns.violinplot(x='day', y='tip', data=tips, inner=None, color='lightgray') sns.stripplot(x='day', y='tip', data=tips, size=4, jitter=True) plt.ylabel('tip ($)') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  31. Let ' s practice ! IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON

  32. Vis u ali z ing m u lti v ariate distrib u tions IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON Br y an Van de Ven Core De v eloper of Bokeh

  33. Vis u ali z ing data Bi v ariate → " t w o v ariables " M u lti v ariate → " m u ltiple v ariables " Vis u ali z ing relationships in m u lti v ariate data Joint plots Pair plots Heat maps INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  34. Joint plot INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  35. Using jointplot () sns.jointplot(x= 'total_bill', y= 'tip', data=tips) plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  36. Joint plot u sing KDE INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  37. Using kde = Tr u e sns.jointplot(x='total_bill', y= 'tip', data=tips, kind='kde') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  38. Pair plot INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  39. Using pairplot () sns.pairplot(tips) plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  40. Using pairplot () w ith h u e sns.pairplot(tips, hue='sex') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  41. Co v ariance heat map of tips data INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  42. Using heatmap () print(covariance) total_bill tip size total_bill 1.000000 0.675734 0.598315 tip 0.675734 1.000000 0.489299 size 0.598315 0.489299 1.000000 sns.heatmap(covariance) plt.title('Covariance plot') plt.show() INTRODUCTION TO DATA VISUALIZATION IN PYTHON

  43. Let ' s practice ! IN TR OD U C TION TO DATA VISU AL IZATION IN P YTH ON

Recommend


More recommend