Page 165 - Touhpad Ai
P. 165

The most popular data visualization method in machine learning is the scatter plot.
                 When is a scatter plot suitable?
                 u  It is used to track the connections between two numeric variables. When the data is seen as a whole, the dots on the
                   plot indicate both the variable's value and any trends.
                 u  The scatterplot is a valuable tool for calculating correlation. Variable relationships can be categorised in a variety of
                   ways, including positive or negative, strong or weak, linear or nonlinear.
                 u  This graph’s strength lies in its ability to clearly depict trends, clusters, and relationships within datasets.
                 The function scatter() is used to visualise a scatterplot in Python.

                      Program 4: Create a Scatter Plot Graph for number of hours students spend studying per week with respect to
                    percentage scored using Python

                           Study Time      4   3.5   5     2    3   6.5  0.5   3.5  4.5   5    1    1.5  3    5.5

                           Percentage      82   82   90   74   40    97   51   75   86   85    62   75   70   91

                 Code:

                 import matplotlib.pyplot as plt


                 # Data
                 study_time = [4, 3.5, 5, 2, 3, 6.5, 0.5, 3.5, 4.5, 5, 1, 1.5, 3, 5.5]
                 percentage = [82, 82, 90, 74, 40, 97, 51, 75, 86, 85, 62, 75, 70, 91]


                 # Create scatter plot using scatter() function
                 plt.scatter(study_time, percentage)


                 # Add title and labels
                 plt.title('Study Time vs. Percentage Scored')
                 plt.xlabel('Study Time (hours)')
                 plt.ylabel('Percentage Scored')


                 # Show plot
                 plt.show()




                                                                                                  Data Visualization  163
   160   161   162   163   164   165   166   167   168   169   170