From 81059207590e940338345479ca701a45dc15baf7 Mon Sep 17 00:00:00 2001 From: Mariusz B Date: Sat, 1 May 2021 16:52:09 +0000 Subject: [PATCH] lin reg --- dev-0/out.tsv | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 24 ++ test-A/out.tsv | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2024 insertions(+) create mode 100644 dev-0/out.tsv create mode 100644 main.py create mode 100644 test-A/out.tsv diff --git a/dev-0/out.tsv b/dev-0/out.tsv new file mode 100644 index 0000000..a330641 --- /dev/null +++ b/dev-0/out.tsv @@ -0,0 +1,1000 @@ +77239 +12174 +49262 +13719 +24094 +78831 +44731 +9445 +-8775 +13484 +25123 +82523 +5739 +1473 +35893 +24156 +62832 +94431 +36316 +6932 +-48 +7404 +-8741 +58501 +-5318 +69009 +79095 +12188 +10168 +37254 +75971 +63525 +6658 +49598 +39198 +59440 +32540 +24943 +42595 +71446 +74940 +28528 +39057 +68094 +12355 +121925 +91830 +9824 +42892 +50773 +75051 +-7257 +95529 +39512 +11934 +-6552 +-4101 +24977 +71079 +20681 +62319 +-10728 +-646 +73072 +83081 +28698 +-7037 +87264 +33190 +1884 +20660 +32992 +18967 +19523 +167547 +48549 +62745 +42096 +66864 +16652 +47605 +20351 +45222 +16632 +17955 +19287 +56585 +41008 +40562 +23521 +41009 +32697 +55246 +45324 +3349 +2651 +64318 +60186 +36433 +30100 +6477 +9337 +10176 +19691 +5895 +25133 +26251 +42408 +63177 +19739 +76864 +-15323 +54252 +59921 +8744 +40710 +11756 +34232 +55888 +26714 +24416 +30650 +-24711 +30210 +66911 +75109 +-20169 +44208 +22083 +46460 +12363 +-7609 +45743 +37835 +-28849 +62991 +100418 +56741 +31694 +62733 +14749 +51230 +69818 +17982 +66275 +51842 +90877 +14816 +10818 +57652 +32220 +18065 +46411 +-38790 +74907 +-13979 +75781 +17738 +58732 +60355 +36382 +67125 +6722 +-3564 +3006 +-6209 +41504 +38028 +26221 +81803 +61213 +71060 +20127 +22529 +75049 +36982 +76843 +95528 +82135 +74940 +53215 +33505 +16613 +-13981 +21488 +5521 +81620 +37928 +10933 +23498 +-11782 +39853 +44221 +62780 +1502 +54753 +40962 +57996 +21573 +37325 +100436 +95529 +-6019 +-18119 +18991 +21878 +32395 +64885 +67648 +32891 +25611 +6945 +91665 +42259 +34567 +77487 +50274 +61892 +120091 +53360 +-14210 +33713 +26802 +-9574 +37526 +26978 +-1026 +40298 +39283 +54308 +6257 +44483 +25623 +46580 +-753 +4598 +71722 +49840 +13921 +61262 +36797 +24831 +21964 +48547 +37468 +14610 +13297 +43043 +30968 +12309 +54870 +24088 +49690 +74596 +12578 +86243 +32373 +82544 +33454 +21766 +67952 +7679 +20565 +14556 +73228 +27465 +-2782 +95529 +2703 +20119 +-12609 +24105 +18875 +17096 +68733 +15405 +18148 +149857 +19171 +24461 +120994 +62282 +13289 +14892 +74940 +29884 +78371 +7639 +33981 +56498 +27388 +72976 +38449 +-636 +27382 +37766 +43555 +30097 +28430 +53805 +23465 +11475 +3290 +36849 +14053 +35215 +5897 +52486 +39293 +8593 +4925 +-23201 +24439 +-21228 +68077 +88769 +2479 +26594 +47449 +26022 +45811 +48858 +23796 +21549 +57779 +76356 +17345 +44600 +60323 +30416 +28810 +64522 +3939 +35248 +-2005 +42539 +41750 +30092 +52959 +63507 +130497 +87259 +44945 +66278 +13045 +65108 +14770 +3971 +54569 +39275 +58686 +14664 +48595 +32765 +51616 +63790 +8276 +4444 +54889 +21269 +94454 +41792 +-912 +48798 +58255 +78371 +179254 +68077 +54604 +8519 +30860 +31243 +-24088 +70576 +81803 +42172 +28310 +47427 +76763 +37111 +-13229 +38511 +36700 +51170 +-3825 +27772 +18842 +-14937 +26434 +-1663 +50162 +71426 +48354 +23766 +7402 +65919 +21322 +70490 +44736 +34758 +51808 +36874 +87619 +60900 +53775 +26413 +-604 +19471 +80051 +81448 +45231 +6548 +19309 +238485 +98960 +120329 +112266 +10604 +44488 +46757 +43194 +65819 +67632 +78371 +58702 +48641 +51335 +-25589 +55248 +43045 +39852 +74479 +55817 +28368 +4325 +74940 +20309 +42484 +27574 +66106 +31911 +57603 +23404 +68077 +61214 +112895 +44066 +95932 +65323 +66096 +61670 +29210 +7021 +17919 +25067 +47263 +9236 +65109 +50699 +30855 +78023 +13678 +25127 +24592 +8670 +39811 +13547 +81803 +42058 +39503 +27580 +17667 +79926 +69840 +23433 +52210 +28521 +19367 +14996 +58284 +-23850 +45284 +23103 +20196 +17878 +24914 +52227 +47263 +32747 +25824 +44213 +47900 +78371 +24094 +19025 +36952 +63618 +41422 +76628 +293 +64109 +26187 +34206 +24920 +60601 +59203 +66431 +7915 +89329 +32277 +-30570 +106293 +72614 +20465 +196907 +49853 +18372 +47300 +35829 +-28515 +23583 +50247 +105426 +16008 +25737 +94006 +-12346 +93311 +71176 +68678 +58684 +27801 +94876 +12808 +79110 +11973 +73858 +6401 +65255 +41777 +74786 +68465 +27312 +-1655 +12913 +5987 +46140 +19611 +67069 +74940 +52267 +56632 +12981 +28192 +16410 +2931 +18578 +-13483 +2245 +54322 +136788 +84073 +1469 +40528 +41240 +-27550 +55433 +21722 +-5713 +1691 +73818 +36178 +92452 +65829 +81943 +55823 +49396 +90877 +30278 +63301 +-5039 +55665 +-21661 +58240 +72641 +14251 +6870 +36350 +63168 +22129 +-659 +24606 +74769 +14488 +45913 +63207 +67869 +128197 +51465 +2826 +27314 +70253 +44105 +63019 +14105 +34775 +12658 +-49051 +25068 +55895 +46329 +15910 +-2068 +56479 +42382 +41449 +26586 +22078 +54155 +42518 +201668 +14318 +-20010 +56414 +38037 +17951 +39380 +48325 +11040 +69391 +-2852 +132499 +90045 +-1006 +26532 +-2504 +30210 +-1066 +67633 +25968 +39779 +-6072 +20647 +23271 +34061 +21454 +49233 +32856 +58027 +55183 +56957 +21814 +26878 +42599 +61860 +23911 +55450 +89919 +87462 +40047 +50958 +1259 +45049 +24997 +33549 +39620 +16789 +13753 +8738 +88345 +49794 +32264 +8068 +86938 +25363 +34623 +30728 +80465 +30629 +44844 +-38946 +39144 +16763 +116092 +76162 +50356 +63557 +30601 +36139 +-9834 +11345 +11168 +7502 +52976 +48066 +-930 +-14764 +94134 +1693 +70132 +-4133 +33138 +95433 +40215 +21579 +50444 +57213 +95529 +33346 +-15864 +13886 +-28906 +21997 +51979 +7126 +35888 +-12354 +59952 +129480 +45949 +58589 +-2877 +41499 +57781 +-3279 +1824 +55671 +14264 +22582 +-3084 +26850 +80001 +103130 +19195 +1715 +81803 +-1211 +27969 +24173 +1309 +26503 +22832 +90940 +62655 +-3620 +46395 +51280 +42983 +54668 +16453 +57774 +-30762 +44618 +76055 +7778 +68077 +41921 +-12788 +-42765 +29928 +12500 +12765 +23530 +108538 +26144 +46107 +29091 +32630 +-35983 +40883 +-25073 +36293 +33658 +35644 +54236 +8619 +-25506 +17760 +39426 +17347 +22818 +37346 +-60777 +60623 +49502 +4304 +71386 +59392 +26227 +13279 +57928 +7419 +-9840 +34691 +172638 +-16531 +19762 +79650 +61213 +17745 +-11618 +6050 +61909 +16327 +23521 +3330 +29470 +35140 +58404 +73449 +-6431 +60323 +74816 +6517 +38634 +28001 +12783 +6845 +79784 +57781 +35790 +29766 +2676 +36683 +23308 +67633 +46101 +-3997 +57779 +91872 +20927 +47705 +51201 +72866 +4011 +42545 +59377 +15833 +-9635 +46614 +19822 +37636 +65628 +37960 +4518 +37324 +33048 +65546 +20984 +22781 +30290 +33925 +28183 +54693 +62867 +58839 +11156 +49387 +21395 +-2548 +20474 +13403 +-10956 +41602 +22283 +-15082 +22064 +20785 +29339 +14922 +69967 +48707 +35796 +35507 +7080 +95529 +44755 +128153 +61195 +75587 +33442 +26283 +59964 +18019 +40153 +80095 +45370 +50589 +96959 +10666 +3066 +25503 +562 +25942 +37111 +-53110 +38328 +-16799 +59061 +81803 +49294 +26867 +78371 +-2103 +25962 +38895 +-15282 +15613 +45720 +94985 +60135 +115377 +92616 +60180 +20032 +-15495 +26655 +15795 +25500 +29704 +88504 +78371 +392 +29939 +71192 +77925 +95529 +35425 +14665 +14670 +59164 +41662 +29656 +55948 +12942 +39010 +65470 +80683 +61070 +54384 +-6981 +-12594 +27520 +86168 +39656 +72231 +64253 +-13343 +7428 +88603 +28727 +36385 +11752 +-5968 +32483 +63460 +68931 +21122 +20419 +19880 +3521 +61040 +40262 +82322 +67004 +21444 +21212 +72134 +74905 +5068 +54610 +74120 +46919 +39648 +48034 +36379 +89 +74940 +25067 +10612 +44807 +77922 +75754 +2699 +11270 +14075 +67286 +75947 +68596 +39244 +33697 +5978 +45382 +45292 +-28765 +17348 +71820 +74178 +41522 +118171 diff --git a/main.py b/main.py new file mode 100644 index 0000000..519cdb5 --- /dev/null +++ b/main.py @@ -0,0 +1,24 @@ +import numpy +import pandas +import sys +from sklearn.linear_model import LinearRegression + +def trainModel(filePath): + trainFrame = pandas.read_csv(filePath, sep='\t', names=['price','mileage','year','brand','engineType','engineCapacity']) + dataY = trainFrame[['price']] + dataX = trainFrame[['year','mileage','engineCapacity']] + model = LinearRegression() + model.fit(dataX, dataY) + return model + +def predictModel(model, filePathIn, filePathOut): + inFrame = pandas.read_csv(filePathIn, sep='\t', names=['mileage','year','brand','engineType','engineCapacity']) + data = inFrame[['year','mileage','engineCapacity']] + prediction = model.predict(data) + numpy.savetxt(filePathOut, prediction, fmt='%d', delimiter='\n') + +model = trainModel("train/train.tsv") +predictModel(model, "dev-0/in.tsv", "dev-0/out.tsv") +predictModel(model, "test-A/in.tsv", "test-A/out.tsv") + + diff --git a/test-A/out.tsv b/test-A/out.tsv new file mode 100644 index 0000000..24fa64a --- /dev/null +++ b/test-A/out.tsv @@ -0,0 +1,1000 @@ +24011 +23563 +11560 +-8533 +-6064 +20297 +40399 +19425 +118423 +47261 +-29452 +44114 +-3817 +30715 +-25260 +-7549 +44891 +66214 +35059 +14874 +60027 +17819 +-4858 +44981 +5040 +23606 +37982 +34209 +73675 +25772 +41668 +21488 +23453 +9008 +70745 +13255 +53940 +46556 +70878 +34932 +12608 +50489 +37319 +67694 +66611 +32927 +37068 +8783 +27645 +43646 +40892 +87031 +13285 +46445 +-4659 +30584 +66771 +32953 +72493 +95528 +20899 +79272 +63680 +26488 +65225 +69025 +-4741 +-1898 +42993 +78372 +49971 +94431 +27795 +76203 +47630 +19693 +22281 +16089 +84355 +35494 +15226 +45721 +64552 +44168 +39939 +76490 +84424 +16063 +34552 +46943 +13240 +58805 +75707 +47089 +18453 +75068 +20906 +7892 +63516 +39830 +74940 +56185 +6799 +25837 +33178 +69085 +54466 +8214 +43123 +19134 +26978 +-1163 +58809 +21328 +6223 +79100 +539 +74940 +-10697 +44809 +22804 +11704 +34069 +-2676 +13457 +16965 +29608 +1679 +61718 +44119 +23119 +15380 +35445 +7704 +112217 +76040 +28903 +46161 +51905 +31441 +35846 +29528 +47918 +-22487 +33824 +23495 +122270 +43057 +33389 +10384 +58856 +73556 +73568 +29937 +-7094 +117580 +45973 +28280 +40665 +24597 +25671 +18707 +56393 +-9732 +62695 +43011 +26795 +65784 +44290 +62502 +61473 +585 +24888 +54996 +58728 +14548 +34391 +61042 +82414 +62652 +45873 +51939 +24629 +96155 +53010 +70895 +35735 +39156 +93924 +22912 +26285 +10399 +3160 +17507 +14926 +10031 +56519 +44641 +11056 +41177 +96509 +27781 +19637 +56943 +77542 +66045 +24754 +8331 +36585 +18403 +25569 +-17130 +22955 +42070 +32630 +1329 +56040 +31532 +38602 +13449 +25990 +14261 +70965 +7633 +-8066 +9214 +-10221 +61442 +15205 +50091 +-32226 +1131 +53143 +61631 +43127 +5605 +46491 +23834 +59321 +52264 +-26053 +-1097 +62511 +-7157 +20785 +28839 +51198 +124383 +45061 +38541 +20037 +41262 +69923 +57650 +60123 +76456 +22949 +38281 +78372 +89874 +26881 +85627 +70007 +1556 +57285 +30523 +27750 +44055 +10800 +66721 +26984 +8235 +38712 +71239 +-1663 +5430 +14191 +19729 +81631 +51436 +43066 +17530 +54377 +45347 +33585 +39355 +58534 +78372 +6346 +42684 +34779 +39711 +34863 +23316 +47105 +12791 +48160 +45999 +26870 +44076 +87405 +33878 +111818 +71683 +94183 +59972 +40437 +4021 +81707 +28612 +36094 +-6624 +56687 +51352 +13343 +63878 +24188 +-11839 +37584 +44350 +76256 +41142 +91554 +18596 +16750 +89262 +32879 +21725 +50419 +11268 +-38779 +3658 +53252 +69760 +58121 +34561 +26137 +-8921 +71249 +64165 +59421 +45658 +39650 +123241 +78370 +11714 +12686 +27628 +89321 +39589 +62307 +56891 +78180 +3633 +41078 +25799 +43592 +12337 +37167 +48721 +62100 +13731 +13073 +26735 +-7226 +38273 +64934 +36132 +32671 +60900 +56771 +129845 +27400 +23497 +24381 +43898 +56934 +61214 +-1831 +14646 +81803 +21605 +42829 +39404 +25335 +25238 +28375 +6625 +608 +637 +790 +33040 +49464 +19118 +32740 +42971 +37257 +57626 +59167 +33266 +77033 +-6460 +46964 +50313 +20471 +-5554 +31030 +7189 +19373 +42305 +52170 +52999 +62940 +67670 +59552 +48064 +5232 +70117 +83986 +23623 +53444 +29331 +68077 +7559 +56527 +30043 +35337 +60950 +95239 +41241 +34958 +14642 +61213 +-5867 +8012 +31156 +35368 +91366 +61274 +25363 +95529 +72009 +27941 +-11455 +20222 +62310 +17841 +30364 +46160 +41027 +-22926 +22977 +-31991 +26356 +13885 +66544 +-10736 +25290 +99214 +25941 +20719 +3153 +23034 +16017 +34944 +4637 +44144 +52834 +-18759 +-35849 +45642 +10022 +76230 +35418 +56689 +-5646 +51058 +42184 +15029 +51460 +-297 +75214 +126118 +81739 +8220 +93417 +38116 +52042 +46121 +44090 +-18366 +29527 +25532 +20374 +57263 +35507 +29414 +65047 +75553 +50603 +30860 +75371 +8152 +58178 +3923 +18494 +57384 +37333 +-52159 +51796 +68641 +-13769 +84018 +57721 +44134 +131033 +25922 +94431 +17422 +53514 +67248 +39933 +39873 +23245 +105823 +-14191 +6767 +-13539 +-5566 +35545 +17125 +47895 +-32952 +51184 +33744 +28085 +12309 +94896 +79942 +59766 +54377 +43530 +24432 +78372 +51832 +3590 +32654 +31233 +118067 +56555 +40596 +61405 +39488 +95344 +38449 +75858 +50844 +40153 +66149 +23966 +-17875 +28773 +-19598 +12256 +90911 +71571 +68533 +13383 +50169 +73755 +83203 +52424 +11469 +46875 +90465 +29003 +93348 +58050 +-3854 +85226 +11400 +5782 +48400 +38700 +-8397 +103821 +26520 +29186 +91449 +-8731 +124144 +4632 +79774 +51757 +174301 +-14265 +-2700 +22088 +31275 +49690 +28810 +10748 +476 +340 +39856 +11668 +31210 +33565 +58367 +5149 +59523 +51369 +54409 +90760 +-3582 +57192 +8741 +12005 +-10244 +20764 +59540 +29492 +23716 +94317 +10552 +42143 +16413 +-25147 +37150 +75594 +36122 +-9430 +63948 +32787 +57419 +52398 +55280 +33168 +54503 +33457 +88822 +30658 +60249 +40647 +32853 +112299 +23821 +25624 +24019 +-15402 +112647 +5913 +63734 +64618 +50136 +104597 +-15131 +81802 +84493 +8084 +84018 +816 +56440 +12309 +-63390 +2515 +20666 +40306 +144613 +40092 +-3962 +62056 +-12415 +-9985 +38682 +38777 +77033 +72820 +54402 +30674 +30641 +17666 +80089 +19067 +-10474 +43756 +5424 +82283 +37028 +8513 +17848 +23597 +5292 +24546 +34024 +-16330 +5728 +9595 +1809 +77239 +49225 +4897 +81803 +8348 +-34639 +43757 +63088 +76066 +67882 +52586 +3067 +31968 +23887 +89231 +32647 +26474 +53873 +74940 +1081 +11606 +26648 +81004 +90194 +15600 +95528 +-1447 +70894 +91003 +64826 +906 +32907 +97936 +27733 +69724 +69880 +5973 +35790 +53651 +38565 +36910 +38526 +63888 +31691 +78371 +37532 +29644 +17148 +6845 +51999 +13975 +29762 +35590 +-1756 +36162 +8593 +75243 +64523 +57554 +26834 +84720 +9900 +55359 +70589 +75518 +-39730 +40458 +95529 +-625 +48119 +56775 +123975 +40803 +4500 +1257 +68077 +23393 +14365 +84122 +28904 +22003 +-1507 +64492 +57142 +121985 +47414 +13945 +35398 +44060 +50028 +64387 +-13515 +20377 +43196 +51199 +20583 +29843 +8377 +107129 +18047 +62832 +-3845 +77053 +22778 +30324 +57452 +3381 +45624 +-14425 +42767 +71067 +24774 +109899 +34138 +43103 +28215 +3137 +81803 +25339 +35064 +46530 +5808 +2564 +60035 +3436 +18745 +115812 +42888 +36952 +7066 +9595 +35257 +-32886 +45989 +68573 +12450 +68077 +41198 +51566 +10116 +19601 +21604 +22146 +63513 +27235 +-1401 +22462 +33488 +24706 +28997 +44546 +18691 +46976 +38048 +96742 +18675 +35603 +95529 +-20618 +30248 +58177 +74816 +80589 +19181 +19967 +13969 +22069 +21431 +-16124 +22547 +36012 +63788 +30348 +70016 +33212 +22024 +60059 +2487 +5759 +32842 +15695 +-4632 +82281 +10193 +40784 +6485 +-20567 +-14976 +23162 +-9417 +27397 +93851 +42168 +27551 +3920 +68077 +4963 +67946 +12919 +30176 +29131 +19683 +26939 +61285 +91721 +21726 +70521 +97836 +21713 +75926 +34608 +1465 +-2327 +91526 +53694 +39300 +26580 +31358 +-21296 +11914 +12571 +27320 +8028 +-32412 +37191 +29093 +76976 +10513 +31962 +74596 +37165 +25349 +55751 +-24537 +3863 +12752 +64802 +33001 +7004 +40835 +-4449 +68077 +-23560 +35923 +48183 +-5927 +68632 +56336 +-433 +45375 +27972 +7265 +28229 +67351 +78356 +-5811 +57786 +7474 +-13893 +36798 +26950 +15054 +5355 +61213 +36135 +12761 +67371 +114903 +81305 +46262 +41827 +43131 +31577 +124730 +16834 +11592 +42478 +51826 +-38297 +42698 +36476 +-14076 +53195 +9006 +652 +26053 +8770 +15444 +81223 +83650 +24072 +12484 +68243 +66784 +30019 +150434 +2506 +71931 +58689 +46796 +87242