mieszkania5/model_regresji_liniowej.ipynb
2023-10-17 17:35:43 +02:00

62 KiB
Raw Blame History

import pandas as pd
train_dataset = pd.read_csv("J:/Desktop/Projects/mieszkania5/train/train.tsv", sep = "\t", header=None)
test_dataset = pd.read_csv("J:/Desktop/Projects/mieszkania5/test-A/in.tsv", sep = "\t", header=None)
train_dataset[4].value_counts()
4
7000    42
6750    42
7100    37
7500    29
7800    20
        ..
9674     1
7565     1
8352     1
7511     1
5077     1
Name: count, Length: 1452, dtype: int64
pd.set_option("display.max_columns", None)
train_dataset.describe()
0 4 7 10 12 13 16 19 20 24
count 2.547000e+03 2547.000000 0.0 2316.000000 0.0 0.0 0.0 1768.000000 0.0 0.0
mean 4.210372e+05 7201.618767 NaN 5.015112 NaN NaN NaN 2011.436086 NaN NaN
std 2.663796e+05 1737.605837 NaN 2.797598 NaN NaN NaN 610.162290 NaN NaN
min 4.500000e+04 36.000000 NaN 1.000000 NaN NaN NaN 50.000000 NaN NaN
25% 2.990000e+05 6200.000000 NaN 4.000000 NaN NaN NaN 1976.000000 NaN NaN
50% 3.590000e+05 7000.000000 NaN 4.000000 NaN NaN NaN 2011.000000 NaN NaN
75% 4.570000e+05 7868.000000 NaN 5.000000 NaN NaN NaN 2019.000000 NaN NaN
max 6.000000e+06 23005.000000 NaN 21.000000 NaN NaN NaN 20120.000000 NaN NaN
train_dataset.head(1)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
0 309000.0 do zamieszkania 390 zł spółdzielcze własnościowe 7113 https://www.otodom.pl/oferta/niezalezny-uklad-... 2 NaN 43.44 wtórny 4.0 blok NaN NaN Niezależny Układ W Nowoczesnym Wydaniu 1 NaN gazowe plastikowe NaN NaN NaN cegła Polecamy na sprzedaż dwupokojowe mieszkanie p... NaN telewizja kablowa, internet, meble, piwnica, g...
train_dataset[3].value_counts()
3
pełna własność               1515
spółdzielcze własnościowe     158
spółdzielcze wł. z KW         131
udział                         15
Name: count, dtype: int64

15,8, (2)

filtered= train_dataset[[0,8,15,2]]
filtered[15].value_counts()
15
1           569
parter      452
2           419
4           357
3           321
5           117
6            51
7            42
8            32
10           29
> 10         24
9            21
suterena      5
poddasze      3
Name: count, dtype: int64
filtered[15] = filtered[15].replace({"parter": 0})
C:\Users\s433445\AppData\Local\temp\ipykernel_3048\4107925475.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  filtered[15] = filtered[15].replace({"parter": 0})
filtered
0 8 15 2
0 309000.0 43.44 1 390 zł
1 314900.0 42.60 1 NaN
2 249000.0 44.30 2 300 zł
3 419000.0 88 1 490 zł
4 499000.0 77 7 850 zł
... ... ... ... ...
2542 507600.0 94 3 1 zł
2543 342400.0 53.50 4 NaN
2544 335000.0 55.25 4 280 zł
2545 260000.0 62 2 NaN
2546 1990000.0 392 NaN NaN

2547 rows × 4 columns

string = ["> 10", "suterena", "poddasze"]
filtered = filtered[~filtered[15].isin(string)]
filtered = filtered[~filtered[15].isna()]
filtered[15].value_counts()
15
1     569
0     452
2     419
4     357
3     321
5     117
6      51
7      42
8      32
10     29
9      21
Name: count, dtype: int64
filtered[15] = filtered[15].apply(int)
filtered[8].value_counts()
8
38       59
48       40
50       35
53       28
43       26
         ..
33.79     1
42.60     1
47.82     1
53.09     1
55.25     1
Name: count, Length: 1084, dtype: int64
def check_value(number):
    try:
        return float(number)
    except:
        return str(number)
    
def check_str(value):
    if isinstance(value,float):
        return 1
    else:
        return 0
filtered[8] = filtered[8].apply(check_value)

