import pandas as pd
import numpy as np
import seaborn as sns # visualisation
import [Link] as plt # visualisation
# %matplotlib inline
# [Link](color_codes=True)
df = pd.read_csv("[Link]")
[Link](5)
[Link](5)
print([Link](5))
print([Link](5))
print([Link])
columns_to_drop = [
"Engine Fuel Type",
"Market Category",
"Vehicle Style",
"Popularity",
"Number of Doors",
"Vehicle Size"
]
df = [Link](columns=columns_to_drop)
df = [Link](columns={
"Engine HP": "Horsepower",
"Engine Cylinders": "Cylinders",
"highway MPG": "HighwayMPG",
"city mpg": "CityMPG",
"MSRP": "Price"
})
df_before = len(df)
df = df.drop_duplicates()
df_after = len(df)
print("Removed duplicates:", df_before - df_after)
df = [Link]()
def remove_outliers(col):
Q1 = df[col].quantile(0.25)
Q3 = df[col].quantile(0.75)
IQR = Q3 - Q1
low = Q1 - 1.5 * IQR
high = Q3 + 1.5 * IQR
return df[(df[col] >= low) & (df[col] <= high)]
df = remove_outliers("Price")
df = remove_outliers("Horsepower")
df = remove_outliers("Cylinders")
[Link](figsize=(10,5))
[Link](df["Make"])
[Link]("Car Manufacturers Count")
[Link](rotation=90)
[Link]()
[Link](figsize=(10,6))
[Link]([Link](), annot=True, cmap="coolwarm")
[Link]("Correlation Heatmap")
[Link]()
[Link](figsize=(8,5))
[Link](x=df["Horsepower"], y=df["Price"])
[Link]("Horsepower vs Price")
[Link]()
import cv2
import numpy as np
import [Link] as plt
# Read the image
image1 = [Link]("image/sorasnap-0sHA_YUpFEw.jpg")
# Convert BGR → RGB (for matplotlib)
image1 = [Link](image1, cv2.COLOR_BGR2RGB)
# 1. Grayscale
image2 = [Link](image1, cv2.COLOR_RGB2GRAY)
# 2. Canny Edges
canny_edge = [Link](image2, 100, 200)
# 3. Sobel Edges
sob_x = [Link](image2, cv2.CV_64F, 1, 0, ksize=3)
sob_y = [Link](image2, cv2.CV_64F, 0, 1, ksize=3)
sobel_combined = [Link](sob_x, sob_y)
print("Min pixel image1:", [Link](image1))
print("Min pixel gray (image2):", [Link](image2))
# -----------------------------
# DISPLAY IMAGES WITH AXES ENABLED
# -----------------------------
[Link](figsize=(10, 8))
[Link](2, 2, 1)
[Link](image1)
[Link]("Original (With Axes)")
[Link]("X - Pixel Position")
[Link]("Y - Pixel Position")
[Link](False) # optional
[Link](2, 2, 2)
[Link](image2, cmap='gray')
[Link]("Grayscale (With Axes)")
[Link]("X - Pixel Position")
[Link]("Y - Pixel Position")
[Link](2, 2, 3)
[Link](canny_edge, cmap='gray')
[Link]("Canny Edges (With Axes)")
[Link]("X - Pixel Position")
[Link]("Y - Pixel Position")
[Link](2, 2, 4)
[Link](sobel_combined, cmap='gray')
[Link]("Sobel Edges (With Axes)")
[Link]("X - Pixel Position")
[Link]("Y - Pixel Position")
plt.tight_layout()
[Link]()