0% found this document useful (0 votes)
8 views

Module5 Dbscanv2

Uploaded by

Priyansh Polra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Module5 Dbscanv2

Uploaded by

Priyansh Polra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

In‬‭

‭ [1‬:‬‭import‬‭
]‬
‭‭ numpy‬‭as‬‭np‬
‭from‬‭
sklearn.cluster‬‭import‬‭DBSCAN‬
‭from‬‭sklearn‬‭import‬‭
metrics‬
‭from‬‭
sklearn.datasets‬‭import‬‭make_blobs‬
‭from‬‭
sklearn‬‭import‬‭
metrics‬
‭from‬‭sklearn.preprocessing‬‭import‬‭LabelEncoder‬
‭import‬‭pandas‬‭as‬‭
pd‬
f‭ rom‬‭
sklearn.preprocessing‬‭import‬
StandardScaler‬‭import‬‭
‭ matplotlib.pyplot‬‭as‬‭
plt‬
‭from‬‭
matplotlib.colors‬‭import‬‭
ListedColormap‬

In [‬
‭ 2‭
‭] :‬‭#read‬‭the‬‭
‬‬
‭ data‬
df‬‭
‭ =‬‭
pd.read_csv‬‭'‭
(‬
‭ ‬ ris.csv‬
i ‭'‬‭
)‬
‭df.head‬‭()‬

‭sepal.length‬‭sepal.width petal.length petal.width‬‭variety‬


‭Out‬‭
[‬‭2‭]‬‬‭:‬

‭0‬
‭5.1‬
‭3.5‬
1.4‬

0.2‬‭Setosa‬

‭1‬
4.9‬

‭3.0‬
1.4‬

‭0.2‬‭Setosa‬

‭2‬
4.7‬

‭3.2‬
‭1.3‬
‭0.2‬‭Setosa‬

3‬

4.6‬

‭3.1‬
‭1.5‬
‭0.2 Setosa‬

4‬

‭5.0‬
‭3.6‬
1.4‬

‭0.2‬‭Setosa‬

In‬‭
‭ [‭
3
‬‭
]
‬‬ #select only‬‭feature‬‭
:‬‭
‭ columns‬
‭X‬‭=‬‭
df‬ ‭'‬‭
[[‬
‭ sepal.length‬
'‬
‭ ,‬‭
‭ '‭
s ‭'‬‭
‬epal.width‬ ,‬‭'‬‭ ‭'‭
petal.length‬ ‬ ‬‭'‭
, ‬ etal.width‬
p ‭'‬‭
]‭
]‬‬

[‭4
‭n‬‭
I ‬‬‭
]‭
:
‬‬‭
sc‬‭
=‬‭
StandardScaler‬
()‬

‭Out‬‭
[‬‭4‭
‬‬
] :‬

X‬‭
‭ =‬‭
sc.fit_transform‬
(‬
‭X‬
‭ ‭)‬
‭X‭
‬ :‬
[ 5‬
‭ ]‬

‭array‬‭
(‬[‬
‭ [‭
‭-‬‬ ‭0.90068117‬‭
,‬
1.01900435‬
‭ ,‬ ‭-1.34022653‬‭,‬ ‭-1.3154443‬ ‭]‭,‬‬ ‭
‭ [‬‭-1.14301691‬‭
,‬
‭-0.13197948‬‭ ,‬ ‭-1.34022653‬‭,‬ ‭-1.3154443‬‭]‬‭,‬‭
[‭-‬1.38535265‬‭
,‬‭ 0.32841405‬ ,‬

‭-1.39706395‬‭,‬ ‭-1.3154443‬ ‭
]‭
,‬‬ ‭[‬‭-1.50652052‬‭ ,‬ ‭0.09821729‬‭,‬ ‭-1.2833891‬‭
,‬
‭-1.3154443‬ ‭]‭,‬‬ ‭
[‭
-
‬1.02184904‬
,‬ ‭
‭ 1.24920112‬
,‬ ‭
‭ -1.34022653‬
,‬

-1.3154443‬‭]]‬‭
‭ )‬

In‬‭
‭ [5‬
]‬
‭ :‬‭
‭ Compute‬‭DBSCAN‬
#‬‭
d =‬‭DBSCAN‬‭(‭
‭b‬‭ ‬ ps‬
e =‭
‭ 0
‬.8‬‭,‬‭
min_samples‬ ‭=‬‭ ‭)‭
10‬ ‬ fit‬
. (‭X
‭ ‬ ‬‭)‬
core_samples_mask‬‭
‭ =‬‭np‬‭.‬‭zeros_like‬‭(‬‭
db.labels_‬ ,‬‭dtype‬‭=‬‭
‭ bool‬
)‬