filtered["isinstance"] =  filtered[15].apply(check_str)
filtered = filtered[filtered["isinstance"]==0]
filtered
0 8 15 2 isinstance
0 309000.0 43.44 1 390 zł 0
1 314900.0 42.6 1 NaN 0
2 249000.0 44.3 2 300 zł 0
3 419000.0 88.0 1 490 zł 0
4 499000.0 77.0 7 850 zł 0
... ... ... ... ... ...
2541 383680.0 70.4 0 NaN 0
2542 507600.0 94.0 3 1 zł 0
2543 342400.0 53.5 4 NaN 0
2544 335000.0 55.25 4 280 zł 0
2545 260000.0 62.0 2 NaN 0

2410 rows × 5 columns

filtered
0 8 15 2
0 309000.0 43.44 1 390 zł
1 314900.0 42.60 1 NaN
2 249000.0 44.30 2 300 zł
3 419000.0 88 1 490 zł
4 499000.0 77 7 850 zł
... ... ... ... ...
2541 383680.0 70.40 0 NaN
2542 507600.0 94 3 1 zł
2543 342400.0 53.50 4 NaN
2544 335000.0 55.25 4 280 zł
2545 260000.0 62 2 NaN

2410 rows × 4 columns

def check_value(number):
    try:
        return float(number)
    except:
        return str(number)
    
def check_str(value):
    if isinstance(value,float):
        return 1
    else:
        return 0
filtered[8] = filtered[8].apply(check_value)
filtered["check"] = filtered[8].apply(check_str)
C:\Users\s433445\AppData\Local\temp\ipykernel_3048\588287806.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  filtered[8] = filtered[8].apply(check_value)
filtered = filtered[filtered["check"]==1]
filtered = filtered[[0, 15, 8]]
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
X = filtered.drop(0,axis=1)
y = filtered[[0]]

scaler = StandardScaler()
trans_data = scaler.fit_transform(X)

