Data Analysis and Visualization with Python – 2

We continue to make visualizations on the Iris dataset I used in my previous article. There are 2 most frequently used libraries for data visualization. Of these libraries, matplotlib is known by many people, just as I know. In addition, our second library is seaborn. In this article, we will witness the visualization of data with the help of libraries.

🔐 You need to enter the link for the Colab link I use.

Data Visualization Libraries

1. Seaborn: Statistical Data Visualization Library

Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface to draw attractive and informative statistical graphs. Visit the setup page to see how you can download the package and start using it.

Seaborn

We can say that the difference compared to Matplotlib is that it has more customization options.

Seaborn Samples

In the image I gave above, we see how we can visualize the data thanks to Seaborn. It is possible to display our data in many different graphics and forms.

2. Matplotlib: Visualization with Python

Matplotlib; it is a comprehensive library for creating static, animated, and interactive visualizations in Python.

Matplotlib Logo

Matplotlib was originally written by John D. Hunter, has an active development community ever since.

Plots

Likewise, in the visual I have given here, there are visualization forms that can be made with Matplotlib.

🧷 Click on the link to view the plot, or graphics, in the Matplotlib library.

  • Line Plots: It shows the relationship between two variables in lines.

Line plots

  • Scatter Plots: As the name suggests, this relationship between two variables is shown as distributed points.

Scatter Plots

✨ I wanted to use the seaborn library to measure the relationship between the variables in the Iris data set.

Uploading Seaborn

After including the Seaborn library in our project, we provide the graph by entering various parameters. Here we have compared the relationship between sepal_length and petal_width attributes over dataframe. The cmap variable is the variable that determines the color palette we use in our chart. It can be changed upon request. The variables indicates the size of the points in the scatter chart given here as points.

Data Visulatizaton

We have come to the end of another article. Stay healthy ✨

REFERENCES

  1. https://seaborn.pydata.org.
  2. https://matplotlib.org.
  3. Machine Learning Days | Merve Noyan | Data Visualization | Study Jams 2 |, https://www.youtube.com/watch?v=JL35pUrth4g&t=640s.
  4. Matplotlib, Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/wiki/Matplotlib.
  5. https://jakevdp.github.io/PythonDataScienceHandbook/04.02-simple-scatter-plots.html.
  6. https://jakevdp.github.io/PythonDataScienceHandbook/04.01-simple-line-plots.html.
  7. https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html.

 

 

 

 

 

 

 

Python ile Veri Analizi ve Görselleştirme – 2

Bir önceki yazımda kullandığım Iris veri seti üzerinde görselleştirme yapmaya devam ediyoruz. Veri görselleştirme için en sık kullanılan 2 adet kütüphane vardır. Bu kütüphanelerden matplotlib tıpkı benim bildiğim gibi birçok kişi tarafından bilinmektedir. Bunun yanı sıra 2. kütüphanemiz ise seaborn olmaktadır. Bu yazıda verilerin kütüphaneler yardımı ile görselleştirilmesine tanıklık edeceğiz.

🔐 Kullandığım Colab bağlantısı için linke girmeniz gerekmektedir.

Veri Görselleştirme Kütüphaneleri

1. Seaborn: Statistical Data Visualization Library ( İstatistiksel Veri Görselleştirme Kitaplığı )

Seaborn, Matplotlib tabanlı bir Python veri görselleştirme kitaplığıdır . Çekici ve bilgilendirici istatistiksel grafikler çizmek için üst düzey bir arayüz sağlar. Paketi nasıl indirebileceğinizi ve kullanmaya başlayabileceğinizi görmek için kurulum sayfasını ziyaret ediniz.

Seaborn

Matplotlib’ e göre farkı daha fazla özelleştirme seçeneğinin olması diyebiliriz.

Seaborn SamplesYukarıda yer verdiğim görselde Seaborn sayesinde verileri nasıl görselleştirebileceğimizi görmekteyiz. Birçok farklı grafik ve formlarda verilerimizi sergilememiz mümkün.

2. Matplotlib: Visualization with Python

Matplotlib; Python’da statik, animasyonlu ve etkileşimli görselleştirmeler oluşturmak için kapsamlı bir kütüphanedir.

Matplotlib Logo

Matplotlib orijinal olarak John D. Hunter tarafından yazılmıştır , o zamandan beri aktif bir geliştirme topluluğuna sahiptir. 

Seaborn Samples

Aynı şekilde burada verdiğim görselde ise Matplotlib ile yapılabilecek görselleştirme formları bulunmaktadır.

🧷 Matplotlib kitaplığındaki plot yani grafikleri incelemek için bağlantıya tıklayınız.

  • Line Plots ( Çizgi Grafikleri): İki değişken arasındaki ilişkiyi çizgiler halinde göstermektedir.

Line plots

  • Scatter Plots ( Dağılım Grafikleri ): İki değişken arasında var olan bu ilişkiyi isminden de anlaşılacağı üzere dağıtık noktalar halinde gösterilmektedir.