core_samples_mask‬‭[‬‭
‭ db.core_sample_indices_‬ ‭]‬‭=‬‭True‬‭
labels‬‭=‬
db.labels_‬

In‬‭
‭ [‬‭6‬‭
]‭
:‬‬‭
labels‬

‫‬‮ده‬
‫‬‮ده‬
‭0,‬
‭Out‬‭
[‬6‬
‭ ]‬
‭ ‭:‬

‭1‬‭,‬

1‭
‭,
‬‬
‬‬‭1‭
1‭
‭, ‬ ‬‭
, 1‬
,‬‭
‭ 1‬
,‬‭
‭ 1‬
,‬‭
‭ 1‭
,
‬‬
4444‬

‭array‬‭
(‬[‬
‭ 0,‬‭0,‬‭0‬‭,‬

0‭
‭,‬‬‭0‭,‬‬‭
0‭
,‬‬‭0‬‭,‬‭0‭,‬‬‭0‬‭, 0‬‭,‬‭0‭,‬‬‭0,‬‭
-1‬ 0‭,‬‬
,‬‭

1‭
‭,‬‬‭
1‭
,
‬‬‭
1‭
,
‬‬‭
1‭
,
‬‬‭
1‭
,‬‬‭
1‭
,‬‬‭
1‬,‬‭
‭ 1‭
,‬ -1,‬‭
1‬
,‬‭
‭ 1,‬‭
1‬
,‬

1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
,‬‭
‭ 1,‬‭
1,‬‭
1‭
,
‬‬
0‭
‭,
‬‬

‭0‬‭
,‬‭0‬‭,‬‭0‭
‬ ‬‭0‬‭,‬‭
, 0‬
,‬‭
‭ 0,‬
‫‬‮ده‬
0‭
‭,
‬‬
‭0‬‭,‬

0‭
‭,
‬‬
0‬
‭,‬

0‭
‭,
‬‬
0‭
‭,
‬‬
‭0‬‭,‬
0,‬‭0‭,‬‬

0‭
‭,
‬‬‭
-1‬
,‬

0‭
‭,
‬‬
0‭
‭,
‬‬

‭0‬‭,‬
0‭
‭,
‬‬

‭1‬‭
,‬
1‭
‭,‬‬
‭PPP‬
‭1‭,‬‬
1‭
‭,
‬‬‭
-1‬
,‬

1‭
‭,
‬‬‭
1‭
,
‬‬
लेते‬

1‬
‭,‬

‭PP‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1.‬‭
1‬
,‬

1‬
‭, 1‬
‭ ,‬‭
‭ 1‬
,‬

PPPPP‬

1‭
‭,
‬‬
‭1‬‭,‬
‭ले‬‭लेते‬
1‭,‬‬

1‭
‭,‬‬‭
1, 1‬
,‬‭
‭ 1‭
,‬‬‭
1‭
,‬‬‭
1,‬‭1‭,‬‬‭1‭,‬‬
1‭
‭,
‬‬‭
1,‬‭
1‬
,‬‭
‭ 1‬
,‬‭
‭ 1‬
,‬

0‭
‭,
‬‬‭
0‭
,
‬‬‭,‬‭0‬‭,‬
0‬

1‭
‭,‬‬

1‭
‭,
‬‬

1‭
‭,
‬‬‭
1‭
,
‬‬‭
1,‬‭
1‬
,‬‭
‭ ‭,‬‭
1‬ 1‭
,
‬‬
‭1‬‭,‬
‭1‭,‬‬
‭1‬‭,‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1,‬‭
1,‬
1‭
‭,
‬‬‭
-1‬
,‬‭
‭ -1‬
,‬

1‭
‭,
‬‬
1‬
‭,‬

‭PP‬
1‭
‭,
‬‬
लेते‬

1‬
‭,‬‭
‭ -1,‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
,‬

‭1‬‭
,‬

1‭
‭,
‬‬‭
1‭
,
‬‬‭‭]‭,‬‬
1‬
1‬
‭,‬‭
‭ 1‬
,‬

1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
,‬‭
‭ ‭,‬
-1‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
,‬‭
‭ 1‬
,‬‭
‭ 1‬
,‬

‭dtype‬‭
=‬ ‭)‬
int64‬

