# -*- coding: utf-8 -*-
"""
Created on Thu Feb 10 20:32:37 2022

@author: TANISH
"""


""" Visualization In Python Using Seaborn """

# Need for Visualisation?
# 1.) Easy to understand for non-tech people

# 2.) Helps in pattern identification and
#     incorrect data points / outliers


# Limitations:
# Sometimes the decision can vary 
# from individual to individual


import seaborn as sb
import pandas as pd

mtcars = pd.read_csv(r"C:/Users/tanis/Desktop/MTCARS.csv")
mtcars.rename(columns = {"Unnamed: 0" : "CarName"},
                                      inplace = True)


""" TM, a car company looking to enter 
    the market with its first all rounder Car.
    
    The company have researched about all
    cars present in the market and is
    looking to develop the best car model """

""" You have a meeting with the
    design development team and you 
    are expected to come with following inputs: """


# Q.)
# What is the mileage range we 
# should focus on?

# Histogram
sb.displot(mtcars["mpg"],kind = "hist",
           color = "skyblue").set(xlabel = "MPG", 
                                ylabel = "Freq",
                                title = "Histogram of MPG")


# Q.)
# What is the mileage range if we 
# decide to focus on the niche current market?
                                  
# Density Plot
sb.displot(mtcars["mpg"],kind = "kde",
           color = "skyblue").set(xlabel = "MPG", 
                                ylabel = "Density")
                 
sb.kdeplot(mtcars["mpg"],shade = True)
sb.kdeplot(mtcars["hp"],shade = True)


# Histogram with Density Plot
sb.histplot(mtcars["mpg"],kde = True)
                                  

# Q.)
# If the company decides to target the niche
# mileage segment, what are the additional
# parameters / info you should look for?

# Scatter Plot
sb.scatterplot(x = mtcars["wt"],y = mtcars["mpg"])


sb.scatterplot(x = mtcars["wt"],y = mtcars["mpg"],
               hue = mtcars["cyl"])


sb.scatterplot(x = mtcars["wt"],y = mtcars["mpg"],
               hue = mtcars["hp"])


sb.scatterplot(x = mtcars["qsec"],y = mtcars["hp"])

# Combine Scatter Plot
sb.pairplot(mtcars)


# Q.)
# What mileage can we expect with
# no. of 4, 6, 8 cyl vehicle?

# Barplot

sb.barplot(x = mtcars["cyl"],
           y = mtcars["mpg"],ci = None)


# Q.)
# How many cyl do maximum car have
# currently in the market?

sb.countplot(mtcars["cyl"])

sb.countplot(mtcars["cyl"],hue = mtcars["am"])


# Q.)
# Can we expect the same amount of
# variability in mpg across all cyl?

sb.boxplot(x = mtcars["cyl"],
           y = mtcars["mpg"])



""" Excercise """

# Import the dataset, Iris.csv
# and answer the following questions

# 1.) What distr will be an 
#     appropriate fit for all the Lengths?

# 2.) Try to find out clusters 
#     and name them (if any)

# 3.) Summarize lengths as per Species














https://matplotlib.org/2.0.2/examples/color/named_colors.html
import matplotlib.pyplot as plt