2/23/23, 11:00 AM
Vizualizatsiya2.ipynb - Colaboratory
https://colab.research.google.com/drive/1JW1m0PA5HiH-RnrL_HjQNTzlxW24yQpM#scrollTo=Y3XJ7TyxfGjo&printMode=true
1/7
Kirish. Mashinali o‘qitishga kirish va uning asosiy tushunchalari
Chiziqli grafiklar. seaborn kutubxonasi
seaborn matplotlib ustiga qurilgan kutubxonalardan bo'lib, grafiklar bilan ishlashni yana osonlashtiradi va muhimi chizmalarga ko'zga
yoqadigan qilib chiroy beradi.
seaborn to'lqi dokumentasiya:
https://seaborn.pydata.org/index.html
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# agar seaborn o'rnatilmagan bo'lsa pip install seaborn
# Colab da faqat chaqirib olish kifoya
import seaborn as sns
Keling, amaliyot uchun ma'lumotlar yuklab olamiz.
# https://github.com/JamshidSalimov/Ai-Fayls
Avila Adobe Firehouse Museum Chinese American Museum America Tropical Interpretive Center Date 2014-01-01 24778
4486
1581
6602
2014-02-01 18976
4172
1785
5029
2014-03-01 25231
7082
3229
8129
2014-04-01 26989
6756
2129
2824
2014-05-01 36883
10858
3676
10694
# muziyga tashrif bo'yuruvchilarning malumotlarini yuklab olamiz.
df=pd.read_csv("/content/Ai-Fayls/museum_visitors.csv", index_col=0)
df.head()
seaborn da chiziqli grafik chizish uchun .lineplot() metodiga murojaat qilamiz.
# lineplot() metodi
plt.figure(figsize=(13,6))
plt.title("Muziyga tashrif grafigi")
plt.plot(df)
plt.xticks(rotation=90)
# plt.yticks(rotation=90)
plt.show()
plt.savefig("2-rasim.jpg")
2/23/23, 11:00 AM
Vizualizatsiya2.ipynb - Colaboratory
https://colab.research.google.com/drive/1JW1m0PA5HiH-RnrL_HjQNTzlxW24yQpM#scrollTo=Y3XJ7TyxfGjo&printMode=true
2/7
2/23/23, 11:00 AM
Vizualizatsiya2.ipynb - Colaboratory
https://colab.research.google.com/drive/1JW1m0PA5HiH-RnrL_HjQNTzlxW24yQpM#scrollTo=Y3XJ7TyxfGjo&printMode=true
3/7
Agar df ning barcha ustunlarini emas, tanlangan ustunlarning grafigini chizaman desangiz, buning ham imkoni bor
# Avila Adobe uchun grfik yasab ko'ramiz
.lineplot() funksiyasiga ham qiymatlarni x va y ko'rinishida uzatish mumkin:
# ikkita grafikni bittada chizish
Ustunli diagramma
Ustunli diagramma turli kategoriyadagi qiymatlarni solishtirish uchun juda qulay.