Pertemuan 3 Praktikum Praktikum Visualisasi Data dan Informasi

Поділитися
Вставка
  • Опубліковано 12 січ 2025
  • =========================
    Koding Untuk Pertemuan 3
    =========================
    -------------------------
    pip install seaborn pandas
    ==========================
    import seaborn as sns
    import pandas as pd
    import matplotlib.pyplot as plt
    ===========================
    tips = sns.load_dataset('tips')
    print(tips.head())
    ==========================
    sns.histplot(data=tips, x='total_bill', bins=10, kde=True, color='blue')
    plt.title('Distribusi Total Bill')
    plt.show()
    ===========================
    sns.boxplot(data=tips, x='day', y='total_bill', palette='Set2')
    plt.title('Boxplot Total Bill per Hari')
    plt.show()
    ==========================
    sns.scatterplot(data=tips, x='total_bill', y='tip', hue='sex', style='time', palette='deep')
    plt.title('Hubungan Total Bill dan Tip')
    plt.show()
    ===========================
    import warnings
    warnings.filterwarnings("ignore", category=UserWarning)
    pairplot = sns.pairplot(tips, hue='sex', palette='coolwarm')
    plt.show()
    ==========================
    print(tips.info())
    ===========================
    numerical_tips = tips.select_dtypes(include=['float64', 'int64'])
    correlation = numerical_tips.corr()
    print(correlation)
    ==========================
    import seaborn as sns
    import matplotlib.pyplot as plt
    sns.heatmap(correlation, annot=True, cmap='coolwarm', linewidths=0.5)
    plt.title('Heatmap Korelasi Variabel Numerik')
    plt.show()
    ===========================

КОМЕНТАРІ •