In‬‭
‭ [‬‭7‭]‬‭
‬ ‬‭
: le LabelEncoder‬
()‬

‭=‬

‭_actual‬
y
le.fit_transform‬
‭ (‭
‭d
‬f‬‭'‭
[‬
‭ ‬ ariety‬
v ‭'‬‭
]‬
)‬

In‬‭
‭ [‬8‭]‬‬‭
‭ :‬‭
y_actual‬
‭Out‬‭
[‬8‬
‭ ]‬
‭ :‬

‭array‬‭(‬‭ ,‬‭0‭
[0‬
‭ ‬ ‬‭
, 0‬,‬‭0‭,‬‬‭
‭ 0‬ 0,‬‭0‬‭,‬‭
,‬‭
‭ 0‭,‬‬‭‬‬‭0,‬‭
0‭
, 0‭
,‬‬‭
0‭
, 0‭,‬‬‭
‬‬‭ 0‭
,‬‬‭0‬‭,‬‭0‭,‬‬‭
0‭
, 0‭,‬‬‭0‬‭,‬‭
‬‬‭ 0‭,‬‬‭
0‭
,‬‬‭0‬‭,‬‭‬‬‭0‬‭
0‭
, ,‬‭0‭,‬‬‭0‬‭,‬‭0‬‭
,‬‭0‬‭,‬‭0‬‭,‬
‭0‬‭,‬‭0‬‭,‬‭0‬‭,‬‭0‬‭,‬‭0‭
‬ ‬‭0‭,‬‬‭0‭,‬‬‭0‬‭,‬‭0‭,‬‬‭0‬‭, 0‬‭,‬‭0‭,‬‬‭0‭,‬‬‭0‭,‬‬‭0‬‭,‬‭
, ‭,‬‭0‭,‬‬‭
0‬ ,‬‭0‬‭
0‬
‭ ,‬‭0‭,‬‬‭0‬‭,‬‭
1‭
,
‬‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
, 1‬
‭ , 1‬
‭ ,‬

1‭
‭,
‬‬‭
1,‬‭
1‬
,‬‭
‭ 1‬
,‬‭
‭ 1,‬‭
1‭
,
‬‬‭
1‭
,
‬‬‭
1‭
, 1,‬‭1‬‭
‬‬‭ ,‬
1‬
‭,‬‭
‭ 1‭
,
‬‬‭
1‬
,‬‭
‭ ,‬‭1‬‭
1‬
‭ ,‬
1‭
‭,
‬‬
1‭
‭,
‬‬
1‭
‭,
‬‬
1‭
‭,
‬‬‭
1‭
,
‬‬
1‭
‭,
‬‬
1‭
‭,
‬‬
1,‬

‭1‬‭,‬
‭1‬‭,‬
1‭
‭,
‬‬‭
1‭
,
‬‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
,‬‭
‭ ,‬‭1‬‭
1‬
‭ ,‬
1‬
‭,‬‭
‭ 1‭
,
‬‬‭
1‬
,‬‭
‭ 1‬
,‬‭
‭ 1‬
,‬

1‭
‭,
‬‬
1‭
‭,
‬‬
1‭
‭,
‬‬
1‭
‭,
‬‬‭
1‭
,
‬‬‭
1‬
,‬

1‭
‭,
‬‬
2‭
‭,
‬‬
2‭
‭,
‬‬
2‭
‭,
‬‬
2‭
‭,
‬‬‭
2‭
,
‬‬
2‭
‭,
‬‬‭
2‭
,
‬‬‭
2‬
,‬‭
‭ 2‬
,‬‭
‭ 2‬
,‬

2‬
‭,‬‭
‭ 2‭
,
‬‬‭
2‬
,‬‭
‭ 2‬
,‬‭
‭ 2‬
,‬

2‭
‭,
‬‬
2‭
‭,
‬‬
2‭
‭,
‬‬‭
2‭
,
‬‬‭
2‬
, 2,‬‭
‭ 2‬
,‬‭
‭ 2‭
,
‬‬
2‭
‭,
‬‬‭
2‭
,
‬‬‭
2, 2‬
,‬‭
‭ 2‬
,‬‭
‭ 2‭
,
‬‬‭
2‭
,
‬‬‭
2‭
,
‬‬‭
2‭
,
‬‬

‭2‬‭
,‬‭
2‬,‬‭
‭ 2‭
,
‬‬‭
2‭
,‬‬‭
2‭
,‬‬‭
2‭
,‬‬‭
2‭
,‬‬‭
2‭
,
‬‬
2‭
‭,‬‬‭
2,‬‭
2,‬‭
2‭
,‬‬
‭2‬‭
,‬
2‭
‭,‬‬‭
2‭
,‬‬‭
2‭
,‬‬‭
2‭
,
‬‬‭
2‭
]‬‬
)‬

