Exploratory Data Analysis
In this chapter, we will explore some of our data's features. Specifically, we will see how the target variable is distributed in the following variables: "gender"
, "relevent_experience"
, "enrolled_university"
, "education_level"
, "major_discipline"
, "experience"
, "company_size"
, "company_type"
.
Methods description
-
import matplotlib.pyplot as plt
: Imports thepyplot
module from thematplotlib
library and assigns it an aliasplt
.pyplot
provides a MATLAB-like interface for creating plots and visualizations in Python; -
import seaborn as sns
: Imports theseaborn
library and assigns it an aliassns
. Seaborn is a Python visualization library based on matplotlib that provides a high-level interface for drawing attractive statistical graphics; -
plt.figure(figsize=[15, 18])
: Creates a new figure object with a specified figure size of 15 inches in width and 18 inches in height; -
features = [...]
: Defines a list of feature names; -
plt.subplot(5, 2, n)
: Divides the figure into a grid of 5 rows and 2 columns, then selects the subplot at positionn
; -
sns.countplot(...)
: Generates a count plot for the specified feature (x=f
) with counts separated by thehue
variable (here, "target"), using data from thedata
DataFrame; -
plt.title(...)
: Sets the title for the subplot with the name of the feature; -
plt.tight_layout()
: Adjusts the subplot layout to make sure the plot elements fit within the figure area properly; -
plt.show()
: Displays the plot.
Swipe to start coding
-
Import
matplotlib
andseaborn
(assns
) libraries. -
Plot the following features:
"gender"
,"relevent_experience"
,"enrolled_university"
,"education_level"
,"major_discipline"
,"experience"
,"company_size"
,"company_type"
.
Soluzione
Grazie per i tuoi commenti!