Scatter Plots

✨ Iris veri setinde yer alan değişkenlerin birbirleri ile olan ilişkisini ölçmek adına seaborn kütüphanesini kullanmak istedim.

Uploading Seaborn

Seaborn kütüphanesini projemize dahil ettikten sonra çeşitli parametreleri girerek grafiğin oluşmasını sağlamaktayız. Burada dataframe üzerinden sepal_length ve petal_width öznitelikleri arasındaki ilişkinin karşılaştırılmasını gerçekleştirdik. cmap değişkeni ise grafiğimizde kullandığımız renk paletinin belirlendiği değişkendir. İsteğe göre değiştirilebilmektedir. s değişkeni ise burada noktalar halinde verilen scatter grafiğindeki noktaların büyüklüğünü belirtmektedir.

Data Visulatizaton

Bir yazının daha sonuna gelmiş bulunmaktayız. Sağlıcakla kalın ✨

REFERANSLAR

  1. https://seaborn.pydata.org.
  2. https://matplotlib.org.
  3. Machine Learning Days | Merve Noyan | Data Visualization | Study Jams 2 |, https://www.youtube.com/watch?v=JL35pUrth4g&t=640s.
  4. Matplotlib, Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/wiki/Matplotlib.
  5. https://jakevdp.github.io/PythonDataScienceHandbook/04.02-simple-scatter-plots.html.
  6. https://jakevdp.github.io/PythonDataScienceHandbook/04.01-simple-line-plots.html.
  7. https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html.

Data Analysis and Visualization with Python

Hello, one more beautiful day! In this article, we will continue to code Python with you. So what are we doing today? We will talk about one of my favorite topics, data analysis. You can get your data set from data sites such as Kaggle or UCI. In addition to these, I did research on Iris Flower Data Set and chose it for you.

The Iris flower dataset is a multivariate dataset presented by the British statistician and biologist Ronald Fisher in his 1936 article on the use of multiple measures in taxonomic problems. It is sometimes referred to as the Anderson Iris dataset because Edgar Anderson collected data to measure the morphological variation of Iris flowers of three related species. The dataset consists of 50 samples from each of the three Iris species (Iris Setosa, Iris virginica and Iris versicolor).

Four properties were extracted from each sample:

    1. The length of the sepals in centimeters
    2. The width of the sepals in centimeters
    3. The length of the petals in centimeters
    4. The width of the petals in centimeters

This dataset becomes a typical test case for many statistical classification techniques in machine learning, such as support vector machines.

Iris dataset

The visual you see above is also included in the notebook I created in Colab. In this visual, we see examples from the data set. You can access it via the Colab link at the end of the article. It is already in the literature as one of the most frequently and fundamentally used data sets in the field of data science.

STEPS

✨ The necessary libraries must be introduced in Colab and then the path of the data set in the folder must be specified. Then you can print the df variable to see the data set content or use the df.head( ) command to access the first 5 lines.

Veri kümesini ve kitaplıkları içe aktarma

Veri Kümesini İncele

✨ If you wish, let’s run the df.head( ) command and see how we will get an output.

Baş Komuta

✨ We include the values of the features in the data set above. Variables like sepal_length and petal_width are numerical variables. In addition, the feature of the flower type referred to as species is referred to as a categorical variable. First of all, it is useful to know which type of variable this data falls into.

⚠️ If it is desired to estimate the categorical data, namely the type of flower from the numerical variables (features between sepal_length and petal_width), this is a classification problem.

Descriptive Statistics

✨ Descriptive statistics are printed with Pandas’ describe method. If you want to follow, you can access the original documents of Pandas. In this way, how much data each feature contains – it is possible to see the lost data – it is informed. Standard deviation, average, minimum and maximum values of the properties are seen.

Describe Method

For example, in these data, the sepal_length feature is specified as 150000 lines in total and the standard deviation of these values is approximately 0.83.

⏳ The 25% and 75% range are known as Quartiles. By controlling these values, data can be analyzed.

✨ To get information about the data set, df.info( ) command should be run.

According to this information, we see that there is no row with an empty value. In addition to these, we also know that the features that exist numerically have float type.

✨ The df.isna( ) command checks if there is missing data (Not a Number) in the data set. We expect the row with the missing data to be ‘True’. However, as we have seen above, we do not have any lost data.

NaN Any

✨ The df.isna( ).any( ) command returns True if the data set contains even 1 missing data while checking lost data.

Not a Number Value

🖇 NOTE: Click on the link for the Colab link I mentioned above.

In the second article of the series, I will refer to the small points in the data analysis and the visualization area. Stay healthy ✨

REFERENCES

  1. https://pandas.pydata.org/pandas-docs/stable/index.html.
  2. https://www.kaggle.com/arshid/iris-flower-dataset.
  3. Machine Learning Days | Merve Noyan | Data Visualization | Study Jams 2 |, https://www.youtube.com/watch?v=JL35pUrth4g.
  4. https://www.kaggle.com/peterchang77/exploratory-data-analysis.