‭n‬‭
I [‭
9
‬‭
]
‬‬ print‬‭(‭"‬ ‬‭Accuracy‬‭
:‬‭
‭ :‬
"‭
‭,
‬‬‭
metrics.accuracy_score‬‭
(‭
y
‬_actual‬
,‬

labels‬
‭ ))‬

print‬‭(‬‭
‭ "‬Classification‬‭report‬‭
‭ :‭
"‬‬
)‬

‭rint‬
p (‬
‭ ‭(‬‭
metrics.classification_report‬
‭ y_actual‬
,‬

labels‬
‭ ))‬

‭Accuracy‬‭
:‬‭0.6466666666666666‬
Classification‬‭report :‬

‭precision‬
recall‬‭
‭ f1‬
-‭
‭ ‬core‬‭support‬
s

‭-1‬
0.00‬

0.00‬

0.00‬

0‬

0‬

‭ ‬
O
‭H‬
‭2‬
1.00‬

0.96‬

0.98‬

‭50‬

‭1‬
0.52‬

0.98‬

0.68‬

‭50‬

0.00‬

0.00‬

0.00‬

‭50‬

‭accuracy macro‬‭avg‬
weighted‬‭
‭ avg‬
0.65‬

‭150‬

‭0.38‬
0.48‬

0.42‬

‭150‬

0.51‬

0.65‬

‭0.55‬
‭150‬

