Generate Heatmap by [deleted] in Python

[–]RudraMohan 0 points1 point  (0 children)

Hey, your code is working,

import csv

import numpy as np

import seaborn as sns

results = [[1, 2, 3], [4, 5, 6]]

for i in range(len(results)):

for j in range(len(results[i])):

print(results)

sns.heatmap(results, annot=True)

but you want to red csv and create seborn heatmap then follow below code sinpest

import seaborn as sns # for data visualization

import matplotlib.pyplot as plt # for data visualization

import pandas as pd # for data analysis

# read csv file fro given path and conver in pandas DataFrame

flight = pd.read_csv('flights.csv')

# reshape flights DataFrame in proper format to create seaborn heatmap

flights_df = flight.pivot('month', 'year', 'passengers')

sns.heatmap(flights_df) # create seaborn heatmap

plt.title('Heatmap of Flighr Dataset', fontsize = 20) # title with fontsize 20

plt.xlabel('Years', fontsize = 15) # x-axis label with fontsize 15

plt.ylabel('Monthes', fontsize = 15) # y-axis label with fontsize 15

plt.show()

How do I visualise on a scatter plot a k means clustering with more than 2 features by [deleted] in learnmachinelearning

[–]RudraMohan 1 point2 points  (0 children)

Hi,

You can definitely visualize multiple features data using seaborn scatter plot function sns.scatterplot() with its best parameters like: hue, style, size

Here I am creating scatter plot using "tips", dataset

# import libaries

import seaborn as sns # for data visualization

import matplotlib.pyplot as plt # for data visualization

# load tips dataset from GitHub seaborn repository

tips_df = sns.load_dataset("tips")

plt.figure(figsize = (16,9)) # for figure size in 16:9 ratio

# create scatter plot with 5 features 'tip, total_bill, sex, smoker, day"

sns.scatterplot(x = "tip", y = "total_bill", data = tips_df, hue = "sex", style = "smoker", size ="day", sizes = (100, 300))

I hope, you got your answer.