forked from IrfanRamzanParray/Machine-Learning-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_visualization.py
More file actions
42 lines (35 loc) · 844 Bytes
/
03_visualization.py
File metadata and controls
42 lines (35 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.preprocessing import StandardScaler
# Load dataset
iris = load_iris()
# Create DataFrame
df = pd.DataFrame(data=iris.data,columns=iris.feature_names)
df["species"] = iris.target
#print(df)
# Histogram
plt.figure()
plt.hist(df["sepal length (cm)"], bins=20)
plt.xlabel("Sepal Length (cm)")
plt.ylabel("Frequency")
plt.title("Histogram of Sepal Length")
plt.show()
# #Scatter plot
plt.figure()
plt.scatter(
df["sepal length (cm)"],
df["petal length (cm)"],
c=df["species"]
)
plt.xlabel("Sepal Length (cm)")
plt.ylabel("Petal Length (cm)")
plt.title("Sepal vs Petal Length")
plt.show()
# #Box Plot
plt.figure()
df.iloc[:, :-1].boxplot()
plt.title("Boxplot of Features")
plt.xticks(rotation=45)
plt.show()