‭‬
C :‬
‭ ‭\‭U
‬ sers‬‭\‭R
‬ ajesh‬‭A‬‭
\‭a
‬naconda3‬‭\envs‬‭\‬‭
tf‬
\‭
‭l‬ib‬
\‭
‭ s
‬ite‬ -‭p
‭ ‬ackages‬‭\sklearn‬‭\‭m
‬ etrics‬‭
\‭
_ :‭1
‬classification.py‬
‭ ‬34‬‭
4‭
:‬‬
‭UndefinedMetricWarning‬‭ : Precision‬‭ and‬‭F‭-
‬‬‭score‬‭are‬‭
ill‬
-‭
‭ d
‬efined‬‭ and‬‭ being set‬‭
to‬‭ in‬‭labe‬‭
0.0‬‭ with‬‭no‬
ls‬‭
‭predicted‬‭ samples‬ .‬‭
‭ zero_division`‬‭parameter‬‭
Use‬‭̀‬
‭ to‬‭control this‬‭behavior‬‭.‬
‭_warn_prf‬‭(average‬‭
,‬‭ ‭,‬‭
modifier‬ msg_start‬
,‬‭
‭ len(result‬
)‭
‭)
‬‬
‭‭
C : ‭\‭U
‬‬ ‬ sers‬‭\‭R
‬ ajesh‬ ‭A\‬‭anaconda3‬‭\‭
‬ nvs‬
e ‭\‭
‬ f‬
t \‭l‬ib‬‭
‭ \‭
s -‭p
‬ite‬
‭ ‬ackages‬‭\sklearn‬‭
\‭m
‬etrics‬
\‭
‭ _
‬classification.py‬ ‭:‭1
‬ 34‬ ‭4‬‭
:‬
‭UndefinedMetricWarning‬‭:‬ ‭Recall‬ ‭ and‬ ‭ ‬‭s‬core‬ ‭are‬ ‭
F‭
- ill‬
-‬
‭ ‭defined‬ ‭
and‬ ‭
being‬ ‭ set‬ ‭
to‬ ‭
0.0‬ ‭
in‬ ‭
labels‬ ‭
with‬ ‭ no‬ ‭true‬
samples‬
‭ .‬‭
‭ zero_division`‬‭parameter‬‭
Use‬‭̀‬
‭ to‬‭control‬‭this‬‭behavior‬‭.‬
‭_warn_prf‬‭
(‭a
‬verage‬‭, modifier‬‭,‬‭msg_start‬‭
,‬‭ ‭(‬‭
len‬ result‬
)‭
‭)‬‬
C‬
‭ :‬
‭ ‭\‭U
‬ sers‬‭\Rajesh‬‭A‬‭\‭a
‬ naconda3‬‭\‭e
‬ nvs‬‭\‭
‬ f‬
t \‬
‭ lib‬
‭ \‭
‭s‬ite‬-‭p
‭ ‬ackages\‬‭sklearn‬‭
\‭m‬etrics‬
\‭
‭ _
‬classification.py‬ :‭1
‭ ‬34‬‭4‬‭
:‬
‭UndefinedMetricWarning‬‭ : Precision‬‭ and‬‭F‭
-
‬‬score‬‭are‬‭
‭ ill‬ -‭d
‭ ‬efined‬‭
and being‬‭set‬‭ to‬‭
0.0‬‭
in‬‭labe‬‭ with‬‭no‬
ls‬‭
‭predicted‬‭ samples.‬‭ zero_division`‬‭parameter‬‭
Use‬‭̀‬
‭ to‬‭ control‬‭ this‬‭behavior‬‭.‬
‭_warn_prf‬‭
(‭a
‬verage‬‭
,‬‭ ‭,‬‭
modifier‬ msg_start,‬‭ ‭(‭
len‬ ‬ esult))‬
r
‭‭
C: ‭\‭U
‬‬ ‬ sers‬‭\‭
‬ ajesh‬
R ‭A\‬‭anaconda3‬‭\envs‬‭\‭
‬ f‬
t \‭
‭ l
‬ib‬ \‭
‭s‬ite‬-‬
‭ ‭packages‬‭\sklearn‬‭
\‭
m‬etrics‬
\‭
‭_‬classification.py‬
:‭
‭ 1
‬34‬ ‭4‬‭
:‬
UndefinedMetricWarning‬
‭ ‭ Recall‬‭and‬‭
:‬‭ F‭‬‭s‬core‬‭are‬‭
- ill‬-‭
‭d‬efined‬‭ and‬‭ being‬‭set‬‭
to‬‭
0.0‬‭
in‬‭
labels‬‭with‬‭
no‬
‭true‬‭ ‭.‬‭
samples‬ zero_division`‬‭parameter‬‭
Use‬‭̀‬
‭ to‬‭control‬‭
this‬‭behavior‬‭.‬
‭_warn_prf‬‭
(‭a
‬verage‬‭
,‬‭ ,‬‭msg_start‬‭
modifier‬
‭ ,‬‭ ‭(‭
len‬ ‬ esult‬
r )‭
‭)
‬‬
‭‬
C :‬
‭ ‭\Users‬‭\‭R
‬ ajesh‬‭A‬‭\‭a
‬ naconda3‬‭\envs‬‭\‭t‬f‬‭
\‭
l‬ib‬
\‭
‭ s -‭p
‬ite‬
‭ ‬ackages‬‭\‭s‬ klearn‬‭
\‭
m‬etrics‬
\‭
‭_‬classification.py:‬ ‭134‬‭4‬‭
:‬
‭UndefinedMetricWarning‬‭:‬‭Precision‬‭ and‬‭ F‭
-
‬‭
s‬core‬‭are‬‭
ill‬
-‭
‭ d
‬efined‬‭ and being‬‭set‬‭
to‬‭ 0.0‬‭
in‬‭
labe‬‭ls‬‭ with‬‭no‬
‭predicted‬‭ samples‬ .‬‭
‭ zero_division`‬‭parameter‬‭
Use‬‭̀‬
‭ to‬‭ control‬‭ this‬‭behavior‬ ‭.‬
‭_warn_prf‬‭
(‭a
‬verage‬‭
,‬‭modifier‬‭,‬‭ ‭,‬‭
msg_start‬ len‬
(‭
‭ r
‬esult‬
)‬
‭ )‬

‭‭
C : ‭\‭U
‬‬ ‬ sers‬‭\‭R
‬ ajesh‬ ‭A‭
‬‬
\ ‭anaconda3‬‭\envs‬‭\‬‭tf‬‭\‭
‬ ib‬
l \‭
‭ s -‭p
‬ite‬
‭ ‬ackages‬‭\sklearn‬‭
\‭m
‬etrics‬
\‭
‭_ :‭1
‬classification.py‬
‭ ‬34‬ ‭4‬‭
:‬
‭UndefinedMetricWarning‬‭:‬‭ Recall‬‭ and‬‭ F‭
-
‬‭
s‬core‬‭are‬‭ ill‬ -‭
‭d‬efined‬‭and‬‭ being‬‭set‬‭to‬‭
0.0‬‭
in‬‭
labels‬‭
with‬‭ no‬‭true‬
samples‬
‭ .‬‭
‭ zero_division`‬‭parameter‬‭
Use‬‭̀‬
‭ to‬‭control‬‭
this‬‭behavior‬‭.‬
‭_warn_prf‬‭
(‭a
‬verage‬‭
,‬‭
modifier‬
,‬‭
‭ ,‬‭len‬‭(‬‭
msg_start‬
‭ result‬
)‭
‭)
‬‬

