Advertisement
makispaiktis

Kaggle - Exercise 5 - Histplot, kdeplot, jointplot

Jul 2nd, 2023 (edited)
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. import pandas as pd
  2. pd.plotting.register_matplotlib_converters()
  3. import matplotlib.pyplot as plt
  4. # %matplotlib inline
  5. import seaborn as sns
  6.  
  7.  
  8. # 1. Read the file
  9. cancer_filepath = "../input/cancer.csv"
  10. cancer_data = pd.read_csv(cancer_filepath, index_col="Id")
  11. print(cancer_data.head())
  12.  
  13. # In the first five rows of the data, what is the largest value for 'Perimeter (mean)'?
  14. max_perim = 87.46
  15. # What is the value for 'Radius (mean)' for the tumor with Id 8510824?
  16. mean_radius = 9.504
  17.  
  18. # 2. Histogram containing the 2 values of the class (class="Diagnosis")
  19. sns.histplot(data=cancer_data, x="Area (mean)", hue="Diagnosis")
  20.  
  21. # 3. KDE plot containing the 2 values of the class (class="Diagnosis")
  22. sns.kdeplot(data=cancer_data, x="Radius (worst)", hue="Diagnosis")
  23.  
  24. # 4. 2D-KDE plot (jointplot) containing the 2 values of the class (class="Diagnosis")
  25. sns.jointplot(data=cancer_data, x="Radius (worst)", y="Area (mean)")
  26. sns.jointplot(data=cancer_data, x="Radius (worst)", y="Area (mean)", kind="hist")
  27. sns.jointplot(data=cancer_data, x="Radius (worst)", y="Area (mean)", kind="kde")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement