Python में डेटा कैसे विज़ुअलाइज़ करें?

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

Kirill Smirnov

Data Science Consultant, Altran

matplotlib

import matplotlib.pyplot as plt
  • स्कैटर प्लॉट
  • हिस्टोग्राम
  • बॉक्सप्लॉट
Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

डेटासेट

import pandas as pd

diabetes = pd.read_csv('diabetes.csv')
diabetes = diabetes[[
    'n pregnant', 'plasma glucose', 'blood pressure', 'skin thickness',
    'serum insulin', 'bmi', 'age', 'test result']]
print(diabetes.head())
   n pregnant  plasma glucose  blood pressure  skin thickness  serum insulin   bmi  age test result
0           6           148.0            72.0            35.0            NaN  33.6   50    positive
1           1            85.0            66.0            29.0            NaN  26.6   31    negative
2           8           183.0            64.0             NaN            NaN  23.3   32    positive
3           1            89.0            66.0            23.0           94.0  28.1   21    negative
4           0           137.0            40.0            35.0          168.0  43.1   33    positive
Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

स्कैटर प्लॉट

स्कैटर प्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

स्कैटर प्लॉट बनाएँ

import matplotlib.pyplot as plt
plt.scatter(
    diabetes['serum insulin'],
    diabetes['plasma glucose']
)
plt.show()

स्कैटर प्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

स्कैटर प्लॉट बनाएँ

import matplotlib.pyplot as plt
plt.scatter(
    diabetes['serum insulin'],
    diabetes['plasma glucose']
)

plt.title('Plasma Glucose vs Serum Insulin')

plt.show()

स्कैटर प्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

स्कैटर प्लॉट बनाएँ

import matplotlib.pyplot as plt
plt.scatter(
    diabetes['serum insulin'],
    diabetes['plasma glucose']
)

plt.title('Plasma Glucose vs Serum Insulin')

plt.xlabel('Serum Insulin')
plt.ylabel('Plasma Glucose')

plt.show()

स्कैटर प्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

हिस्टोग्राम

हिस्टोग्राम

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

हिस्टोग्राम बनाएँ

import matplotlib.pyplot as plt
plt.hist(diabetes['bmi'])

plt.title('Histogram of BMI index')

plt.xlabel('BMI index')
plt.ylabel('counts')

plt.show()

हिस्टोग्राम

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

हिस्टोग्राम बनाएँ

import matplotlib.pyplot as plt
plt.hist(diabetes['bmi'], bins=20)

plt.title('Histogram of BMI index')

plt.xlabel('BMI index')
plt.ylabel('counts')

plt.show()

हिस्टोग्राम

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

बॉक्सप्लॉट

बॉक्सप्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

बॉक्सप्लॉट बनाएँ

import seaborn as sns
sns.boxplot('test_result', 'bmi', data=diabetes)
plt.title('Boxplot of BMI index')

plt.show()

बॉक्सप्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

बॉक्सप्लॉट बनाएँ

import seaborn as sns
sns.boxplot(
    x='test_result',
    y='bmi',
    data=diabetes
)
plt.title('Boxplot of BMI index')

plt.show()

बॉक्सप्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

बॉक्सप्लॉट बनाएँ

import seaborn as sns
sns.boxplot(
    y='test_result',
    x='bmi',
    data=diabetes
)
plt.title('Boxplot of BMI index')

plt.show()

बॉक्सप्लॉट

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

अभ्यास करते हैं!

Python में कोडिंग इंटरव्यू प्रश्नों का अभ्यास

Preparing Video For Download...