In‬‭
‭ [‬10‬
‭ ]‬
‭ :‬‭
‭ Set‬‭the‬‭
#‬‭ size‬‭of‬‭the‬‭
plot‬
plt.figure‬
‭ (‬
‭figsize‬
‭ =‭
‭(‭10,7‬‭
‬‬ ))‬
#‬‭Create‬‭a‬‭
‭ colormap‬‭for‬‭
red,‬‭green and blue‬
cmap‬‭
‭ =‬‭
ListedColormap‬ ‭'‬‭r‭'‬‬‭
([‬
‭ ,‬‭'‬‭
g‭
' ‬‬‭'‭
‬‭
, ‬ ‭'‬‬‭
b ])‬
#‬‭
‭ Plot Sepal‬
‭ ‭(‭
plt.subplot‬ ‬‬
2 ,‬‭
‭ 2‭
,‬‬‭
1‭
)‬‬
‭(‭
‭lt.scatter‬
p ‬ f‬
d [‭
‭'‬‬ ‭'‬‭
sepal.length‬
‭ ],‬‭
df‬
[‬
‭ ‭'‬‭ ‭'‬‭
sepal.width‬ ],‬‭
c‭
=
‬‬ ‭(‭y
cmap‬
‭ ‬ _actual‬‭
),‬‭marker‬‭=‬‭'‭0
‬ ‭'‬‬‭
,‬
s‭=
‭ ‬‭2
‬ 5‬‭
)‬
‭ (‭'‬‬‭
plt.xlabel‬
‭ sepallength(cm)‬
'‬
‭ )‬

‭lt.ylabel‬
p ‭'‭
(‬
‭ ‬ epalwidth‬
s
‭ ‭'‬‭
(cm)‬ )‬
‭(‭'‬‭
plt.title‬
‭ ‬ epal (Actual)‬
S '‭
‭)‬‬
plt.subplot‬
‭ (‭
‭2‬‭
,
‬‬‭
2‭
,‬‬‭
2‬)‬

‭(‭
plt.scatter‬
‭ ‬ f‬
d [‭'‬‬‭
‭ ‭'‭
sepal.length‬ ‬ ,‬‭
] df‬
[‬
‭ '‭
‭s ‭'‭
‬epal.width‬ ‬ ,‬‭
] c‭
=‬‭
c ‭(‭
‬map‬ ‬ abels‬
l ),‬‭marker‬‭=‭
‭ ‬‬
' ‭0‭'‬‬‭
,‬‭
s‭
= ‭25‬‭)‬
‬‬
plt.xlabel‬
‭ (‭
‭' ‬epallength‬‭(‭
‬‭
s ‬ m)‬
c '‬
‭ )‬

plt.ylabel‬
‭ (‭
‭'‬‭
s
‬epalwidth (cm)‬
'‭
‭)‬‬
‭ ‭(‭
plt.title‬ ‬‭
'S ‭)‬‭'‭
‬epal (Predicted‬ ‬‬
)
plt.show‬
‭ ()‬

In‬‭
‭ [‬‭
]‬:‬

‭sepalwidth‬‭(‬‭cm‬‭)‬
‭4.0‬

‭3.5‬
‭3.0‬

2.5‬

‭Sepal‬‭(‭A
‬ ctual‬‭)‬
‭Sepal‬‭(‭P
‬ redicted‬‭)‬
4.5‬

‭4.5‬
‭sepalwidth‬‭(‬‭cm‬‭)‬
‭4.0-‬

‭3.5‬

‭3.0‬

2.5‬

‭2.0‬
2.0‬

‭4.5‬
5.0‬

‭5.5‬
6.0‬‭6.5‬‭
‭ 7.5‬‭sepallength‬‭(‬‭cm‬‭)‬
7.0‬‭
‭8.0‬
4.5‬

‭5.0‬
‭5.5‬
6.0‬

6.5‬‭
‭ 7.0‬
‭7.5‬
8.0‬

‭sepallength‬‭(‬‭cm‬‭)‬

You might also like