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

Mall Customer Segmentation Using KMeans Clustering Algorithm and Classification Algorithm

Mall Customer Segmentation and Classification using Unsupervised and Supervised Learning

Uploaded by

Daniyal Masood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
36 views

Mall Customer Segmentation Using KMeans Clustering Algorithm and Classification Algorithm

Mall Customer Segmentation and Classification using Unsupervised and Supervised Learning

Uploaded by

Daniyal Masood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 40
Importing Libraries for Data Processing, Visualization and Train Model Lxport pumpy 05 99 ‘import pandas 95 pa inport matplotlib.pyplot a5 ptt Snport seaborn as sn # For clustering Algorithe from sklearn-cluster import Kans fram skLearn_neteies import silhoette_ scare # For mittctoss-clossiftcation of fron skeaon.ensenbe apor= GrsctentboosngclassSfien 4 For performace metrics of Classification from sklearnonetries nport accuracy. score Snport plotly 38 py Anport plotly.graph_objs 25 go “tfor dota preprocessing ond spliting of test and train data from sklearn-rodel selection deport tratn test split Lnport sklearn. preprocessing a5 pre, process for evaluetion metrices for final nodelpt Snport sklearn netics 25 em Exploratory Data Analysis (EDA) fF = pa.read_esw("C:\\users\\Wp\\tnage Processing and Conputer Vision Lectures and Labs\\practice Project\Wall_Custorers.csv") eFsnead) Customeri0. Gender Age Annual Income (k$; Spending Score (1-100) ° 1 Mae 18 5 38 1 2 Male 2 15 8 2 3 Female 20 fa ‘ 2 4 Female 23 6 7 4 5 Female 3 ” «© es describet) Customer) Age Anal Income (ks Spendng Score (1-100) ‘count 200000000 200000000 2o0n00000 2oon00000 mean 09s00000 28850000 aso so2o0000 sta s7aT918= 13960007 25264721 rae min 1.090000 18000000 ‘so00000 1.00000 asx sa7so000 28750000 00000 2arsto00 ‘0% sonso0000 26000000 100000 sooo0000 ys% 1s02so000 2000000 aonoo00 ‘3000 ‘max 200000000 7000000 'aa00000 x.000000 eF-snf00) Rangeindex: 200 entrLes, @ to 198 3ata colums (total 5 columns) * Colunn Non-4uld count 9 custonert0 200 non-null inte 1 ender 200 non-null object 2 Age 200 pon-null —intea 3 Anal Income (K$) 288 non-null int 4 Spending Score (1-100) 208 non-null int6t types: imtea(a), object(2) senory usage: 7.9 KE sns.displot (af Age" J kde-true) Ceeaborn.exisgrid.Fecet@rld ot Ox2e8iS7e00) out (35) 450 Age ‘sna. dlaplot(df{ ‘Annual Tncone (48)"),kéo-True) «seaboon.axisgrid.FacetGrid at 322650200180) 6080100 ‘Annual Income (ks) [37], [ansadlaplot(aFt Spending Score (1-100)"],decTrue) cunjsy), 40 60 ‘Spending Score (1-100) Feature Selection (38), [Data = eff {Anaad Income (K$)*, "Spending Score (2-100)"}] Data. head() ‘Annual Income (KS). Spending Scove (1-100) ° 15 8 1 15 2 2 6 5 2 6 7 4 7 0 bata. plot(einde"scatter", ‘serannalTneont (K5)", yerSpending Score (1-288)", Figste-(30,7)) pit.shou() 200 80 . 3 60 2 240 . & 20 . ° 20 2 60 100 20 x40 30 Annual income (ks) Finding Optimal Numbers of Clusters with Elbow Method warnings. Filterwarnings(*ignore") for Kin range(t, 18) n= seana(@nclustersek, inite"k-neanse+* max, Ster=2000) kn = kn. fit (Data) MeSS(i] = hr Srerei, sns.pointplot(x=1ist (Hs heys()),yolist(Wess.values())) ple-alabel CNinner of clusters. (K)") prt-ylabel Cwss") PLL-LtLe(“Elbow Method for optinal K°) plt-shot() Elbow Method for Optimal K 250000 200000 100000 0000 7 2 3 4 5 6 7 6 Number of Clusters (k) Train Model using K-Means Clustering Model = Mheans(n_clustersss,inite"koneans" max ster1000) ode. f8e(osts) . Wteans ‘feans(nax_iter-1000, n_clusterss5) print( “Clusters” Wo labels) Hlusters [@3.03030303030303030303030303030303036 BOSDIOCO IEMA CLAEHA EAA LAME ALAA ESAS Deedee ga ed ae daa had ed seca aead eg aaasaagd Saadaagaaaaaizaaraigradzagazi2aaiza2d 2122212121242123212121212121212121217 121212421212121 print( Centroids” Model.cluster_ceaters_) fentroids [[26.30454763 20.01304348 eo, 846158 62.12820513] 8.2. 17.11428571] 25.72727272 79.36362636] s5.29a062 49.51851852]] controls = Model cluster_contors, cluster_pata = pata.copy() Chaster_pata[“clusters"] = Model. fit_predict(oata) ‘custer_pata. head) ‘Anal Income (S)_ Spending Score (1-100) Custer ° 15 » 3 1 15 a 6 2 6 5 3 2 6 nm oc 4 ” o 3 Color = (Red Orange, “Black", “Brown”, Violet”) {luster_Sata["olor"] » Closter_onta[Clusters”].map( labs 9 le. figure(Figsize=(20,20)) ple-seatter(Cluster_oata["Annual I9cone («$)*), ‘luster atal"spending Score (1-100)"], cotintee Datarccioe). 5e3te) pit.seateer(Centrosas[:,0] ,Centrofds[:,1], "blue", #2250) plt.show() » x i: oe 7” aoe ot, | |<. 2s s « : af 3m € oo . . - « . . ole . . . 9 . =| e s a. —- © 4... . te : _ Ye 4 . Evaluation of Model with Silhouette Score Ispels = Hoge labels, stTnouette,seore(Dstey labels) a ss20919744064e stinovette = () for kin range(2.8): bem sense” enn, iteretsen) ‘ken. fi0(Data) Stihouettert] « silhouette seare(Dota, ka. Labets_) sns.pointplot(x=list(sithovette,keys()),y=List( Silhouette, values())) ple-alabel *Nunner of Clusters. (K)") plt.ylabel(“Sttnouette scores") PLL. title(“siitouette scores or each K°) plt-shot() Silhouette scores for each K oss, oso silhouette Scores 030 2 3 a 3 é Number of Clusters () Again Train Model with all features Finaibata = of{{"Age", "Annual incona (KS)*, "Spending Score (1-100)°1] ness = for k in range(t,20) ken = sears (7_elustansck, anite"-neansi+"ynax_iter=1000) kas ke. fit(Finalbata) NeSsck = becinertia, sns.pointplot(x=1ist (as heys()),yoList(Wess.values())) ple-alabel CNunner of clusters. (K)") prt-ylabel Cwss") PLL-LtLe(“Edbow Method for optinal K°) plt-shot() Elbow Method for Optimal K 200000 280000 2200000 wess 250000 290000 0000 7 2 3 4 5 6 7 Number of Clusters (k) Model? = kheans(a_clusterss6, instore ode12.#1t(FinalData) nase" max Sters2000) keans(nax_ite 1980, cluster Hinaloata[ Clusters") = Nosel2.fis_presict(Finalbata) Finalbata.heae() ‘Age Annual Income (KS) Spending Score (1-100) Clusters o 9 15 o 4 a 15 nog 20 1 . 4 ae 1 mos aon ” o 4 3D Visualization Finatbata["tabels"] = Labels trace = go-Seatter3e( xeFinaloata[ Age"), yerinaloatalaomuaiTncone (&$)"J> EoFinalbata[ "Spending Score (2-1€8)"], Iarkersdict(colorsFinalbata["Labels"], size-5, Line-dict(color-Finalbata("Labels"], width-12), opacity-®.8) ) fata » ferace] Tayout = go-Layout( itles‘clusters", Scene-aict( waxisndict(title = "Age'), yaxssdtee(estle © “honsal Income (&8)"), datsdict( tithe = “Spending Sore 2-88)") ‘agave = go.Figure(cstaresta, layoutelayost) pyrotfline.iplot igure) pltcshou() Clusters Performing Classification using new clustered dataset DataPreproessing (Encoding and Scaling) ‘ordinal_encosing-pre_process.oréiralencoder() srenot_encousng.pre_process.cneiottncoser() Standered_scallingspre_ process. standardScaler() ‘ninax_scallingepre, process. Winaxscaler() Create New Dataframe using previous dataframe Cluster patafrane = of nerge(Finalbata, how"right"),drop({"Custoneri0"],axis-4) {huster_patarrane.hesd() Gender Age Annual Income k6) Spending Sco (1-100) Clusters Labels 0 Mae 19 15 we o4 4 1 wale 21 15 nos s 2 ‘emie 20 6 6 4 4 3 female 23 16 nm os os 4 Femle 31 ” o 4 4 Spliting of Features and Labels xocluster_patafrane.iloc{:.@:4] ¥-eluster_pataFrane:ioet=s-3] Create Column Transformer for the features and lables ‘from sklearn. compose Inport nake_colunp_transforner transform xonake_colum_transforser( (ePéinal_encoding , [enéer")), (olomax_scalting; [Age's Annual Tacone (H8)", Spending Score (2-128)"1)) wend) Gender Age Annus income (k$) Spending Score (1-100), ove 19 15 Ea 1 wale 21 15 " 2 vemie 20 6 6 3 female 23 16 7 4 femle 31 ” 0 Yinaad() a5 204 35 4 a None: Labels, dtype: int32 Make Fit Transform to convert the features into numbers eae aa ROO) array([[1. Meee a are 0.057690, 6. 0.81632653), elaseacist, @.eaeise72, a.esie2041), Scsuises,eaeisr2 sie) 6:0762308, 6.01639344, 0.76530612), 6.32600308, o.e24soe16, 0.251020), Suis, eens, S758), 6.23076823, 0.03278685, 8.7244858 |, e.a4a20768, 0.03278689, 0.1265206), 0-32692506, 6.03276589, 1. L @.7o02677, @.ocone261, 0114285724), e.sasiaec2, ovodooenel, 0.755102 ], @-36538462, @.04008361, 0.12264658), lavcanses, @.oco0e261, 0.79591627), 6. 3z600368, @vosoieer3, 0.34693878), Glaseasise, ovoso1ee33, 0166326521), @.65384615, 6.06557577, 0.26571425), @.32692506, 0.06557577, 0.98979552), 6.32600308, 0107377000, 0.34693878), e.1a4e1s38, 0107377089, 0.73469208), @-s3easisé, 0.09196721, 0.04081633), 0.25, @.08196721, 0.73460388), @:60230765, @,10655738, 0.15265306), eins, Ssse) ®. Soeaaee, ereizzeso J, ‘sz3e7ea2, e.3e6i2245), 29615385, o.er7ssin, 30760231, 03081224), 05760231, o.73eea3ea), 67307692, b.eaesi204), oe. 9.92857143), 59615385, 014754098, 8.13265306], as7eaaat, o.le7sdead, 0.81632689], 1587377 , 0.16326531], 21557377 | 0.73469388), Sasisaes, o-19002787, 0.25510204], ‘aseaeisé, 0,19032789, 9.735102), soseasas, 0,29852459, 0,24693878), su53edea, o-1eas24s9, 0,92857143], 0,57692306, 0,19672131, 0.3571¢286), 0.25, 0.19672131, 8.612269 ], 6:soeisaes, @.19672131, 812755162 J; e.1usiaee2, 0119672131, 0165906122), 6.61538462, 0.20491803, 0.55102041), 0117307682, 0.20491803, 0.46938776), i ee ae 0.25, 0.20491803, 0.41836735), evsoeasaes, 0122131188, 0.520¢0016), Suis, zt, ocr) 8: 7aeasise) 0:229S082 | 0.60204082), evexsaeee2, 0.2208082 | 0144297959), ScSrszi, Gaze: | en”) 898076823, @.73770492, 0.45918367], e.a7se7ee2, @.25400836, 0.51020488), e.erae7ee2, o.2sanonne, 0.45918267), 1 » 0.25409836, 0,56122448), Scouser, eases, estas), 0,94230765, 0.31967213, 6.40816327), e:sseacise, @.31067213, 0143877551], @.05769231, @.31967213, 0.57162857), 0,96153846, 0,36065574, 0.55102041), e. 836068574, 040816327), 6:s7ea2n08, 0.385206, 0.48979502), e.ezie7e02, 0.885246, 0.39795018), 0.26909077, 0.36885206, 0.41936735), 0.113862, 0. 36885286, 0.520086), MSPS EL, 0117307682, 0.36885206, 8.5), e.s7en2ne8, @.37704918, 0.41226725), S.caise, erat, .ss2), 6159615385, 0.382459 | 0.47955184], e.a4a3e768, @.38s24s9 | 0.59183673), Scsss, eaeats | sie) 6.as76s231, 0.382459 | 0.41836735), 92397602, 0,39344262, 8.5, eo23e7e, 0,30344262, 0,45018367), 3934422, 0.42857143], 39544262, 0.47950164), 393462, 0.52040816), 1923077, 030344260, 0,5498i6%3], Se4eisse, 0,401630%¢, 0.41836735), Sieserr, Saisie, se, tao76a2s, 0,2s00ie%9, 0,34693878), 42307602, 0,25001699, 0,95918367], ‘Tabasisé, 0,25001639, 8,16204082), ‘Jeseisae, 0,2590ie%9, 6.755102), 0.55769231, 0.45901638, 8.08163265), Abasasas, 0,25001639, 8.75510204), su4sisae, o.as7aisit, 6.23673469), @a5720311, 0.71426571), 247540588, 0. 04081633), 247540588, 0.6877551 ], e.a7sdoone, 0,06122648), 30023077, 0.47sdoaed, 0.73269388), 0.01923077, 0.48360656, 0,09183673), 0132692306, 0.48360656, 0.7244858 ], 75, 0149160528, 0.040e1633), 6.26002077, @.49180328, 0.93877551), o.15230768, 0.5, 0.39795518), 0.26523077, 0.5 | 0.8755102), EGE eeiae ee, 0/10230765, 0.50819672, 0.97959184), 15700306, 6. 50e19672, 0135710266), S27, S072 8.70796), 6.30768231, 0.51639344, 0.90816327), e.asevean3, o.sisie2ee, 0.16226521), Sess, stsset 8775) 6. 3a4s1s38, 0.51639344, 0. 76550612), ‘576921, 0,51639344, 0,15306122], a7ae7602, 0,51639344, 0.89795918], 33a7ea08, 0.51639344, 8.78571429], 33a7eaa8, 0.516394, 6,73450288), ‘yaareaas, 0,324soe16, 8,34693878), use, 8 Sani, @ S673, esaaaais, o.soe3cese, 0.12244808), 23076908, 0,308360se, 0,86734604), 76923077, o.sa83sese, 9.14285714), S7ao7ea2, o.saq3sese, 0.69387755], @.7aB461S4, 0,63934426, 8,13265206], ‘Jaegaiee, e.e3o3uae, 0,90016327), 3esaeaea, o.672i31is, 0,21632653], 35023097, 0.67213115, 9,86734604], .68052787, 0.14265728), (2.68052787, 0.687551 ], ‘aaaeren, 0,69852459, 0.3877581 J, 2ao7eans, 0,69852459, 0,97259184], 0.69020765, 0, 70491803, 0.23469388), 0119230765, 0: 70491803, 0.68967347), e.4aaie7es, @.7a1siieg, 0.16226521], @.s4eisies, @.7ausiies, 0185710286), 0,30769231, 0,72131108, 0.2244858 ], 0.26903077, 0.72131188, 0.69387755), a +» 0.28846154, 0.80327869, 3 | 0-38461538, 0,80527865, a | 0.26923077, 0,50983607, pd. oataFrane(processed_x) 2 2 4 195 196 187 ° 10 10 oo oo oo oo oo 10 10 10 1 2a ‘ot9231 ag00000 034775 ‘uosrés2 400000 086227 oxedsz ro0eie7 aosize oseis¢ aooeie7 0775510 sonar 201638: 0297089 3 1860656 0795918 staan agose36 0275510 en raonens 07609 ze231 1000000 0.173462 22076 1000000 003672 200 rows 4 columns mpc) ra 091836735), 35306322), 7950187), e.zrssie J, 74489796), 0.17346939), essere] array([[4), 5] process. ondinaléncoder() oder #it_tranefora(ap-e_{¥1) processed_y array([[4.], 3. Spliting of dataset into training and testing parts rain y test petra 1 Initializa the Gradient Boosting Classifier for model training sodel = GradientsoostingClassi¢ier(_estinators=s6,randon_state-2) model. ft CEratn_xetrain-y) GracientBoostingclassifier GradientBoostingclassifier(n estinators=s8, random state=2) Make Prediction of test dataset pred_y-nodel.predict(cest_s) aeeerel aa tety from sklearn-utils inmort all_estinaters estinators = sl] estinators (type_filter="classi ier") odel rome = {1 odel_preeision = () ‘for name, get-nodel in estinators: ty mode = got_naded() model. Fie(trainx, train y) ioded_precision: append(sh.prectston_score(test_y, pred.y)) Itodel-rane.apoene(nane) except Exception ase ‘rine(*unablen to ingort *, name) peinte) (nobles to import AdsBecstClassifior Target is multiclass but averagesbinary’, Please Jnablen to inport BaggingClassiier Target is multiclass but average="binary’. Please Jnablen to import BerroulTiNe Target is multiclass but averages"binary’, Please Jnablen to import. CalibratedClassifiercy Target ss multiclass but averoge="binary'. Please Jnablen to import. CategoricalNs Target Ss multiclass but averagee"binary’, Please Jnablen to Inport. Classifienchair Snablen to TaportComplenentvé choose jasechain. ~Init_() nissing 1 required positional argunent: another average another average another average another average another average setting, setting, setting, setting, setting, base_estinator’ Target is multiclass but average~"binary’. Please choose another average setting, Jnablen to Inport. DecistonTreeciassi¢ier Target ss multiclass but average~"binary'. Please Jnablen to Inport. OumyClassifier Target ss multiclass but average~"binary’. Please Jnablen to import. ExtraTreeClassifier Target is multiclass but average="binary’. Please Jnablen to Inport. ExteaTreesClassifier Target is multiclass but average="binary’. Please Jnablen to inport Gaussianhé Target is multiclass but average="binary’. Please Jnablen to Inport GaussianProcessclassifier Target is multiclass but average="binary'. Please Jnablen to import GradientSoostingClassifier Target is multiclass but average="binary'. Please nablen to Inport MistGradlentBoostingClassifier Target 1s multiclass but average="binary'. Please Sablen to import #Neighborsclassifier Target ss multiclass but average="binary’. Please Jnablen to import. LabelPropagatior Target is multiclass but average="binary’. Please Jnablen to inportLabelspreading Target ss multiclass but average™'binary’. Please Jnablen to import. LinearDiscraninantanalysis, Target ss multiclass but averoge~"binary'. Please Jnablen to inport LinearSVe Target ss multiclass but averoge~"binary’, Please Jnablen to import LogisticRegression Target ss multiclass but average~"binary’. Please Jnablen to ingort LogisticRegressionC\ Target is multiclass but averagesbinary’. Please snablen to import MLPclassifier choose choose cnoose croose choose noose noose noose cnoose another average another average another average another average another average another average another average another average another average another average another average another average another average another average another average Target ss multiclass but averoge~"binary’, Please choose another average Jnablen to Inport multioutputCiassifier vultioutputclassifier. init _() missing 1 required positional argument: setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, setting, “estinator* of of of of of of of of of of of of of of of of of of of of of (Mone, [Mene, [Wone, [Mene, (Mone, IMene, IMene, Inene, Inene, Inene, [Mene, Inene, Inene, Inene, IMene, Inene, Inene, IMene, IMene, [Mene, (Mone, IMene, ‘lero’, ‘hero’, ‘lero’, ‘kero’, ‘lero’, ‘hero’, ‘kero’, ‘tcro', ‘hero’, ‘hero’, ‘hero, ‘hero’, ‘hero’, ‘hero’, ‘tcro', ‘hero’, ‘tcro', ‘hero’, ‘hero’, ‘hero’, “nlero’, ‘hero’, “nacro', “weighted ‘wacro!, ‘welghted') “nacro', “welghted'] ‘wacro', “weighted! ‘nacro', ‘weighted! ‘wacro', “welghted') ‘wacro!, “welghted') ‘wacro!, “welghted' ‘wacro!, ‘welghted') ‘wacro!, “weighted! ‘wacro', ‘welghted') ‘wacro!, ‘weighted! ‘wacro!, ‘weighted! ‘wacro!, ‘welghted') ‘wacro', ‘weighted! ‘wacro!, ‘welghted'] “wacro!, “welghted') ‘wacro', “weighted! ‘wacro!, “welghted') ‘wacro!, “weighted! “nacro', “weighted “wacro', ‘weightes') (netllen to deport: MaltinonislNe Target is multiclass but averages"binary’. Please choose another average setting, one Jnablen to inport. NearestCentroic Target is multiclass but average="binary’. Please choose another average setting, one Jnablen to import muse Target is multiclass but averages"binary’. Please choose another average setting, one Jnablen to import. OneVsOneClassiier anevsoneclassifier, init -() alssing 2 required positional argunent: “estimator Snablen to import GievstestClassifier DnevshestClassifier. init _() missing 1 required positional argument: ‘estinator Snablen to ingort OutputCadeClasei fier autputcodeclassifien, init _() nissing 1 required positional argunent: “estimator Snablen to inportasivelggressiveCleseifier Target is multiclass but average="binary'. Please choose another average setting, one Jnablen to import Perceptror Target is multiclass but average="binary’. Please choose another average setting, one Jnablen to Inport. QuadraticDisceininantanalysis Target is multiclass but average~"binary’. Please choose another average setting, one Jnablen to Inport Radiushelghborsclaeei fier Target is multiclass but average~"binary’. Please choose another average setting, one Jnablen to import. RandoaForestclassifier Target is multiclass but average="binary'. Please choose another average setting, one Jnablen to Inport. RidgeClassifier Target is multiclass but average="binary’. Please choose another average setting, one Jnablen to import. RidgeClassifiercv Target is multiclass but average="binary’. Please choose another average setting, one Jnablen to Inport. scbclassifier Target 1s multiclass but average="binary’. Please choose another average setting, one snablen to inpore sve Target 1s multiclass but average="binary’. Please choose another average setting, one Jnablen to inport. stackingClassiier Htackingelassifier,. init--() alssing 1 required positional argunent: “estimators Snablen to import VoingClassifier Votingclassifier.init--() missing 1 required positional angueent: ‘estinators results-pd.DataFrane({"¥odel Nane":nodel_oat 1 *hodel precision®inedel_precision}) Model Name Mode! precon of of of of of of of of (Mone, [Mene, [Wone, IMene, IMene, Inene, Inene, Inene, [Mene, Inene, Inene, Inene, ‘lero’, ‘aero’, ‘lero’, ‘atcro’, ‘cro’, ‘atcro’, ‘cro’, ‘tera’, ‘atcro’, ‘cro’, ‘atcro’, ‘atcro’, Make Inverse Transform for the predictions in real form pred_y_€lass-ordinal_encocer.snverse,transforn(oree_y) predcyrelaee| Rest yctlass-ordinal_encoder.inverse_transfora(test_y) ‘nacro', ‘weighted! ‘wacro!, ‘welghted') ‘nacro', ‘weighted! snacro!, "wanted ) seacro!, "wanted ] Seacro!, "welahtes'] seacro!, "welghtes'] Snacro!, "welghted'] Seacro!, "welghtes') Snacro!, "welghtes') seacro!, "welghtes') “wacro', “weightes') Tase-test_y_Clase.reshape(2, 3) Analysis on the Prediction and Actual Class Value prediction = pl.Datarrane({‘Original Value’: test_y C1ass[@], “Predicted Value": pred y_cass(e}}) Orginal Value Predicted Value ° c a 1 5 5 2 4 4 a 2 4 2 % c a % 4 4 n a 3 n c a " c a 80 rows «2 columns Prepare Classification Report print(sn. classification report(test_y,pred_y)) arecision recall f1-score support 00 0. ego oma ve ease ee Se tease 42 eee 93 € se leak Ola 5 accuracy 090 6 nacroag = 8930.89] weighted og = 918.98 838 Accuracy of Model print(sm.accuracy_score(test_y,pred_y)) 29 Precision of Model print(am. precision score(test_y,pred_y,averages"icro")) 29 Confusion Matrix of Model Drint(a confusion aateix(test_y,pred_y)) [is ¢ 20 0 a} 2 8]

You might also like