You are on page 1of 6
2117124, 9:40 PM \_ Data Preparation and Data Prepocessing fron google-colab ingort drive vesnount("/content ive") Mounted at /content/drive fsnpoct Library yang dibs neon Sarort noxplotliv-pyplot 35 9 ‘enanpiikan #1le gar perangkat ke goole cola = pa.read_c50("/content/drive/MOrve/BANAW AI/LOWBA AE 2022/0KTASET LATINAN/ Auton atatenet) symboting "OAL make Fee 2 1 > gilt oes 3 2 18h aut ons ‘ 2 18h autos li ua kal (atau tekan Enter) untuk mengedit pd. set_option(“display.nax_coluens' mendesketpsshan d acescrine() mia 79% 2.000000 2.000000 50000 102400000 ereanape 285, 28) fone) renee ‘41.100000 19, 100000 ‘enanpittan info getatl dark dataset aessnto angelndex: 205 entrses, @ 0 208 ‘0:300000 18:900000 Lathan data Mobile jpynd -Colaboratory Style wheels 400000 '56:500000 exon tw *488,000000, 2936,000000 61.000000 141000000 data.csw") ws 1766 7.000000 400000 Tength wiath hedght ‘9.000000 ‘0.000000 hntps:ifolab research google.conisrive1Ol.560WodgTBTAWCOg0T)-Feto2uIN?authuser=2#scrolTo=uKvIW-s-Wb7 1&printMode=rue aaa 1.000000 :4,000000, ‘type 18 2117124, 9:40 PM Data columns (total 26 columns) colum Symbol tn-of-doors boay-seyle Grivecunesls| ‘egine-location Tength weigh corb-wesgnt ‘enainetype tore horsepaver peak-ro highway price types: #loaten(s), intea(s), object16) Eonpression-ratto freory usage! 2.8) KB Mon-wtl count 305 poner 205 noncrat 205 aon-null 298 monet 285 nonenld 285 none 205 noneralt 285 nonenald 288 nonenald| 295 nonerut 205 noneralt 285 nonenald 395 noncrat 205 noncralt object ject object ject object object object ject ‘fasate Toate abject nese object object object ‘Hoatos object fbject nese object ‘encart dan nenarpilian juniah nilat yang hilang sf.) sun) symboling oayestyle ‘engine-Location fetare Carb-vesght engine tee cnaine-size onpresston-ratio horseparer| ahr ‘types inte Amelinat 4si/ndlat dart kolon nornalized-losses AF( normal izee-losses"}.value_counts() hntps:ifolab research google.conisrive1Ol.560WodgTBTAWCOg0T)-Feto2uIN?authuser=2#scrolTo=uKvIW-s-Wb7 1&printMode=rue Lathan data Mobile jpynd -Colaboratory 206 2117124, 9:40 PM Lathan data Mobile jpynd -Colaboratory sengubah dats yang tid valid (2) menjads angea ar sa replace(’ fF = ae repnace(’ d= ae repiace(’ df = dcrepiace({ ft = areplace( ff = acrepiaced 4 = dcreplacet fe = ae creplacet af = af reptacets ff = a reptace(( fF = af repnace({ ff = ae repiace({ = af repuace(, ff = areplace(’ 4 = dcreplacet ae > aerepiacet 4 = a creplocet fF = af roptace(( ‘engubah type date menjads runerie supaya bisa die pd.to-nuneric(uf{ nornalized-losses"]) runerie(ue nun-ot~asors" |) F{ "noon szed-losses") {¢(‘nuneof-doors"| = od (¢{'nun-of-cyliaders"] = pdstonune tore’ :"?"),8) 2) 2 }8) rut-of-deors':"two"),2) ru-of-600rs": "#00" J) ru-of-d00rs":'2°}48) run-of-eyliners run-of-cyingers| ore" ?,8) scrote’ :'?"),8) 40" }2) ‘eee, 3) our'),2) ve", 5) 506) ‘welve'), horsepowen":"?"),0) peaks ron’ :°7"2,8) prise’s"?*),0) (r{unot-cyLincers*}) G¢{" stroke") = o.to_nunertcter{stroxe"]) ¢(nonsepover' = pds to_nureric(et norsepower’ {¢('peskerpn'] = peto_novense(@/Tpene-npn'T) at{'price'] = pa.tornuneric(fl pe to-mumer ie AFT" eurbowesen® hntps:ifolab research google.conisrive1Ol.560WodgTBTAWCOg0T)-Feto2uIN?authuser=2#scrolTo=uKvIW-s-Wb7 1&printMode=rue > Earbewosent 1) 36 2117124, 9:40 PM Lathan data Mobile jpynd -Colaboratory ‘Ploreaisash nengguiatan sinple future scaling. Gtrsynboling = dtesynboling / $6 synmoling-maK0) 4F{"noomal zeeclosses"} = sf[rovmalized-lorees') / af{“normalszed-losses].nax() AF {"nuneof-coors"] = Af["nun-of~doors") / af{nun-of-doors"] max) GFL ‘abeel-base'] = Gf[ wheel-base"] / df wheel-base"Jemox() dfs tengen = of-lengeh /"a¢-tength.#3x() devdth = df-uidth / dfawidthenaxt) height = ofsneigne / 6¢-hetgnt. 93x) Ge{"cunbeneaght'] = a¢[curd-wedght’) / off curb-wedgre"].nax0) {¢("numeofecylinders"] = of{ ninaot-cylincers’] 7 a 'auncof-cylinders]-nox() {eT enginacesze'] = sf[-enginensize") / off ongine-size']-nax() AF.stroke = efvstroke / #f-rtrote.nax() AF("conprasston-ratio"] = df{"compression-ratio') / af[“conpression-ratio"]-mae() “F.horsepover = df.hersepower/ df horseparer-nsx() {F{"paakerpa") = aF{"peakeran")/ dF{"peakergn".ax() GF{"ekty-npg") = ef{eaty-rag’)/ aff eaty-nog”).max0) Ge{mighaayenbe') = 6¢{"highaay-noR’)/ 6 "nighway-npa"}-moX() Gt.price = efverice/ df. price.nax0) Gradescribe() ormanizes mayor nee eet wath eta a welgnt cytinoers “size SPOKE symboling mean 0278049 0.381260 O.77O171 O.81645 aa26979agTTSHB 0.9E409 O2H521 0.965041 OsbuRG ——O.TEEHAA 25% 0900000 0.900781 0500000 0781638 0.799195 ORHESe 0.809505 O27H45 OSRIIa O.20TSKG 0743405 som 020999 0402544 1000000 0.807318 0.892202 0908947 904682 O809706 osRIIa 0.360008 o.7HHOE \ Data Visualization ats conn() -style-backgreund-gradient() f-core(), style background gradient () ~ symboling "SC! Length width hetght wien ene scomoression™ city-nog Mem symbolng 00057 -BSI854 -a9sr612 -azv9I9 sKio1 —-o22TE=% 10879 osresis 2008879 9000 weatbase —-0sst8st ono azost4e 05808 oss a2ssree aaroei4 —-ostos2 length 9357612 0974587 1000000 oBAHIB o4o:0R9 —oBrTr2B nase ouseera -asroene 07012 wa 920289 0705144 O84:s18 1200000 027219 noTOR O75 oen29 ascam 9677218 heat 0541008 0588195 04a: posse agers aster ageasio 0307058 curbonioht 227697 9770 987 2 02 ‘ soe ousras2 azote ores ngiwsize 0405790 0505009 600 ss osr9 oe , ooassrs 2953858 9577470 semresion —o7e516 oar oseti20 02 wise gamer 10000 022 2eseat chy-mpg 0m38829. 947044 0570009 9.882706 -o0%HsKO —o7sTANA —-nosoHt8 aaatros 0000090 hntps:ifolab research google.conisrive1Ol.560WodgTBTAWCOg0T)-Feto2uIN?authuser=2#scrolTo=uKvIW-s-Wb7 1&printMode=rue 46 2117124, 9:40 PM Lathan data Mobile jpynd -Colaboratory ‘Plenganalisis data dengan cara newvisualtsasikan data dengan scatter plot atau diagran tittk pit-seatser(aflenginessize'I,e¥L price']) pit.saabel(“ergine-size") pitiyisber price") eer} 40000. " ” e+ 2% 30000: * ® 20000 ode 3h se yet |. seria ‘Plenanpiikan scatter plot dark date yg nenilski conelast tertingat ke-? pit. seatcor(af{‘curb-xesent'],ef[ price’ |, color="red") pit.saabel(“curo-wesant™) pit.yiabel price") neo 40000 . 2 . “i : : 30000 . « 20000 re scgetee § ‘. ee curb-weight fvariabel x Sri berist cataraata yang akon digunatan sebogal Srdependent untuk perodelan dan aralisis selanjutnys xe af-tiee(:, (23,36)] ‘Menganbit semua baris et xolon price dan nenyimpantya paca variabel y, ys aff price’) — - - “ hntps:ifolab research google.conisrive1Ol.560WodgTBTAWCOg0T)-Feto2uIN?authuser=2#scrolTo=uKvIW-s-Wb7 1&printMode=rue 56 2117124, 9:40 PM Lathan data Mobile jpynd -Colaboratory ‘remagh data nanjadt 2 yaitu data srain(gelatinan) an data test(pengufsen),nenggunakan train_sest_split sari situ akon mendapatkan 4 argunent yaitu = x_train, x test, y.train, y.test soising ada argument x can y Kenuatan ada argument tex¢_size yoieu untue sengatur ukuran ders aata test, fsangunent random state berforgss untuk newsTsh data secara random dan dsdopatkan dats yang paling akurse ‘from sklearn-rodei_selection inport train test split Actrain, atest, yotrain, yotest = train Rest aplSt(e, y, test size-8.2, random eate-82) melaiukan perskalaan Fltur (sealing) pads data eth (Lratning date) dan date ut (Lest eats) menggunakan netode standartsest. fron sklearn-preprocessing Inport Standorescaler se StandardscalerO) sctrain = seu fte_sranstorn(x_srain) Chest = se-transtoreGx test) sonagunakan Linear roel yottu Linearkegesston ‘rom skiearn-Linear nodel import Lineartegresston ‘enjadskan regresserye yastu Lineartegression Ir = Lineartegresston() menuat regressornya dari data train yaltu (x train,y_train) arsfit(x train, y_train) ‘preaiisi nenggunakan nodel regrest Linear yang telah latin pada data ujt OL test) yapredi = Insprediec test) snencetak nial accurasy prine(ecuracy = “wser(Ir.score(x test,y_test)*100)) ecuraey = 9.32440083303237 hntps:ifolab research google.conisrive1Ol.560WodgTBTAWCOg0T)-Feto2uIN?authuser=2#scrolTo=uKvIW-s-Wb7 1&printMode=rue 86

You might also like