Use the iloc() function to extract the first 20 features of the dataframe har_train. Save this new dataframe to first_twenty. Next, using the seaborn library create a heatmap for the correlation matrix. First you have to create the correlation matrix from the pandas dataframe (save it in a dataframe called corr) and then plot it using seaborn with these customizations: Set the seaborn style to white. Generate a mask using np.triu(np.ones_like()) with the dtype as boolean to only show the lower triangle of the correlation matrix. Save it in a variable called mask. Set up the figure with matplotlib with figsize=(11,9). Use fig, ax = ... Generate a custom diverging colormap for the heatmap with the arguments (220, 10, as_cmap=True). Save it in a variable called cmap. Draw the heatmap with the mask and correct aspect ratio, using the arguments corr, mask=mask, cmap=cmap, vmax=.3, center=0, square=True, linewidths=.5, cbar_kws={"shrink": .5}). Finally, use fig.tight_layout() just before saving the plot to produce a nicely centered graph. You can find more information about how to create a heatmap using seaborn here. The final plot should look like this:    \# Import the necessary modules import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns Mmatplotlib inline FEATURE_NAMES='./data/features,txt′TRAIN_OATA=′⋅/data/X_train.txt' TRAIN_LABELS=′/data/y_train.txt' * Load the data into a pandos DataFrame objects * read feature names feats = pd.read_cSV(FEATURE_NAMES, Sep ' 'n', header=None) H read in training dato har_train = pd.read_csV(TRAIN_DATA, sep=′\5t′, header=None) * read in training Labels har_train_labels = pd. read_csv(TRAIN_LABELS, sep=" n′, header=None, names=["label"], squeeze = True)   Please give proper explanation and typed answer only.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use the iloc() function to extract the first 20 features of the dataframe har_train. Save this new dataframe to first_twenty. Next, using the seaborn library create a heatmap for the correlation matrix. First you have to create the correlation matrix from the pandas dataframe (save it in a dataframe called corr) and then plot it using seaborn with these customizations: Set the seaborn style to white. Generate a mask using np.triu(np.ones_like()) with the dtype as boolean to only show the lower triangle of the correlation matrix. Save it in a variable called mask. Set up the figure with matplotlib with figsize=(11,9). Use fig, ax = ... Generate a custom diverging colormap for the heatmap with the arguments (220, 10, as_cmap=True). Save it in a variable called cmap. Draw the heatmap with the mask and correct aspect ratio, using the arguments corr, mask=mask, cmap=cmap, vmax=.3, center=0, square=True, linewidths=.5, cbar_kws={"shrink": .5}). Finally, use fig.tight_layout() just before saving the plot to produce a nicely centered graph. You can find more information about how to create a heatmap using seaborn here. The final plot should look like this: 

 

\# Import the necessary modules import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns Mmatplotlib inline FEATURE_NAMES='./data/features,txt′TRAIN_OATA=′⋅/data/X_train.txt' TRAIN_LABELS=′/data/y_train.txt' * Load the data into a pandos DataFrame objects * read feature names feats = pd.read_cSV(FEATURE_NAMES, Sep ' 'n', header=None) H read in training dato har_train = pd.read_csV(TRAIN_DATA, sep=′\5t′, header=None) * read in training Labels har_train_labels = pd. read_csv(TRAIN_LABELS, sep=" n′, header=None, names=["label"], squeeze = True)

 

Please give proper explanation and typed answer only.

 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Multiple table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education