From 811aceb045ea22f5c226baa0003a4b98cfc88254 Mon Sep 17 00:00:00 2001 From: Maciej Sobkowiak Date: Wed, 19 May 2021 00:29:44 +0200 Subject: [PATCH] LinearRegression --- dev-0/out.tsv | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 59 ++- test-A/out.tsv | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2040 insertions(+), 19 deletions(-) create mode 100644 dev-0/out.tsv 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..7555cd4 --- /dev/null +++ b/dev-0/out.tsv @@ -0,0 +1,1000 @@ +72850.31794619281 +15565.106531906873 +47573.93271259777 +16929.707085669972 +25400.199951559305 +72827.7214065427 +44302.05464417022 +12791.90588416718 +-2869.720860371366 +17314.65362323355 +26151.198889313266 +75252.54242606927 +8685.256063401699 +5611.803581016138 +36632.40098980535 +24956.828218087554 +58141.0283325389 +85525.14333524276 +37432.394327571616 +9514.093792510219 +4898.178731706925 +11055.669809535146 +-3446.8276660647243 +54506.52320691571 +-393.80791908688843 +64197.86225304287 +73717.83500313666 +15723.059270042926 +13037.049157283269 +38314.33293625433 +69736.5279596895 +59150.72917975485 +10176.65954201296 +47897.180713830516 +37769.66533583496 +56394.344053699635 +33711.511089271866 +25188.442020772025 +41469.64109735843 +65803.57781364862 +70591.20920333825 +31608.123150490224 +37620.480134757236 +62424.89687905833 +15486.477880621329 +113179.80343536474 +84813.96408640686 +15108.443811262958 +41225.48086569365 +48447.73438381404 +69341.28962953668 +-3254.413518095389 +88871.23313353863 +39284.754998589866 +15192.751104809344 +-765.1819979632273 +760.5014838948846 +27617.33578758128 +64790.73340299819 +23976.355048620142 +59246.02295357268 +-4466.132777097635 +6628.067363254726 +68756.38425727934 +77878.31360429712 +30930.662194377743 +-2463.832434914075 +81320.1808245955 +32903.46183860302 +6223.110933952965 +23048.56402391754 +32263.460231969133 +22042.77612228412 +21539.945681519806 +152868.2232912965 +46150.18387976568 +59891.25855608657 +41723.29999388289 +63720.70201568864 +17626.41862650588 +44983.01844878681 +23918.881849142723 +45436.59649259038 +19785.825807699002 +19596.350156521425 +23923.581327628344 +54669.234486143105 +38168.02320427075 +42173.54596634582 +24680.874161536805 +40812.29083308391 +34408.8336533159 +55484.78768719733 +43552.81855189055 +5287.819299121387 +7274.050714137033 +60644.6456715269 +58736.94092333969 +38451.83922058623 +31571.247496427968 +8191.542868746445 +11110.010015829466 +14652.588322518393 +22401.5503558591 +9146.376753033139 +27840.37767868582 +29047.923919232562 +42460.13043692801 +59416.351341228 +21581.062195856124 +72372.21780955512 +-10249.589230433106 +50279.204862714745 +56634.233299286105 +11961.875122129917 +39697.7040026607 +13805.677484127693 +35674.097607376054 +52716.97370231897 +27994.838022160344 +24271.535233812407 +31749.661645879038 +-17216.763289682567 +31815.98131849803 +62226.94733822439 +71581.05781488772 +-14429.979230454192 +43688.45061026234 +23785.57774387393 +44499.385191188194 +15881.465714435093 +-2975.1226376621053 +40603.39653709531 +36992.02634887863 +-19766.698430092074 +59098.602881640196 +90750.9294832861 +53066.557244977914 +32537.675543602556 +58638.25393201597 +19381.8125350317 +48714.967841028236 +65893.25360731687 +18161.040309637785 +62658.98995482642 +49293.90490952134 +84824.24292020407 +16418.970574814826 +13486.033691076562 +53571.01421169005 +32810.93708059564 +20921.487201726995 +45526.789087411016 +-29502.234161302447 +69226.8600881612 +-8683.39325877186 +69920.22943192534 +22015.415803888813 +54766.42111628782 +56713.075569809414 +37156.598093672656 +64027.38792151306 +9784.288722385652 +1212.4841429358348 +7917.272891248576 +-2751.3663197010756 +40563.613827248104 +38033.7833905546 +26800.60022366699 +75229.11580428574 +58735.0563335903 +67423.23000588734 +21431.59561718814 +22484.371318059973 +71235.92839138862 +36967.48027942423 +70762.10391489789 +87547.00494094379 +75549.12012100127 +70591.20920333825 +53145.00862874556 +33642.98348955158 +18523.66535746865 +-7574.926332851872 +22539.91309726797 +9485.520088531077 +74717.94723246526 +39221.23175269831 +12546.026330389082 +26436.095211884007 +-7446.394077813253 +41446.2561750086 +42723.71069820225 +59174.429447344504 +7016.416607162915 +51850.17976475321 +41019.97551234253 +56975.8977519637 +24506.104939376935 +36644.61006619036 +91856.64261507243 +88011.04361311253 +-155.8847746439278 +-11042.218127127737 +21628.044661240652 +23138.035547363572 +34324.14722784981 +61518.9439334888 +63858.21138013154 +35379.97394696623 +27543.24657508731 +10715.991500215605 +85603.73579561803 +43218.50500430912 +35004.95186271239 +72072.05254296213 +47722.90485369507 +58554.1865375489 +110843.90086790081 +52929.33052736614 +-8358.270876080729 +33422.75604880229 +27658.039312675595 +-5016.695822792128 +38361.17552569322 +27409.810844073072 +4536.168669730425 +40324.87193742208 +39537.378159342334 +51034.12229852844 +8431.271597478539 +43907.06398960948 +27194.928485691547 +46090.01316798944 +2090.8680277317762 +7270.405494984239 +66613.52305777837 +48828.66881438997 +17439.183712349273 +57439.20694332104 +39001.23449233174 +25915.095224024728 +25023.0969443731 +46125.02224296611 +35629.78617318068 +17464.453794974834 +15382.372118975036 +42651.237782437354 +31432.796845907345 +14641.045324711129 +51583.34777709562 +25611.23442659434 +48034.89331819676 +68767.71908316948 +15834.083075463772 +79061.53882912826 +32917.52605821192 +75665.75139039755 +34631.03173027001 +23579.826259674504 +62709.708810088225 +11911.924759278074 +21261.89388178382 +18480.51021375507 +68879.44781837519 +27769.463978955522 +2159.808788477443 +87944.53857945744 +5198.0757092908025 +23204.23355442658 +-7007.477751825936 +24479.41816199757 +19870.72363279853 +20520.4238398578 +63979.13375343289 +19881.029431981035 +19759.827703624032 +136397.18073138688 +21744.538779824972 +25889.376604167745 +109410.29659114964 +57570.977282704785 +15839.695875786245 +16715.195007006638 +70723.18318828288 +29432.46400133893 +73538.39226893708 +11872.522847482003 +33942.89947916567 +54269.36396403983 +27642.84854508657 +67497.92874019127 +40190.903888162225 +4402.780501640402 +29110.91545748338 +37639.01212727744 +42678.78602747619 +29297.641101237386 +29884.206930928864 +52214.09124900121 +23888.45714976266 +14121.314659639262 +7035.35443486087 +36731.150426084176 +16039.39434965793 +35660.10234443005 +10491.079692049883 +49670.59684161097 +37715.998149237595 +13272.742805530317 +8339.891443501227 +-15354.755754313432 +27166.06632383261 +-13834.210097318515 +65225.66266822349 +82343.51364623941 +6015.233753917739 +29129.692260098644 +45718.042035581544 +27417.459534775466 +44579.67669322528 +49757.56041303184 +26553.80491698254 +21906.309947086498 +54660.627530579455 +73562.18290627748 +22167.114232613705 +45172.56662393082 +59706.34298030101 +31800.181496822275 +30131.106613889337 +60554.72140014637 +8892.380484124646 +34362.82991631888 +388.4566118605435 +42515.851183095016 +42402.30998707842 +31107.14900482446 +47354.15473337751 +61073.224219435826 +121182.67250544112 +79404.47423020471 +43545.60264184233 +63764.67703269608 +15471.873031408526 +60127.010228890926 +16117.301098785363 +8113.385330094956 +51345.163953046314 +40127.022608987056 +54984.565164837986 +17081.449128217064 +44810.039936728776 +33007.98400510382 +49513.27296813391 +63998.34122144338 +10975.952202127315 +9339.877062522806 +51759.24204180483 +23554.869515122846 +88150.85803868156 +41250.49881169479 +3427.0978423859924 +48366.80936883297 +54544.833137046546 +73802.91449303925 +162036.0686811302 +63968.74400402419 +53115.559034538455 +13947.173605969176 +31140.252760661766 +32552.901570592076 +-17384.475120226853 +65463.080679471605 +76750.32645206153 +41960.516204721294 +27530.948081627488 +47003.39655683469 +72539.4763808418 +37136.42337705381 +-7083.83542564325 +38543.20035921503 +35514.032545845024 +49705.9636729192 +1982.7833739249036 +28199.119701603428 +21265.017047626898 +-8852.298935695551 +27830.45938873198 +5245.476852064021 +47082.205058960244 +67007.50100448448 +47902.022319162264 +25413.544267913327 +11079.485674393363 +61759.62051031366 +24505.98388142977 +65647.65185526107 +41897.65779460408 +33823.72512369696 +49241.94754128903 +38177.17000605073 +81449.46117399726 +57620.87216262147 +50438.59368253965 +27549.128259138204 +3311.6753685530275 +21715.045011561364 +71725.75193583965 +75603.30747440644 +43015.0900394246 +9836.436727858149 +22551.94768567942 +214612.91905166395 +90561.15217414871 +111133.03129554633 +102877.60259625688 +12853.132563210092 +43370.39451318793 +47628.09586678073 +44473.95408348087 +63060.702527116984 +63210.04035808984 +73802.45401198696 +57306.177334878594 +47295.32780729327 +49272.49094042368 +-19146.43597410433 +52308.78441402502 +41412.55206056498 +41153.911985823885 +69736.79752996285 +55671.06248086877 +29089.231918111444 +9763.484893308021 +69069.19136662222 +21668.55735680554 +40794.82777271513 +28109.48204599321 +63574.60775824729 +31179.231788727455 +55343.56282291934 +26735.49874971155 +63835.964177239686 +58735.516814641654 +105120.75260759238 +42019.82942154445 +89919.43057909235 +61949.4367784448 +61962.793475097045 +60455.367457399145 +28336.312775399536 +9670.835104837082 +21071.005630239844 +26348.54978336394 +46657.88399171736 +13492.14615160413 +60349.58232522849 +50175.41139725689 +33401.523899266496 +71821.03206827585 +17679.431694935076 +28183.730152353644 +26096.10508134216 +12340.804820637219 +39121.6099438956 +15691.280645550229 +76618.00845342875 +43903.840239998884 +38371.41401048098 +28163.086262423545 +18837.55573311448 +73281.81430667639 +67514.2545246929 +24314.728254872374 +49341.685115030035 +29667.655566594563 +23136.55551094655 +16681.312506467104 +57048.65998953674 +-17457.72941556573 +43074.59559309296 +23490.057062512264 +24654.045139825903 +18846.166198909283 +26889.233642922714 +51269.62511724327 +46458.637071383186 +34177.17569314968 +27726.30802407954 +43313.355147846974 +47493.36958883423 +73802.91449303925 +25977.660470271483 +21030.595852337778 +36498.78723435104 +59631.77740787249 +41555.578556168824 +73227.77340607438 +4679.5938935708255 +59822.15005390253 +29403.21646767482 +36223.37124819588 +28001.392625216395 +58660.21532870736 +58090.54887035303 +61305.36400711257 +11808.33777904883 +81044.93797727954 +32802.596170538105 +-23795.496050108224 +96129.27486816794 +69514.55490553658 +21434.515386878513 +177913.80325350538 +48680.717766413465 +19188.266919253394 +45562.08370904252 +35220.26900532842 +-20472.881969721057 +23575.905699401163 +50589.9858472934 +97426.23910597153 +17363.359001976438 +27271.947458036244 +85802.4277232131 +-6940.26890066918 +85800.63732566126 +66988.18399514072 +63417.62947058398 +56420.76835605595 +28735.621670678258 +88154.82939901575 +14626.101269579493 +73586.10345506296 +14041.280252111144 +67749.0059930766 +9435.59217979759 +62996.889913746156 +43382.9895134205 +68805.98744015116 +64227.74349906109 +30294.938024506904 +2659.8270079502836 +14654.345638942905 +8758.462782477029 +45617.96811514441 +20899.11242629215 +61082.581989051774 +68606.07635075971 +50342.88008406665 +52876.046505770646 +15172.126503856853 +28948.533392854035 +19530.698317130096 +7478.207155637443 +20645.15912704356 +-7682.7468964783475 +6460.203004430048 +51194.0527607156 +125762.73357766774 +78181.91620008089 +6611.399367155507 +39315.36915013753 +40493.16767677851 +-20529.83641621936 +52330.98859014176 +22713.908267841674 +1816.5286449221894 +6147.641516990028 +69206.29641616903 +36466.51495280489 +87181.69017805532 +61616.70958425384 +78454.53376339283 +51146.51748588588 +46967.71775451675 +82244.01567841321 +29827.167791286483 +61360.47630678676 +-1686.6853335071355 +53648.50468812324 +-14997.71678627655 +58178.192035418004 +67431.3293468887 +16644.66445350088 +10453.794412367977 +36473.268217531964 +60636.685580431484 +21764.881613367237 +2522.494308992289 +25342.900138455443 +68918.97326607909 +16204.964505190961 +46196.09488116857 +58672.61026806012 +62770.24469688721 +117162.56296672486 +49231.15028831735 +6920.684056241065 +27468.420153839514 +65751.23748839088 +42120.61063438654 +58291.16380087845 +17942.069436378777 +33858.48765473254 +15620.60317826178 +-37510.58787417319 +26575.811704279855 +55489.34289620072 +44708.3017893862 +19289.254201160744 +2107.5478208670393 +55467.67752998695 +44094.05339272786 +40879.848709000275 +27205.269140819088 +24376.85150015261 +51773.28382958472 +40695.1509965118 +182274.599681098 +19531.45375680551 +-13783.600196223706 +53629.60153147206 +40833.31509542558 +20566.901707671583 +38519.964889066294 +46563.570312982425 +13264.653024934232 +66866.57813764829 +1067.0905593493953 +122712.3041064851 +83412.14638003707 +2723.070060121827 +27047.07270664815 +4077.7742352336645 +30823.58622550126 +2525.3476592684165 +62643.999021554366 +25747.807382525876 +39453.487398726866 +-1511.7199876876548 +21769.16986473836 +26125.3389838133 +34652.73818218149 +23016.32237482723 +48201.57981293369 +33855.59568442218 +55066.67650409136 +53242.06402795762 +54800.35871630162 +25566.676433457993 +27321.538383580744 +43226.31846045423 +57946.61139219627 +25415.032223307528 +54289.98856499139 +81630.1542800786 +82829.1037555933 +41457.22678064089 +50643.1218072623 +3980.8990823645145 +43903.68042243924 +26415.88760789577 +36231.710471212864 +38944.779379449785 +19191.257739264518 +17957.84482567385 +13448.414463559166 +82778.83417707309 +47830.141556154005 +32566.547169531696 +9290.629237237386 +81883.68559214193 +26169.278162735514 +33845.10812231619 +31500.17574276775 +74225.6975780977 +30977.56982162781 +45110.71054377034 +-27307.33597186394 +37623.39261966199 +18502.185980897397 +106847.62454256415 +69481.53798790555 +47885.51976922713 +62866.949740335345 +31539.057249097154 +37103.87277855072 +-2063.7004315815866 +13328.354619761929 +15114.788070718758 +12292.47257361468 +51293.757012478076 +45176.06363402307 +7509.985819642432 +-8618.379639171064 +88071.36926347017 +4578.160124988295 +64749.112122344784 +2360.738338426687 +33550.76487414166 +88728.63360607158 +40938.56701441854 +26015.221958868206 +48468.76562949177 +55916.75479937252 +89003.09334532078 +34221.66982522793 +-13727.114424260333 +17241.015509863384 +-23142.578635867685 +22228.92001172062 +49270.91322058812 +9169.80478547141 +34226.07381423004 +-5292.071032262407 +56204.72489486355 +116973.90444626939 +47451.471305564046 +58132.21341242362 +1568.892912578769 +40888.277915640734 +54662.23921426013 +1835.6509676240385 +4104.604835324921 +52947.26531339437 +17097.275934504345 +23784.48169796262 +2275.4126879191026 +29125.711120397784 +73304.91718171537 +96822.38511583302 +20551.808909446932 +5343.407407604158 +75890.36717216112 +2501.4654915509745 +27838.690905431286 +24203.285646717064 +8065.66297603026 +27350.238229962066 +23681.896024089307 +86446.27186046727 +59900.06797203701 +3231.1325687645003 +47542.01018020976 +49191.7677849764 +42536.20756087452 +53568.45485674124 +17412.498282073066 +55801.11440790258 +-22632.618720783852 +43937.21661011968 +70137.34624785371 +9811.32243159134 +65225.317307434045 +41571.19991911482 +-8535.71629534103 +-35854.40077917278 +30996.097690048628 +15726.153332668357 +17788.71865281649 +26255.811878310516 +99591.1091035679 +28327.976611458696 +44173.54700973164 +30174.83463043999 +32695.440549007617 +-23386.577425011434 +40938.190059598535 +-18692.202106449753 +35599.579422513954 +34134.2614255799 +36852.05799797177 +50910.402494185604 +11797.233744580299 +-18054.249669423327 +20234.8918160405 +41288.14218136668 +18612.84130751714 +23225.541164306924 +38408.02799906954 +-48402.106125825085 +58182.65926234331 +47224.44743663538 +7795.645875316113 +67310.54202756006 +55460.28953906987 +28905.154298956506 +16760.477665347047 +57492.376336948015 +9857.214420966804 +-3565.344274273142 +38681.7845051121 +157366.86284911446 +-10557.359671352431 +22011.44386323262 +73706.35810775403 +58735.0563335903 +20128.0210116636 +-6957.936326760799 +11141.269944087602 +58351.38852389529 +17619.464520169422 +24879.35318013653 +5751.56423642952 +29791.628703854978 +37179.78910869453 +54677.48937394377 +67349.92298378795 +-1465.8253041105345 +57589.23344857525 +68801.52156851906 +8959.084035938606 +36838.96609519236 +28478.595877702348 +17736.912419813685 +10514.500629237853 +73346.14570146333 +54662.23921426013 +36299.97325447295 +28969.448739836924 +8592.554258951917 +37127.65355868172 +26543.35221731849 +62643.999021554366 +45140.7155834632 +799.3563379980624 +54660.627530579455 +83911.86752605811 +23214.682219820097 +46460.6440394735 +49938.05199716147 +69767.01580567844 +7094.233823128976 +44223.448568287306 +55268.57202365156 +19029.722155989148 +-4845.651057210751 +46548.34062348958 +23269.876908798702 +39065.56487124134 +61082.82319265511 +39267.54603455402 +7639.571758965962 +38361.428111196496 +33452.833933840506 +61018.36196977645 +21544.452097763307 +22267.327666334808 +30137.420040178113 +32850.755340281874 +29596.306472027674 +53151.50190875493 +59142.120753391646 +56952.3859345112 +14272.059079689905 +46676.53325081803 +23223.665873129852 +2888.837917694822 +22130.688971112482 +17509.038981890306 +-5061.580589143559 +43743.0415027719 +23500.975931213237 +-8702.780507182702 +22621.382052277215 +23135.5299588982 +31522.21777798049 +18553.745608056895 +64957.655988530256 +48067.16345772147 +36689.984113022685 +35684.17692241073 +11014.116208544932 +89003.55382637214 +44396.02832232416 +115186.93532413803 +59669.3081564866 +69797.21066286787 +35071.07587032579 +27066.297853550874 +58296.724860818125 +18200.782544119284 +40011.272655869834 +75513.13300395105 +45161.23062276747 +47080.90314889327 +89916.6996999057 +12872.878539803438 +5094.731028886512 +26079.786478250287 +4087.7626700056717 +26876.048496320844 +38591.93618011568 +-41907.03584413603 +37781.55706759449 +-7732.839554113336 +57326.44232416805 +75030.1749575343 +50036.76152902376 +28004.920895377174 +73802.91449303925 +1602.0986666986719 +27537.2377619287 +38775.17354208883 +-9805.560848297551 +16752.993839734234 +43094.64465178922 +85076.46881448664 +57267.134427152574 +106810.14590092655 +86666.48241038807 +57889.419285411015 +23582.92509135604 +-8869.318212644197 +28666.906173868105 +18101.122619028203 +27006.360873965546 +30140.57552773878 +84052.03070942406 +73869.0741659049 +5522.340837106109 +30484.620196629316 +67320.15225636587 +72611.28831293713 +89665.14920793567 +35040.83686784562 +17542.346688726917 +16936.575673148036 +55164.948278716765 +42133.64554818533 +29043.834908084013 +53372.02655406669 +19353.31639693491 +37627.35694773588 +62592.592109594494 +75016.128743032 +56829.48051051516 +53493.77634740528 +-2818.932470407337 +-8039.7026792047545 +29484.881805746816 +81119.3424553806 +39881.68135688361 +67442.52124616783 +59380.08104422316 +-8871.452407309785 +11246.757530543953 +80378.15514223278 +30763.48872906156 +36296.1833708249 +15001.279971918091 +-1607.854782851413 +33445.134161116555 +60572.92266443744 +65346.96629470866 +22410.54026668705 +21738.465948749334 +20508.039965529926 +8844.804047227837 +56833.27546692174 +38046.14430307131 +76879.52714953665 +64274.118674593046 +23724.987059939653 +23475.09679450188 +67359.80136225466 +69899.13139756676 +8765.828707417473 +53103.59890998714 +68393.33908334468 +45629.85316772107 +41000.60184235778 +46530.845962489024 +36242.57780729327 +3125.910976143554 +70591.20920333825 +25668.264669424854 +12641.760459691286 +45718.05400746595 +72961.11269102804 +70599.28281202074 +8050.142335690558 +12964.219601006247 +16482.8561245203 +63209.134345462546 +72674.89777744096 +64560.60058341082 +39762.61359191127 +34050.6087058438 +10075.610556473956 +43437.34955322463 +45165.39738406241 +-21159.12412010599 +18430.830524637364 +66912.43233515136 +67987.706347364 +42503.92541682348 +107768.02597567346 \ No newline at end of file diff --git a/main.py b/main.py index ea3436e..7ff9c95 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,9 @@ import pandas as pd import matplotlib.pyplot as plt +from sklearn.linear_model import LinearRegression +from sklearn.metrics import mean_squared_error +import numpy as np + # Read column names col_names = [] @@ -13,47 +17,64 @@ test = pd.read_table('test-A/in.tsv', error_bad_lines=False, header=None, names=col_names[1:]) train = pd.read_table('train/train.tsv', error_bad_lines=False, header=None, names=col_names) -test_expected = pd.read_table('dev-0/expected.tsv', error_bad_lines=False, - header=None) +dev_expected = pd.read_table('dev-0/expected.tsv', error_bad_lines=False, + header=None) -# Create dummies for brand -train = pd.get_dummies(train, columns=['engineType']) +# Create dummies for columns +for c in train.select_dtypes(include=object).columns.values: + train[c] = train[c].astype("category").cat.codes +for c in dev.select_dtypes(include=object).columns.values: + dev[c] = dev[c].astype("category").cat.codes +for c in test.select_dtypes(include=object).columns.values: + test[c] = test[c].astype("category").cat.codes # Sprawdzanie ile jest odstających wartości dla price -fig, ax = plt.subplots(1, 2) -fig.set_figheight(15) -fig.set_figwidth(20) -ax[0].boxplot(train['price']) -ax[0].set_title('price') -ax[1].boxplot(train['mileage']) -ax[1].set_title('mileage') -plt.show() +# fig, ax = plt.subplots(1, 2) +# fig.set_figheight(15) +# fig.set_figwidth(20) +# ax[0].boxplot(train['price']) +# ax[0].set_title('price') +# ax[1].boxplot(train['mileage']) +# ax[1].set_title('mileage') +# plt.show() # Usunięcie odstających wartości priceMin = 0 for price in train['price']: if price < 1000: priceMin += 1 -print("Price min cut: " + str(priceMin)) +# print("Price min cut: " + str(priceMin)) priceMax = 0 for price in train['price']: if price > 1000000: priceMin += 1 -print("Price max cut: " + str(priceMax)) +# print("Price max cut: " + str(priceMax)) mileageMin = 0 for m in train['mileage']: if m < 100: mileageMin += 1 -print("Mileage min cut: " + str(mileageMin)) +# print("Mileage min cut: " + str(mileageMin)) train = train.loc[(train['price'] > 1000)] train = train.loc[(train['mileage'] > 100)] # Split train set to X and Y -X = train.loc[:, train.columns != 'price'] -Y = train['price'] +X_train = train.loc[:, train.columns != 'price'] +Y_train = train['price'] -# print(train) -# print(col_names) +# Create Linear regresion model +clf = LinearRegression().fit(X_train, Y_train) + +# # Predict +dev_p = clf.predict(dev) +test_p = clf.predict(test) + +# # Accuracy +score = mean_squared_error(dev_p, dev_expected, squared=False) +print("RMSE: " + str(score)) + +# # Save to files +dev_p.tofile('./dev-0/out.tsv', sep='\n') +test_p.tofile('./test-A/out.tsv', sep='\n') diff --git a/test-A/out.tsv b/test-A/out.tsv new file mode 100644 index 0000000..3ecda45 --- /dev/null +++ b/test-A/out.tsv @@ -0,0 +1,1000 @@ +25749.256337090395 +25315.37415354699 +13988.374854207039 +-3931.6964924819767 +81.90611436031759 +20809.775023297407 +37840.75584587362 +20517.875034689903 +110456.13352839276 +48226.59882908687 +-21020.12800637167 +42892.06417346839 +1593.1289384486154 +31085.683892787434 +-17390.872502552345 +-1452.052247731015 +44741.21042117197 +60900.55796736665 +34951.85555174854 +19579.63870054204 +56643.79197757505 +20254.97676821798 +132.60382531490177 +43177.30955011863 +8812.061476088129 +27104.57543592248 +37364.027244704776 +34807.9277706882 +69749.3773824973 +29140.822910075076 +40527.9738341663 +23267.66949879937 +23964.61427802313 +10763.771718433127 +66326.42814644892 +15957.434623835608 +50952.76495070662 +44891.50255465228 +66246.25461908802 +36732.81289009284 +14960.146693353541 +49091.05048775114 +37252.601231323555 +65769.06174112856 +61646.45806145668 +34036.1006684117 +37194.313550574705 +11943.085082705133 +28829.74016987998 +41853.71615275834 +40301.3122480372 +79223.1598160537 +14958.450969518162 +45157.09861277975 +2444.945316198282 +33086.51858906727 +61988.819662093185 +32468.778896476142 +66591.51069145557 +89068.67741687223 +23727.629913864657 +75123.59700909443 +61174.821476024576 +27664.622125847265 +59824.603206981905 +63632.96702862624 +31.763677060604095 +1210.2767329355702 +41138.099290021695 +73803.3749740906 +48824.49911516998 +85525.14333524276 +28814.336799981073 +74367.50411020033 +44896.86251803115 +21427.503325451165 +23432.551793194376 +17664.89923625812 +79285.12690527085 +33087.434823226184 +19390.91759310197 +43907.179616452195 +60080.67288670689 +45403.615530012175 +41693.958731227554 +71122.94778137375 +79736.74809731916 +20005.00955469627 +31741.105146023445 +46099.051546063274 +16921.7898495635 +57063.31245545391 +69861.05761676747 +45720.94235141389 +23272.601984394714 +68416.76136763487 +23513.798350571655 +12677.145232878625 +61773.24225920066 +39170.67415379919 +70723.18318828288 +54197.91094617825 +9296.780062282458 +29361.87034878228 +32134.655329977162 +64822.47299946379 +53639.285674694926 +9169.896405242383 +44372.15861662477 +20232.690044394694 +27409.810844073072 +3797.2153930244967 +57931.2225802429 +22179.9971006196 +9098.474264253862 +73385.08762580622 +4456.905354815535 +71715.69340154249 +-4534.939223435707 +44740.781404197216 +24290.856086251326 +16731.532622126862 +35444.012301669456 +3090.1394254788756 +17126.034315131605 +18810.709924929775 +29948.66782657616 +6503.550794195384 +58116.26289734617 +42947.88853945304 +24098.535386382602 +17505.047002572566 +35220.000273928046 +11177.739056441002 +103501.88745116442 +70254.30882460345 +29125.908477364108 +47240.304403390735 +51863.314931564964 +31913.700158326887 +35610.12656375952 +30190.324977742508 +46757.13987232093 +-15992.38892586343 +33642.53495231923 +23730.296978342347 +112000.60045377444 +44166.14875518344 +34403.20021691453 +12166.627218913287 +58030.60786935035 +69876.39313722868 +68120.6955059534 +29972.119779756293 +-2635.804736251943 +108556.52028991841 +44536.6887464039 +30148.03427106794 +40946.36793576274 +26069.38944405783 +26421.254704892635 +17649.302609121427 +53575.179276857525 +-4466.504562319256 +57822.361699207686 +44593.21485289093 +27277.008585187607 +63374.44393551629 +43288.96419780888 +59779.15510293003 +57741.38904357143 +4196.1411101790145 +26578.43018937763 +52808.683887337334 +54224.15043406095 +17595.715549390763 +36833.248323471285 +57532.03144886065 +74702.75812805444 +59533.3029527748 +44382.25661304593 +49630.7186808493 +25190.924857519567 +88503.08956556115 +50911.380920063704 +67689.23809400667 +34457.84570683632 +38660.87129402347 +86407.93610262778 +23061.73038977012 +28319.485176084563 +14721.403225145303 +6789.184366330504 +20621.14219513815 +19475.242388692684 +12861.563174718991 +53930.10859802086 +43917.56067491695 +12992.912507601082 +40817.30017200392 +90840.13236434106 +27648.91122974176 +23350.794320301153 +55997.9956781799 +72248.11758861691 +64528.56714227423 +24591.99874787312 +13844.011163933203 +35131.41436537262 +20420.575212125666 +26399.427300150506 +-10310.124103786424 +26113.573734396137 +38720.37773659546 +31616.565444190986 +5692.9421871080995 +53024.235917362384 +30992.834035832435 +39120.943992774 +16867.347792463377 +26373.279940266162 +15780.53850421682 +68035.47827138659 +8111.787018491887 +-3480.9584473259747 +12383.27533314377 +-4518.347616361454 +56980.026030601 +17190.416942073964 +49296.022278130986 +-25081.905241866596 +7454.11408580374 +52113.000543013215 +60543.94632827584 +40872.48983323388 +10996.067397373728 +46517.783335723914 +28184.79667756986 +56115.033376060426 +52545.17664951831 +-18639.613848303445 +1302.8096867045388 +57589.778123344295 +-3039.427295455709 +22738.570574598387 +28963.504929166287 +48633.88724779431 +112554.50140311103 +44797.59652968496 +38288.59355650749 +21149.89166856464 +40878.70990918763 +64801.724792547524 +55182.72813030612 +56670.770598111674 +70055.26986669563 +22950.46624034457 +38917.64555630367 +73803.3749740906 +83352.2245837776 +27134.044359772466 +78375.06501587294 +65224.73467704002 +5587.937282028608 +53497.68262973521 +32840.247038389556 +28806.17738279421 +43203.85157065187 +14901.17568531353 +63493.783513760194 +28455.810153499246 +10972.993466771208 +37491.4974764036 +66457.31035054941 +2665.2496102731675 +9781.309886115603 +16788.66599271726 +22951.881587996148 +76004.2108146688 +50101.5680678729 +42565.422174368054 +18683.914239116013 +53272.05331086926 +45707.69027685188 +33952.55102300178 +39393.22332001012 +54996.099607406184 +73803.3749740906 +8597.73810505867 +41506.25835441891 +35950.30194522068 +40075.42536064703 +36232.71098328661 +24233.557620248757 +44519.52738721762 +16154.872877172194 +46480.133921844885 +46111.45333178248 +30028.29101784993 +42656.06306994334 +79850.18023991585 +36444.45660314802 +102326.24765577726 +67968.45552851632 +86491.35890337732 +58765.635177035816 +41180.30405834131 +7199.868512414396 +75152.90484311059 +29432.935855242424 +37786.094339447096 +1076.644714252092 +53599.06789246574 +51222.49972295016 +14284.505482706241 +62259.25375454873 +26993.520209253766 +-7466.819352677092 +38759.87179957982 +42827.24440174736 +69835.12978523411 +40349.32079647202 +83955.48866250552 +19761.69829640072 +19096.554765434004 +83557.71858759131 +34611.167438341305 +24674.830765860155 +51068.98778207041 +14599.860665875487 +-30501.16555505898 +7373.52470356226 +51244.67546371929 +65359.82859435212 +56845.69628306851 +34453.64122167602 +27616.14617253747 +-2690.9274935880676 +67647.72979223356 +61558.121426701546 +55594.3207942266 +44179.483728289604 +40682.17893198505 +111985.67976468615 +73802.33889172412 +13844.649031847715 +16522.447789075784 +28388.075454999693 +81156.31927776616 +40451.23816014733 +58973.63845124282 +53847.32897754293 +71755.39736908581 +8187.435688746162 +40451.308912560344 +26977.756661659107 +43059.81663009431 +15788.995086502284 +36792.56791004352 +48589.67933747079 +57263.412177873775 +15841.70553807728 +14810.17703340482 +27984.88310906291 +-2691.5268295211717 +38718.98220933974 +61252.028013853356 +37145.55145998858 +32245.56070661079 +56023.94745670352 +53069.88055092469 +119139.27014526818 +29879.042667838745 +24091.887896598317 +26997.132923340425 +43774.05926506221 +53225.37162270211 +58801.33112671971 +4488.4157956484705 +18220.953669237904 +75757.93135906477 +22621.08373189345 +41224.42058017291 +39569.639926096424 +25142.933441411704 +26783.8700474957 +30045.282866422087 +9967.074612181634 +4974.686219730414 +6379.299245877191 +5640.139061921276 +31760.690328813158 +45490.20040769875 +21219.105508671142 +33054.01660200674 +43898.74929208215 +37273.46663039178 +54512.83189346641 +55537.882584429346 +35808.78353286162 +71304.42944637313 +-2809.886935180053 +44547.487109268084 +48016.08549902495 +22461.827658130787 +-59.90143419895321 +30832.81045074016 +10417.89683569502 +20962.955672850832 +41523.285514734685 +49923.470283658244 +53240.20287799463 +57562.63805968873 +62750.80292095244 +55377.51723398175 +46944.02673882712 +7053.284079810604 +65640.5175880054 +76786.715727414 +24899.512651739642 +51473.62196210958 +30391.710733097047 +63835.964177239686 +12728.129415153526 +53233.83325076662 +30147.622877172194 +35787.53058884479 +57414.96557418257 +88641.10772789642 +39191.69548241515 +35985.06023067329 +17244.284367084503 +58735.0563335903 +986.5477595608681 +11753.705640755594 +31953.37488592975 +35093.384840060025 +85239.49666645564 +59133.987886106595 +28286.9063856164 +88870.77265248727 +68192.39242345374 +29440.047407691367 +-1296.4539778633043 +22773.200390775688 +58585.707053815946 +19942.998697351664 +31388.93111359887 +45138.877545255236 +40238.53754793666 +-17726.761175130494 +25517.167781569064 +-26103.96348558832 +28204.60656895209 +16774.806663956493 +61935.80819321703 +-4989.987557706423 +26288.27136527095 +91240.84304223396 +27497.936746932566 +24821.45879589487 +7190.666816627607 +24248.474341109395 +19382.72469643876 +36581.65051186457 +8356.790366522036 +41291.15957127139 +49240.671454858035 +-13031.379193759523 +-27991.87182522379 +43096.24899681471 +12477.499569540843 +69999.32019991986 +35568.3436323246 +55061.05259995069 +3308.3565402431414 +49996.4294662131 +39766.723168434575 +17750.756736834534 +49142.2881244272 +3192.140893193893 +70318.1927979812 +115441.90290617384 +75163.43818332814 +10692.092185118236 +86027.36206072476 +39686.81442983076 +51487.425863346085 +43798.20651361719 +41940.23220340442 +-12537.8547263043 +30955.70601330232 +28230.842944103293 +23497.92931368295 +55020.058389605954 +35551.85622957721 +32225.92355215922 +61267.37929829862 +73389.24219347537 +49040.24209932797 +31007.932067828253 +71320.64037108328 +11219.784631479532 +54392.71439659037 +10137.82770917844 +18103.740496533923 +54754.845019974746 +36782.72336517833 +-44865.22704536468 +49721.93766896427 +66564.01528127585 +-6038.9808067707345 +77127.57596376725 +54768.659322193824 +43154.63750776183 +121351.668410426 +28218.55891326815 +85525.14333524276 +20044.302136125043 +50800.81586611457 +63475.01050309371 +38795.48992864136 +39112.69508850388 +26013.015895969234 +97976.84137918148 +-8759.130943515338 +8421.783394651487 +-8821.075730063953 +894.4588073315099 +36432.98717314843 +18371.104263594374 +45637.11874994915 +-22897.48868151568 +49699.20216973778 +34531.4539738344 +27607.75156099815 +14563.007271942683 +88501.74460016191 +75107.44123047497 +56634.74575507734 +54065.970732366666 +42130.96818416193 +25117.91148025077 +73803.3749740906 +50857.595042472705 +9086.482983729802 +35447.01252114028 +31749.19330256805 +106375.84478779789 +55620.09927538503 +38708.43557632249 +60718.19468241185 +38066.065534606576 +89661.74853735603 +37279.88097624108 +69980.89781050105 +50942.615811195225 +39878.953310137615 +61353.58582216408 +25211.819536973722 +-12653.237778944895 +29409.014444665052 +-13058.661882829852 +17187.612388816662 +84864.33357210364 +67902.37581388466 +63302.50920763146 +16837.26446233783 +50928.85775486566 +67960.22268686164 +78291.2268758798 +51591.06035484094 +13034.605391231366 +44959.835226442665 +82995.5461028684 +30405.056396553293 +86453.70892670285 +54872.74293777812 +1604.0421566953883 +77395.62124119606 +11344.928432734683 +8575.786279755645 +47720.79275448248 +39058.54904494248 +-4242.5028445106 +94209.53128830995 +28341.13977487944 +30276.590470144525 +83161.14873551019 +-2769.430026611313 +112584.50218231883 +9975.153161738068 +72830.92788513191 +48698.377812333405 +157551.9925733991 +-8536.601297563873 +1037.336020133458 +23086.775412456132 +33885.40767050069 +48512.52991437353 +29998.787268156186 +15569.03065803647 +5883.864544290118 +4904.580391946249 +40190.54562359955 +14214.759266586043 +31589.057257344015 +33596.91011596378 +57758.158369869925 +8792.222224496305 +56177.60836100113 +50645.81103198696 +52537.784228229895 +84745.18409994803 +2701.0592306656763 +53424.12078170851 +10892.143562147394 +14320.839863943867 +-5869.359120280482 +22691.727861350402 +56780.9428027831 +31113.85461125616 +25297.166416636668 +85528.11694153026 +14323.107920262963 +41048.21864675358 +17457.943081316538 +-17760.603097139858 +36514.22856018599 +69771.95453324262 +37288.10353974439 +-5495.9756225943565 +60148.997114495374 +31485.343979248777 +55286.82818952203 +52430.950768880546 +54343.652141381055 +32325.094900222495 +51629.17190547008 +33417.99699117616 +80643.0531393122 +31794.032627739944 +56356.251638566144 +38997.97305724956 +33062.019932710566 +103971.04380309302 +24456.822461220436 +28776.439161404967 +25386.470311847515 +-10607.88102848921 +104183.13157819305 +8512.267787677236 +60626.88438997138 +60684.558279831894 +46852.916714232415 +96705.67216324527 +-8817.442269963212 +76750.09621153492 +79328.33148220927 +11344.913457055576 +79679.64327678457 +4363.109019570984 +54205.04232938215 +13763.482919756323 +-49386.93184369244 +7588.6022399663925 +22491.821672149934 +39073.63210621476 +130721.2647751784 +37977.613268283196 +1483.6142590809613 +57639.00218732748 +-8516.604531446472 +-4680.332807022147 +37937.161471559666 +37861.972368584014 +72495.07331744302 +67428.15529047325 +51465.74723268766 +30962.896896723658 +34591.2409164086 +21192.617317873053 +75524.45693547837 +20146.258396783844 +-5778.653987222351 +40605.97660411429 +9529.22934528999 +76719.21816245373 +38014.75714551564 +8926.752424156293 +17965.25725148432 +25418.4958771253 +8017.99175475724 +27193.97306471225 +33618.030641463585 +-9784.934900243767 +8231.035892085172 +12438.826157417148 +6854.355417159386 +73578.0743477242 +47004.9130951846 +9413.497334048152 +75758.27671985328 +11251.984964322299 +-27602.083987728693 +41668.45507723652 +58854.33120380342 +73265.78270750586 +62437.58341552969 +47606.933177319355 +6866.75181944482 +32378.059858175926 +25232.973187698983 +83547.22880105209 +33598.102078395896 +27038.986005580984 +51350.35823833477 +70591.20920333825 +5719.371856818907 +16066.171168426983 +26695.739081581123 +77149.4907332696 +81848.6525391629 +17211.4106906699 +89664.11312556919 +3448.8181464634836 +66819.47908574063 +84937.20469855238 +62547.31473030243 +6197.507514097728 +32877.49428455066 +90827.33378557675 +27490.08440423291 +65679.89842589758 +66079.4565952532 +10750.014471651055 +35974.78316792846 +51042.461521545425 +34553.56244815979 +37433.24466482643 +38332.730483139865 +61483.871418207884 +33350.618978858925 +73802.91449303925 +36959.268286162056 +30536.13565093279 +18880.72571132239 +9786.745574807748 +52231.3263235623 +16262.264318294823 +31577.785934074782 +36856.79301280808 +2306.285873727873 +34623.492269489914 +12214.188039666973 +70888.7664158782 +61614.08200784959 +54890.64899015147 +28497.871711608954 +78650.72743865568 +12871.999407215975 +52402.51050508488 +65214.39077230636 +69711.86175598111 +-33708.174872820266 +39088.18878259137 +88011.04361311253 +3732.287581329234 +47034.01534355432 +54447.0185473701 +113217.4538586894 +38633.60758879222 +8181.304383956827 +3788.368664238602 +65357.636653167196 +26014.16487577837 +18054.97714592796 +80115.17803481594 +31621.28631391283 +24797.861511805095 +2719.663830927573 +60720.742315732874 +55356.96770599205 +112485.56087296363 +46759.680896499194 +18260.916486236267 +34029.34574314859 +42935.56639681384 +48037.92955525033 +61966.825178317726 +-6903.5253782346845 +21475.83222480025 +42838.31167151034 +50024.5649109846 +23451.2246258799 +29275.857501232065 +10604.34290476609 +98286.88911006413 +18962.485879776068 +59188.72314046975 +1564.786240806803 +72522.10439191945 +24252.164500970393 +31103.576201410964 +55471.10490348749 +7552.167749847285 +44317.14470781479 +-8096.994289126247 +42414.23575334996 +67979.6311081918 +25372.204793338664 +102074.27076553646 +35507.111364682205 +43301.864165809005 +28617.507766403258 +9494.667460444383 +75228.65532323439 +24903.11741116084 +36722.37396339327 +47354.47452229168 +10063.114022680558 +5798.15639143344 +55326.39247350115 +7225.492819787934 +19294.44468623586 +104385.2540242821 +39105.96374625061 +38417.41640037671 +10684.469722505659 +13828.179287612438 +35071.13080387656 +-21332.030630731024 +45655.92394459713 +64977.21590291429 +15752.058853607625 +64497.791146429256 +40370.088028280064 +49151.8481498193 +12975.28417656757 +16835.660384661518 +22434.15670245979 +25093.112730765715 +60729.87039866671 +29308.24549627304 +3126.180546416901 +23583.2055042563 +34793.48813942354 +26522.890172733925 +28763.617337126285 +45621.730963556096 +20463.893597694114 +48002.49123202078 +39169.03356491681 +89088.94531878643 +23051.221318251453 +34030.377103489824 +88870.77265248727 +-15234.828145732172 +31506.23680337239 +54630.06939620245 +68801.52156851906 +73520.91071551945 +22146.39986721985 +21598.686004358344 +17142.366004591808 +22392.233583440073 +24077.82387359254 +-8231.592305500992 +22717.61286769621 +35422.60413745325 +61989.20787249971 +31528.350938097574 +64234.23578760214 +32364.17300506588 +24032.101112481207 +59156.974588887766 +5094.792287041433 +8727.760213590227 +33994.67653333675 +19251.195557723753 +406.4532269304618 +75112.07506954577 +12500.855623951182 +40243.22901415359 +10758.87433141563 +-14095.822708080523 +-8230.105465929024 +24186.274906606413 +-6170.195646723732 +28905.674935701303 +87645.00464548636 +42519.42739195004 +28261.45597982779 +7750.790339095518 +65357.636653167196 +9071.542774384841 +62854.58226515539 +16012.456274527125 +32708.947755670175 +30215.165812114254 +24711.344952929765 +28892.08140820358 +57856.37139319908 +84727.62388919201 +23636.45960159041 +67533.73065406363 +89492.12655749358 +22516.67112703994 +70106.63954152819 +34584.26759503223 +6538.182746717706 +4094.1844580955803 +84994.25667509157 +52132.09862025455 +39731.91677117441 +28276.37936311774 +33008.343616766855 +-15556.43885152787 +14285.832644297741 +14608.291785612702 +26926.588661572896 +9846.663034137338 +-26342.453470069915 +37247.662258072756 +30220.072421709076 +70673.11221209262 +13942.838435191661 +33581.48807910737 +69963.88069538958 +36422.620345963165 +26837.636394581757 +53650.49621092528 +-18589.367221430875 +9614.62424194254 +17117.534226525575 +60553.396230096 +33970.7159473747 +10736.491696567275 +41570.76932375971 +-535.6389752505347 +63836.42465829104 +-15705.819107934833 +35981.423936191946 +45706.004850699566 +-602.683650338091 +64598.35556562152 +54246.19223799463 +4103.992578807287 +42778.80444840714 +30491.497478910722 +7529.859069842845 +29953.952638819814 +62599.34173512645 +72677.28721301537 +-1098.260339135304 +57297.67731805891 +16412.060909944586 +-9095.195472141728 +35933.443693353795 +27868.178031024523 +16817.605166302994 +8956.146071239375 +57014.90483906306 +35204.10878377501 +16063.745054141618 +62381.54710401036 +106041.77805287112 +74221.21446860768 +43944.00140217133 +41271.89433068782 +42207.05708799511 +31914.859266750515 +112738.32350812573 +19548.90390605852 +14051.200888018124 +42665.46100009885 +51597.90690043848 +-30544.603386214934 +43418.12736436352 +36717.18645892572 +-9386.455280774273 +51396.702806245536 +11586.809670730494 +5427.615284390748 +27612.684277872555 +13101.535314827226 +16413.970028958283 +76488.90002016444 +78097.56466920301 +26090.117417014204 +18030.155323584564 +65387.85588495061 +64116.88936612569 +30498.084147985093 +136889.7851049099 +9320.127883499488 +68907.44511705544 +54654.913225861266 +45664.02055440936 +80160.76696463488 \ No newline at end of file