X_train, X_test, y_train, y_test = train_test_split(trans_data,y, test_size=0.33)
reg = LinearRegression()
reg.fit(X_train, y_train)
results = reg.predict(X_test)
results
array([[ 588386.57221532],
       [ 347185.77610695],
       [ 333667.85491179],
       [ 350580.90494961],
       [ 483551.82037238],
       [ 248402.31355669],
       [ 295901.04373419],
       [ 323316.55226325],
       [ 514285.10329076],
       [ 569442.34898305],
       [ 299242.73507231],
       [ 381314.18786798],
       [ 394953.7443501 ],
       [ 892738.5148359 ],
       [ 272138.69489957],
       [ 378488.55823341],
       [ 302083.12498475],
       [ 439267.54263911],
       [ 377860.01791385],
       [ 305395.29576713],
       [ 262051.02670974],
       [ 419504.94601791],
       [ 317934.53105975],
       [ 747521.51913496],
       [ 266848.78842728],
       [ 231279.0665647 ],
       [ 343488.33557891],
       [ 268743.56605691],
       [ 415383.55851754],
       [ 248464.90773216],
       [ 521090.12125395],
       [ 389142.17256733],
       [ 488384.7062526 ],
       [ 543565.8688937 ],
       [ 787076.2329331 ],
       [ 461387.54108894],
       [ 343790.64726429],
       [1332628.97166205],
       [ 330121.57022644],
       [ 247314.70210211],
       [ 375146.86689529],
       [ 227824.89661056],
       [ 230348.21455975],
       [ 343064.38860658],
       [ 231279.0665647 ],
       [ 394257.00624813],
       [ 234021.73813899],
       [ 360674.17674638],
       [ 272197.73601105],
       [ 340395.51842163],
       [ 350610.42550535],
       [ 521075.36097608],
       [ 288535.68323385],
       [ 453467.44165838],
       [ 293757.39192372],
       [ 899504.85557242],
       [ 420196.08051295],
       [ 351019.61219981],
       [ 425627.986157  ],
       [ 593569.60367853],
       [ 548354.47394031],
       [ 207365.56188738],
       [ 289914.39915993],
       [ 469547.35802941],
       [ 882523.60775218],
       [ 354005.55434801],
       [ 347185.77610695],
       [ 251767.92184361],
       [1005309.13664698],
       [ 222300.8762353 ],
       [ 225165.18309654],
       [ 856623.21071403],
       [ 416679.31638334],
       [ 358643.00355193],
       [ 650710.18866767],
       [ 452907.09912123],
       [ 360795.81203333],
       [ 387081.47881714],
       [ 349806.81239429],
       [ 470638.52254798],
       [ 476732.04213132],
       [ 474988.42034439],
       [ 345866.10129235],
       [ 364264.74226534],
       [ 181162.85316385],
       [ 363947.67030209],
       [ 461787.57111248],
       [ 616581.77690664],
       [ 377919.05902532],
       [ 306038.59636457],
       [ 707747.45171172],
       [ 248284.23133373],
       [ 385240.13869206],
       [ 279041.43120091],
       [ 413322.86476735],
       [ 415422.23574421],
       [ 387870.33165033],
       [ 405821.10870219],
       [ 423801.40630978],
       [ 352656.35897767],
       [ 306267.1066606 ],
       [ 409435.59116995],
       [ 456302.22796389],
       [ 265318.91665851],
       [ 415383.55851754],
       [ 308829.10183646],
       [ 265318.91665851],
       [ 298780.11087331],
       [ 466635.21727057],
       [ 446087.32088017],
       [ 456302.22796389],
       [ 607004.56681341],
       [ 343692.92892614],
       [ 455317.9384544 ],
       [ 306788.77197108],
       [ 296992.20825276],
       [ 483610.86148386],
       [ 267053.38177451],
       [ 787046.71237736],
       [ 347215.29666269],
       [ 429052.63555539],
       [ 423801.40630978],
       [ 527895.13921713],
       [ 515088.71640181],
       [ 231279.0665647 ],
       [ 360840.09286694],
       [ 296962.68769702],
       [ 290756.68949766],
       [ 342859.79525934],
       [ 347156.25555121],
       [ 657894.87276958],
       [ 306267.1066606 ],
       [ 231279.0665647 ],
       [ 350634.34245415],
       [ 248776.37608848],
       [ 283761.83846511],
       [ 469532.59775154],
       [ 357400.68319067],
       [ 576997.54255276],
       [ 387110.99937288],
       [ 371191.39551548],
       [ 547882.69307037],
       [ 255323.36319989],
       [ 473366.43384441],
       [ 531441.42390248],
       [ 580422.19195116],
       [ 504099.71676278],
       [ 328416.62566617],
       [ 341759.47406984],
       [ 299447.32841954],
       [ 372555.35116369],
       [ 725683.4684857 ],
       [ 238098.84480575],
       [1375623.09513646],
       [ 299447.32841954],
       [ 809664.45918887],
       [ 361916.49710764],
       [ 371040.23967279],
       [ 388133.96610904],
       [ 418778.6873602 ],
       [ 390384.49292859],
       [ 780256.45469204],
       [ 371158.32189575],
       [ 265377.95776999],
       [ 384679.7961549 ],
       [ 467691.25762646],
       [ 354005.55434801],
       [ 301629.65745668],
       [ 355013.7608063 ],
       [ 906392.83159589],
       [ 251708.88073213],
       [ 350838.93580138],
       [ 339956.81117143],
       [ 194861.45075744],
       [ 350713.74745044],
       [ 279017.51425211],
       [ 369539.88845975],
       [ 538939.62690366],
       [ 736375.7600463 ],
       [ 265022.20858007],
       [ 335796.74644438],
       [ 535177.5416572 ],
       [ 315814.79619808],
       [ 283747.07818724],
       [ 275957.77071456],
       [ 562082.59208965],
       [ 279017.51425211],
       [ 440957.72692151],
       [ 514285.10329076],
       [ 367733.67249735],
       [ 480186.21208546],
       [ 258801.45010283],
       [ 241683.80671778],
       [ 923442.27719853],
       [ 497410.7304796 ],
       [ 422437.45066157],
       [ 351603.87168577],
       [ 555174.25218137],
       [ 380232.18002035],
       [ 319877.14258698],
       [ 485627.27440044],
       [ 459815.43902951],
       [ 520787.80956856],
       [ 309691.756059  ],
       [ 284458.57656708],
       [ 354005.55434801],
       [ 317018.43933267],
       [ 701843.76519774],
       [ 559553.67053352],
       [ 339016.80249555],
       [ 262445.45312633],
       [ 482042.31248842],
       [ 641132.97857445],
       [ 523209.85611561],
       [ 393394.35202559],
       [ 319906.66314272],
       [ 360854.85314481],
       [ 442662.67148177],
       [ 323316.55226325],
       [1089148.12817839],
       [ 268773.08661265],
       [ 446813.57953789],
       [ 231249.54600896],
       [ 169871.54183943],
       [ 135743.1300784 ],
       [ 388664.78809046],
       [ 282178.52919179],
       [ 482042.31248842],
       [ 698448.63635508],
       [ 343692.92892614],
       [ 302871.97781794],
       [ 381284.66731224],
       [ 787046.71237736],
       [ 480829.5126829 ],
       [ 182935.99550652],
       [ 456302.22796389],
       [ 231537.09741647],
       [ 238098.84480575],
       [ 299417.8078638 ],
       [ 394924.22379436],
       [ 409221.84115178],
       [ 387110.99937288],
       [ 240115.25772233],
       [ 262294.29728364],
       [ 263424.13902888],
       [ 317845.96939253],
       [ 353976.03379227],
       [ 169871.54183943],
       [ 367615.59027439],
       [ 377767.90318263],
       [ 455059.90760263],
       [ 381284.66731224],
       [ 555262.81384859],
       [ 306296.62721634],
       [ 189551.18040035],
       [ 218881.83044384],
       [ 323301.79198538],
       [ 286202.19835402],
       [ 500675.06736438],
       [ 512891.62708681],
       [ 385634.56510865],
       [1428105.86703687],
       [ 335592.15309715],
       [ 637011.59107407],
       [ 302077.52137781],
       [ 215564.05605452],
       [ 442633.15092603],
       [ 251708.88073213],
       [ 299565.4106425 ],
       [ 373100.93342297],
       [ 507981.38675324],
       [ 416172.41135072],
       [ 392907.81087778],
       [ 654090.55723246],
       [ 270478.03117291],
       [ 408652.3419437 ],
       [ 401729.24175755],
       [ 294688.24392867],
       [ 684779.55931722],
       [ 319877.14258698],
       [ 329317.95711538],
       [ 282471.68420624],
       [ 323331.31254112],
       [ 367674.63138587],
       [ 233280.7192034 ],
       [ 264369.7513117 ],
       [ 401744.00203542],
       [ 328650.73956914],
       [ 322673.25166581],
       [ 641800.19612068],
       [ 292657.07073422],
       [ 531373.22612007],
       [ 385391.29453475],
       [ 420824.62083251],
       [ 403463.70687355],
       [ 461470.49914922],
       [ 514255.58273502],
       [ 311055.71170721],
       [ 270205.24004327],
       [ 435146.15513874],
       [ 238098.84480575],
       [ 403721.73772533],
       [ 268743.56605691],
       [ 895540.22752167],
       [ 238069.32425001],
       [ 279047.03480784],
       [ 377178.04008974],
       [ 922555.70602719],
       [1012099.39433229],
       [ 401773.52259116],
       [ 583832.08107168],
       [ 331432.08837011],
       [ 383656.82941875],
       [ 493986.0810812 ],
       [ 212207.60443853],
       [2195111.56553086],
       [ 476050.06430722],
       [ 189960.36709481],
       [ 372297.32031192],
       [ 275592.86485371],
       [ 211783.6574662 ],
       [ 460803.28160299],
       [ 401862.08425838],
       [ 462137.71669546],
       [ 413308.10448948],
       [ 480200.97236333],
       [ 307251.39617009],
       [ 569442.34898305],
       [ 361522.07069104],
       [ 251708.88073213],
       [ 323301.79198538],
       [ 266751.07008913],
       [ 497410.7304796 ],
       [ 316570.57541154],
       [ 322133.27301347],
       [ 272197.73601105],
       [ 255104.00957479],
       [ 416172.41135072],
       [ 221005.1183695 ],
       [ 429008.35472178],
       [ 600229.06940596],
       [1245077.77932473],
       [ 343692.92892614],
       [ 329187.1651575 ],
       [ 291672.78122473],
       [ 388445.43446536],
       [ 848424.71654689],
       [ 364264.74226534],
       [ 357863.30738967],
       [ 159490.71863515],
       [ 340614.87204673],
       [ 473244.79855745],
       [ 440670.17551399],
       [ 437260.28639347],
       [ 350580.90494961],
       [ 245571.08031518],
       [ 420927.9427776 ],
       [ 378064.61126108],
       [ 439252.78236124],
       [ 391499.57439596],
       [ 353976.03379227],
       [ 394924.22379436],
       [ 606337.34926718],
       [ 374435.36851545],
       [ 325557.92241186],
       [ 340395.51842163],
       [ 380617.44976601],
       [ 608436.72024404],
       [ 399727.58911884],
       [ 466517.13504761],
       [1151919.60855186],
       [ 500675.06736438],
       [ 282383.12253903],
       [ 358150.85879719],
       [ 487065.031438  ],
       [ 394227.48569239],
       [ 279996.20015465],
       [ 369661.52374671],
       [ 602912.69986878],
       [ 548383.99449605],
       [ 349762.53156068],
       [ 252906.92025978],
       [ 549065.97232016],
       [ 930291.57599533],
       [ 515171.67446209],
       [ 235643.72463897],
       [ 296514.82377589],
       [ 273775.44167742],
       [ 343746.36643068],
       [ 343790.64726429],
       [ 317018.43933267],
       [ 377889.53846958],
       [ 487717.48870637],
       [ 279017.51425211],
       [ 356694.78841776],
       [ 466635.21727057],
       [ 572238.45806188],
       [ 412738.60528139],
       [ 342426.69161608],
       [ 364264.74226534],
       [ 308995.01795702],
       [ 680634.25486805],
       [ 419884.61215664],
       [ 442662.67148177],
       [ 562880.60159376],
       [ 579043.47602507],
       [ 344297.55229691],
       [ 360932.20759815],
       [ 478466.50724733],
       [ 527924.65977287],
       [ 238766.06235199],
       [ 261885.11058918],
       [ 405139.13087808],
       [ 308283.51957718],
       [ 378503.31851128],
       [2393089.72786879],
       [ 319877.14258698],
       [ 261923.78781585],
       [ 217580.4689711 ],
       [ 536161.83116668],
       [ 452225.12129712],
       [ 295598.73204881],
       [ 599488.05047038],
       [ 595455.22463722],
       [ 462137.71669546],
       [ 422120.37869832],
       [ 849053.25686645],
       [ 326210.37968023],
       [ 248776.37608848],
       [ 408534.25972074],
       [ 387451.98828494],
       [ 278958.47314063],
       [ 272168.21545531],
       [ 326755.96193952],
       [ 136834.29459696],
       [ 452907.09912123],
       [ 293294.76772472],
       [ 366369.71684913],
       [ 837513.07136119],
       [ 308078.92622995],
       [ 306267.1066606 ],
       [ 345792.299903  ],
       [ 292716.1118457 ],
       [ 647226.49815779],
       [ 452931.01607003],
       [ 356256.08116756],
       [ 267379.6104087 ],
       [ 616552.2563509 ],
       [ 306092.03386911],
       [ 384724.07698851],
       [ 282383.12253903],
       [ 183481.57776581],
       [ 258558.17952893],
       [ 268743.56605691],
       [ 230597.08874059],
       [ 236447.33775003],
       [ 414209.43593869],
       [ 230339.05788882],
       [ 349216.9493014 ],
       [ 388104.4455533 ],
       [ 524470.48981874],
       [ 258528.65897319],
       [ 422188.57648073],
       [ 514285.10329076],
       [ 221005.1183695 ],
       [ 347215.29666269],
       [ 378586.27657156],
       [ 375799.32416366],
       [ 399985.61997061],
       [ 309662.23550326],
       [ 215549.29577665],
       [ 435901.93435219],
       [ 364264.74226534],
       [ 142767.50166669],
       [ 374518.32657573],
       [ 360795.81203333],
       [ 574254.87097846],
       [ 732352.09088407],
       [ 258528.65897319],
       [ 394408.16209082],
       [ 285579.26164139],
       [ 465835.1572235 ],
       [ 747521.51913496],
       [ 254066.28256076],
       [ 437533.07752311],
       [ 261256.57026961],
       [ 340107.96701412],
       [ 340395.51842163],
       [ 417293.09642503],
       [ 306788.77197108],
       [ 450511.02006593],
       [ 217609.98952684],
       [ 435326.83153717],
       [ 296022.67902114],
       [ 297937.82053558],
       [ 344487.38536627],
       [ 694994.46640094],
       [ 287483.19594195],
       [ 232832.85528227],
       [ 299565.4106425 ],
       [ 585780.29620585],
       [ 351686.82974605],
       [ 379891.19110829],
       [ 418876.40569835],
       [ 493825.76856758],
       [ 373631.75540439],
       [ 336941.34846749],
       [ 226543.89902263],
       [ 508337.13594317],
       [ 379837.75360375],
       [ 698419.11579934],
       [ 405806.34842432],
       [ 421219.04724911],
       [ 472699.21629817],
       [ 626796.68399035],
       [ 282178.52919179],
       [ 625462.24889788],
       [ 194861.45075744],
       [ 486279.73166881],
       [ 336941.34846749],
       [ 333667.85491179],
       [ 551156.18662608],
       [ 300114.54596578],
       [ 703163.44001234],
       [ 346245.76743107],
       [ 424044.67688368],
       [ 375146.86689529],
       [ 231279.0665647 ],
       [ 403039.75990122],
       [ 323287.03170751],
       [ 232939.73029135],
       [ 299296.17257685],
       [ 447436.51625051],
       [ 357430.20374641],
       [ 336887.91096295],
       [ 429023.11499965],
       [ 353976.03379227],
       [ 381815.48929366],
       [ 419421.98795763],
       [ 360469.58339915],
       [ 459712.11708442],
       [ 787046.71237736],
       [ 493796.24801184],
       [ 562023.55097817],
       [ 326726.44138378],
       [ 675246.63005761],
       [ 834814.68062051],
       [ 558657.94269125],
       [ 551867.68500593],
       [ 367630.35055226],
       [ 340010.24867597],
       [ 271593.11264028],
       [ 497206.13713237],
       [ 396658.68891037],
       [ 357892.82794541],
       [ 746128.04293101],
       [ 306267.1066606 ],
       [ 590637.09903487],
       [ 275592.86485371],
       [ 422651.20067973],
       [1185366.04248879],
       [ 350669.46661683],
       [ 135743.1300784 ],
       [ 334910.17527305],
       [ 360825.33258907],
       [ 330038.61216615],
       [ 446087.32088017],
       [ 374402.29489571],
       [ 347215.29666269],
       [ 394612.75543805],
       [ 616552.2563509 ],
       [ 824570.25298105],
       [ 446057.80032443],
       [ 422914.83513844],
       [ 218988.70545292],
       [ 393930.77761394],
       [ 660895.57519565],
       [ 345807.06018087],
       [ 364338.54365469],
       [ 583802.56051594],
       [ 303456.2373039 ],
       [ 360795.81203333],
       [ 493825.76856758],
       [ 290601.98059097],
       [ 368341.8489321 ],
       [ 435857.65351858],
       [ 203795.36025323],
       [ 231030.19238385],
       [ 200545.78364632],
       [ 510860.45389236],
       [ 211910.89636009],
       [ 544988.86565339],
       [ 401349.57561883],
       [ 449452.92916709],
       [ 333546.21962483],
       [ 323779.17646225],
       [ 313116.4054574 ],
       [ 380587.92921027],
       [ 381314.18786798],
       [ 392098.59415979],
       [ 279017.51425211],
       [ 435813.37268497],
       [ 295818.08567391],
       [ 470000.82555749],
       [ 200545.78364632],
       [ 344487.38536627],
       [ 197121.13424792],
       [ 200682.17921114],
       [ 467672.94428459],
       [ 462137.71669546],
       [ 473541.5066359 ],
       [ 181162.85316385],
       [ 423537.77185107],
       [ 183481.57776581],
       [ 339956.81117143],
       [ 366378.87352007],
       [ 462137.71669546],
       [ 306267.1066606 ],
       [ 361877.81988097],
       [ 453559.5563896 ],
       [ 258801.45010283],
       [ 873809.0518815 ],
       [ 257179.46360285],
       [ 238039.80369427],
       [ 507465.3250497 ],
       [ 361142.40455232],
       [ 268402.57714485],
       [ 319936.18369846],
       [ 268743.56605691],
       [ 377889.53846958],
       [ 220853.96252681],
       [ 272426.24630708],
       [ 532766.70232403],
       [ 381255.1467565 ],
       [ 691569.81700254],
       [ 517709.75268916],
       [ 360854.85314481],
       [ 410698.27541602],
       [ 928245.64252301],
       [ 336941.34846749],
       [ 217580.4689711 ],
       [ 309039.29879063],
       [ 718644.33661954],
       [ 729063.83705049],
       [ 237553.26254647],
       [ 289149.46327554],
       [ 399054.76796567],
       [ 456272.70740815],
       [ 272168.21545531],
       [ 328742.85430035],
       [ 601115.6405773 ],
       [ 323301.79198538],
       [ 569851.53567751],
       [ 858669.14418635],
       [ 654090.55723246],
       [ 217580.4689711 ],
       [ 484974.81713207],
       [ 238098.84480575],
       [ 329317.95711538],
       [ 241582.53531563],
       [ 272168.21545531],
       [ 258801.45010283],
       [ 529259.09486535],
       [ 449452.92916709],
       [ 370207.10600599],
       [ 316482.01374432],
       [ 411004.14016539],
       [ 361877.81988097],
       [ 357400.68319067],
       [ 378283.96488618],
       [ 338509.89746294],
       [ 452931.01607003],
       [ 292598.02962274],
       [ 299038.14172508],
       [ 404457.15305397],
       [ 234021.73813899],
       [ 455694.05152913],
       [ 555203.77273711],
       [ 349421.54264863],
       [ 491121.77421996],
       [ 516354.95371188],
       [ 356081.00837607],
       [ 224400.24721216],
       [ 336941.34846749],
       [ 598197.89621152],
       [ 379564.96247411],
       [ 298901.74616026],
       [ 278958.47314063],
       [ 486976.46977078],
       [ 310403.25443884],
       [1008007.52738766],
       [ 341077.49624574],
       [ 348798.605936  ],
       [ 353308.81624603],
       [ 933716.22539373],
       [ 838224.56974104],
       [ 384679.7961549 ],
       [ 487065.031438  ],
       [ 577679.52037686],
       [ 367733.67249735],
       [ 435813.37268497],
       [ 846423.06390818],
       [ 846423.06390818],
       [ 378586.27657156],
       [ 546376.7382504 ],
       [ 281632.94693251],
       [1819561.13807363],
       [ 415354.0379618 ],
       [ 444056.14768572],
       [ 366369.71684913],
       [ 457666.1836121 ],
       [ 483551.82037238],
       [ 674813.52641434],
       [ 609761.99866558],
       [ 347171.01582908],
       [ 364279.50254321],
       [ 188869.20257624],
       [ 251738.40128787],
       [ 596092.92162772],
       [ 263969.72128817],
       [ 248328.51216734],
       [ 630888.55093499],
       [ 434532.37509704],
       [ 566563.28184394],
       [ 428993.59444391],
       [ 459697.35680655],
       [ 391529.0949517 ],
       [ 292657.07073422],
       [ 425530.26781884],
       [ 558628.42213551],
       [ 984669.12552537],
       [ 483669.90259534],
       [ 281715.90499279],
       [ 401714.48147968],
       [ 466561.41588122],
       [ 497410.7304796 ],
       [ 268743.56605691],
       [ 269766.53279307],
       [ 439418.6984818 ],
       [ 439282.30291698],
       [ 343162.10694473],
       [ 188231.50558575],
       [ 350669.46661683],
       [ 585848.49398826],
       [ 943263.91493121],
       [ 336970.86902323],
       [ 335636.43393076],
       [ 930262.05543959],
       [ 341033.21541213],
       [ 323360.83309686],
       [ 279026.67092304],
       [ 437153.41138438],
       [ 295097.43062313],
       [ 398363.63347063],
       [ 602411.3984431 ],
       [ 423967.32243034],
       [ 352202.8914496 ],
       [ 219641.16272129],
       [ 524529.53093021],
       [ 545080.9803846 ],
       [ 270750.82230255],
       [ 429023.11499965],
       [ 235341.41295359],
       [ 705019.5404153 ],
       [ 466531.89532548],
       [ 283124.14147461],
       [ 304849.71350785],
       [ 493825.76856758],
       [ 326785.48249526],
       [ 497410.7304796 ],
       [ 316511.53430006],
       [ 742762.43464409],
       [ 316482.01374432],
       [ 371158.32189575],
       [ 355740.01946401],
       [ 512005.05591547],
       [ 378586.27657156],
       [ 285111.03383545],
       [ 586613.42987265],
       [ 309721.27661474],
       [ 392869.13365111],
       [ 243598.94823221],
       [ 357907.58822328],
       [ 463151.52676069],
       [ 884545.6242757 ],
       [ 306267.1066606 ],
       [ 326755.96193952],
       [ 521119.64180969],
       [ 339766.97810207],
       [ 215018.47379524],
       [ 526341.35049956],
       [ 351248.12249585],
       [ 480156.69152972],
       [ 524500.01037447],
       [ 633645.98278715]])
from sklearn.metrics import r2_score
r2_score(y_test, results)
0.5703042723573604