Kaggle competition: New York City Taxi Trip Duration
<SOS> metric: RMSLE Kaggle data source: new-york-city-taxi-trip-duration<predict_on_test>
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import model_selection as b
from haversine import haversine
from sklearn.ensemble import RandomForestRegressor
from sklearn.cluster import MiniBatchKMeans
from xgboost import XGBRegressor
import tensorflow as tf
from sklearn.metrics import mean_absolute_error
print('Predicting')
 for(test_df, sample_prediction_df)in env.iter_test() :
sample_prediction_df = sample_prediction_df.replace(sample_prediction_df, 0 ).reset_index(drop=True)
 predictions_df = make_prediction(test_df, sample_prediction_df, model, labels)
 env.predict(predictions_df)
 print('Writing Submissions')
 env.write_submission_file()<feature_engineering>
ds=pd.read_csv('.. /input/nyc-taxi-trip-duration/train.zip',compression='zip')
 test=pd.read_csv('.. /input/nyc-taxi-trip-duration/test.zip',compression='zip')
 holidays=pd.read_csv('.. /input/nyc2016holidays/NYC_2016Holidays.csv')
 weather=pd.read_csv('.. /input/knycmetars2016/KNYC_Metars.csv')
 nyc_weather=pd.read_csv('.. /input/weather-data-in-new-york-city-2016/weather_data_nyc_centralpark_2016(1 ).csv' )
<define_variables>
env = nflrush.make_env()
labels = {20190905000518 : 6 ,
20190905001453 : 5 ,
20190905002670 : 8 ,
20190905003087 : 9 ,
20190905003108 : 6 ,
20190905003866 : 0 ,
20190908000051 : 5 ,
20190908000690 : 6 ,
20190908000963 : 6 ,
20190908001134 : 5 ,
20190908001220 : 13 ,
20190908001690 : 1 ,
20190908001711 : 17 ,
20190908002759 : 7 ,
20190908003078 : 10 ,
20190908003654 : 3 ,
20190908003728 : 6 ,
20190908003902 : 17 ,
20190908003923 : 7 ,
20190908003944 : 2 ,
20190908011320 : 5 ,
20190908012547 : 15 ,
20190908013336 : 4 ,
20190908013549 : 7 ,
20190908013570 : 4 ,
20190908013934 : 0 ,
20190908014230 : 2 ,
20190908020715 : 13 ,
20190908020882 : 12 ,
20190908021573 : 4 ,
20190908022135 : 14 ,
20190908022156 : 6 ,
20190908022345 : 2 ,
20190908022834 : 3 ,
20190908022855 : 31 ,
20190908023187 : 7 ,
20190908023314 : 0 ,
20190908023456 : 4 ,
20190908031367 : 10 ,
20190908032925 : 5 ,
20190908033082 : 3 ,
20190908033256 : 9 ,
20190908033326 : 5 ,
20190908033392 : 0 ,
20190908033649 : 2 ,
20190908033670 : 2 ,
20190908040277 : 4 ,
20190908040877 : 2 ,
20190908041221 : 1 ,
20190908041399 : 6 ,
20190908041420 : 22 ,
20190908042203 : 2 ,
20190908042224 : 6 ,
20190908043022 : 4 ,
20190908043043 : -2 ,
20190908043345 : 2 ,
20190908043427 : 0 ,
20190908043448 : 0 ,
20190908051455 : 9 ,
20190908051738 : 4 ,
20190908052527 : 6 ,
20190908052909 : 20 ,
20190908053146 : 5 ,
20190908053326 : 7 ,
20190908060304 : 2 ,
20190908060450 : 1 ,
20190908060967 : 6 ,
20190908062138 : 3 ,
20190908062159 : 2 ,
20190908062300 : 17 ,
20190908062321 : 19 ,
20190908062342 : 0 ,
20190908063398 : 9 ,
20190908063419 : 17 ,
20190908070203 : -3 ,
20190908070368 : 23 ,
20190908070389 : 3 ,
20190908070410 : 13 ,
20190908071777 : 25 ,
20190908071798 : 5 ,
20190908071819 : 6 ,
20190908071840 : 10 ,
20190908071861 : 3 ,
20190908072211 : -2 ,
20190908072528 : 9 ,
20190908072946 : 7 ,
20190908072967 : 7 ,
20190908072988 : 6 ,
20190908073009 : 4 ,
20190908073123 : 7 ,
20190908073144 : 1 ,
20190908073209 : 4 ,
20190908073230 : 4 ,
20190908073708 : 3 ,
20190908073729 : 19 ,
20190908073795 : 2 ,
20190908081184 : 5 ,
20190908081299 : 11 ,
20190908081535 : 0 ,
20190908081635 : 6 ,
20190908082351 : -6 ,
20190908082460 : -3 ,
20190908082553 : -1 ,
20190908082574 : 3 ,
20190908082927 : -28 ,
20190908082948 : 5 ,
20190908083948 : 21 ,
20190908090080 : 9 ,
20190908090675 : 6 ,
20190908090697 : 3 ,
20190908091562 : 5 ,
20190908091583 : 4 ,
20190908091760 : 1 ,
20190908093671 : 12 ,
20190908093815 : 4 ,
20190908094226 : 3 ,
20190908095267 : 9 ,
20190908100340 : 7 ,
20190908102368 : 11 ,
20190908102851 : 1 ,
20190908102917 : 8 ,
20190908103346 : 2 ,
20190908103660 : -3 ,
20190908110453 : 14 ,
20190908110776 : 6 ,
20190908111259 : 0 ,
20190908111479 : 3 ,
20190908111500 : 4 ,
20190908111862 : 5 ,
20190908112640 : 5 ,
20190908112749 : 10 ,
20190908112775 : 13 ,
20190908112796 : 8 ,
20190908112950 : 11 ,
20190908112971 : 9 ,
20190908112992 : 2 ,
20190908113345 : 0 ,
20190908113512 : 16 ,
20190908113533 : 5 ,
20190908113730 : 0 ,
20190908120058 : -1 ,
20190908120083 : 7 ,
20190908120136 : 3 ,
20190908120291 : 3 ,
20190908120312 : 2 ,
20190908120480 : 8 ,
20190908120853 : 5 ,
20190908121366 : 5 ,
20190908121387 : 4 ,
20190908121448 : 4 ,
20190908122855 : 11 ,
20190908122876 : 11 ,
20190908122897 : 3 ,
20190908123285 : 8 ,
20190908123306 : 0 ,
20190908123468 : 4 ,
20190908123492 : 6 ,
20190908123835 : 0 ,
20190908123856 : -5 ,
20190909000051 : 9 ,
20190909001139 : 5 ,
20190909001516 : 20 ,
20190909003540 : 28 ,
20190909010058 : 4 ,
20190909010240 : 6 ,
20190909010695 : 0 ,
20190909011098 : 5 ,
20190909011418 : 8 ,
20190909012012 : 4 ,
20190909012033 : 5 ,
20190909012404 : 4 ,
20190909012425 : 7 ,
20190909012514 : 5 ,
20190909013198 : 8 ,
20190909013219 : 4 ,
20190909013240 : 2 ,
20190909013261 : 4 ,
20190912000216 : 10 ,
20190912000311 : 6 ,
20190912000487 : 6 ,
20190912001458 : 7 ,
20190912001753 : 5 ,
20190912002619 : 12 ,
20190912002881 : 13 ,
20190912003364 : 4 ,
20190912003623 : 3 ,
20190912003644 : 12 ,
20190912003665 : 2 ,
20190912003781 : 1 ,
20190915003804 : 4 ,
20190915003825 : 7 ,
20190915004239 : 3 ,
20190915010183 : 6 ,
20190915010458 : 2 ,
20190915010479 : 2 ,
20190915010693 : 12 ,
20190915011263 : 4 ,
20190915011289 : 5 ,
20190915011371 : 4 ,
20190915012585 : 15 ,
20190915012776 : 3 ,
20190915012897 : 7 ,
20190915012923 : 18 ,
20190915013026 : -4 ,
20190915013250 : 6 ,
20190915013277 : 7 ,
20190915013298 : 20 ,
20190915013545 : 3 ,
20190915013566 : 11 ,
20190915013587 : 14 ,
20190915013613 : 1 ,
20190915013634 : 6 ,
20190915013660 : 10 ,
20190915013682 : -6 ,
20190915014065 : 3 ,
20190915014123 : 3 ,
20190915020150 : 2 ,
20190915020589 : 7 ,
20190915020816 : 9 ,
20190915020837 : 4 ,
20190915021208 : 17 ,
20190915021316 : 8 ,
20190915022711 : 2 ,
20190915022858 : 9 ,
20190915023039 : 5 ,
20190915023146 : 4 ,
20190915023317 : 7 ,
20190915023563 : 13 ,
20190915030215 : 3 ,
20190915030440 : 1 ,
20190915030696 : 0 ,
20190915031233 : 5 ,
20190915031254 : 4 ,
20190915031318 : 5 ,
20190915031690 : 8 ,
20190915031711 : 4 ,
20190915031794 : -48 ,
20190915032382 : 9 ,
20190915032722 : 11 ,
20190915032743 : 9 ,
20190915032769 : 2 ,
20190915033335 : 8 ,
20190915033649 : 5 ,
20190915033670 : 10 ,
20190915033771 : 8 ,
20190915033792 : 3 ,
20190915034057 : 2 ,
20190915034233 : 1 ,
20190915042535 : 8 ,
20190915042556 : 1 ,
20190915042577 : 5 ,
20190915042598 : 7 ,
20190915042619 : 2 ,
20190915042856 : 8 ,
20190915043538 : 0 ,
20190915050051 : 1 ,
20190915050274 : 4 ,
20190915050349 : 1 ,
20190915050492 : 2 ,
20190915050658 : 7 ,
20190915050790 : -1 ,
20190915050811 : 1 ,
20190915050974 : 5 ,
20190915051239 : 4 ,
20190915051260 : 5 ,
20190915051281 : 4 ,
20190915051302 : 9 ,
20190915051323 : 0 ,
20190915051683 : 1 ,
20190915052236 : 3 ,
20190915052411 : 3 ,
20190915052769 : 4 ,
20190915053639 : 0 ,
20190915053779 : 6 ,
20190915060051 : 6 ,
20190915060072 : 20 ,
20190915060093 : 14 ,
20190915060119 : 8 ,
20190915060858 : 9 ,
20190915063344 : 4 ,
20190915063437 : 20 ,
20190915063558 : 1 ,
20190915063856 : 4 ,
20190915064126 : 9 ,
20190915064185 : 6 ,
20190915070677 : 23 ,
20190915071334 : 7 ,
20190915071355 : 5 ,
20190915071376 : 4 ,
20190915071507 : 3 ,
20190915073013 : 3 ,
20190915073318 : 7 ,
20190915073647 : 4 ,
20190915080778 : 12 ,
20190915081066 : 1 ,
20190915081234 : 10 ,
20190915081255 : 15 ,
20190915081537 : 3 ,
20190915082326 : 5 ,
20190915082347 : 4 ,
20190915082647 : 9 ,
20190915082823 : 11 ,
20190915082844 : 6 ,
20190915083037 : 4 ,
20190915083216 : 2 ,
20190915083329 : 7 ,
20190915090627 : 6 ,
20190915090836 : 4 ,
20190915090924 : 0 ,
20190915091098 : 10 ,
20190915091818 : 8 ,
20190915092156 : 13 ,
20190915092746 : 9 ,
20190915092773 : 3 ,
20190915093324 : 3 ,
20190915094001 : 7 ,
20190915100234 : 8 ,
20190915100255 : 1 ,
20190915102804 : 51 ,
20190915103318 : 1 ,
20190915104057 : 3 ,
20190915110301 : 0 ,
20190915110448 : 2 ,
20190915110676 : 7 ,
20190915110702 : 9 ,
20190915111031 : 0 ,
20190915111114 : 4 ,
20190915112411 : -3 ,
20190915112524 : 12 ,
20190915112545 : 46 ,
20190915112571 : 3 ,
20190915112592 : 14 ,
20190915112613 : 3 ,
20190915112690 : -1 ,
20190915112711 : 1 ,
20190915112874 : 7 ,
20190915113427 : 14 ,
20190915120051 : 2 ,
20190915120623 : 2 ,
20190915121909 : 4 ,
20190915123059 : 12 ,
20190915123965 : 0 ,
20190915123986 : 9 ,
20190915124007 : 6 ,
20190915130147 : 9 ,
20190915130423 : 4 ,
20190915130790 : 2 ,
20190915133172 : 28 ,
20190916000057 : 8 ,
20190916001346 : 8 ,
20190916001367 : -1 ,
20190916001496 : 6 ,
20190916001517 : 6 ,
20190916001542 : 7 ,
20190916001563 : 5 ,
20190916002956 : 8 ,
20190916003336 : 15 ,
20190919000260 : 2 ,
20190919000498 : -3 ,
20190919001591 : 8 ,
20190919002518 : 4 ,
20190919002620 : 0 ,
20190919002641 : 11 ,
20190919003693 : 69 ,
20190922000245 : 12 ,
20190922000721 : 0 ,
20190922000998 : 3 ,
20190922001129 : 9 ,
20190922001217 : 8 ,
20190922002797 : 3 ,
20190922002856 : 5 ,
20190922002974 : 10 ,
20190922003243 : 22 ,
20190922003264 : 3 ,
20190922003651 : 1 ,
20190922003800 : 9 ,
20190922003821 : 2 ,
20190922004055 : 4 ,
20190922010301 : 7 ,
20190922010708 : 13 ,
20190922010969 : 5 ,
20190922010990 : 0 ,
20190922011290 : 4 ,
20190922011524 : 3 ,
20190922011754 : 6 ,
20190922012835 : 12 ,
20190922013448 : 18 ,
20190922013514 : 2 ,
20190922013540 : 6 ,
20190922013561 : 28 ,
20190922013858 : 6 ,
20190922013879 : 11 ,
20190922020225 : 2 ,
20190922020652 : 8 ,
20190922020679 : 9 ,
20190922020873 : 3 ,
20190922021240 : 4 ,
20190922021384 : 6 ,
20190922022003 : 4 ,
20190922022250 : 12 ,
20190922022445 : 5 ,
20190922022703 : 2 ,
20190922022899 : 5 ,
20190922023251 : 9 ,
20190922030060 : 8 ,
20190922030199 : 0 ,
20190922030328 : 28 ,
20190922031017 : -2 ,
20190922031481 : 24 ,
20190922032684 : 2 ,
20190922033960 : 4 ,
20190922040969 : 2 ,
20190922041421 : 5 ,
20190922041442 : 7 ,
20190922041600 : 9 ,
20190922042341 : 9 ,
20190922042362 : 4 ,
20190922042383 : 15 ,
20190922042404 : 13 ,
20190922042425 : 1 ,
20190922042568 : 25 ,
20190922042594 : 8 ,
20190922042615 : 1 ,
20190922042683 : 3 ,
20190922043591 : 8 ,
20190922043888 : 41 ,
20190922050514 : 3 ,
20190922050535 : 8 ,
20190922050743 : 7 ,
20190922051091 : 3 ,
20190922051634 : 1 ,
20190922052346 : 15 ,
20190922052367 : 6 ,
20190922052594 : 4 ,
20190922053192 : 21 ,
20190922053213 : 2 ,
20190922053234 : 24 ,
20190922053255 : 2 ,
20190922053276 : 2 ,
20190922060101 : 1 ,
20190922061343 : 0 ,
20190922062124 : 3 ,
20190922063123 : 2 ,
20190922070232 : 1 ,
20190922070393 : 11 ,
20190922070414 : 6 ,
20190922070435 : 2 ,
20190922070762 : 5 ,
20190922071335 : 2 ,
20190922071498 : 6 ,
20190922072075 : 3 ,
20190922072096 : 6 ,
20190922072303 : 5 ,
20190922073144 : 3 ,
20190922073270 : 5 ,
20190922073698 : 2 ,
20190922080051 : 5 ,
20190922081063 : 0 ,
20190922081274 : 2 ,
20190922082478 : 9 ,
20190922082499 : 5 ,
20190922083003 : 8 ,
20190922083140 : 5 ,
20190922083548 : 1 ,
20190922083755 : 3 ,
20190922090171 : 3 ,
20190922090192 : 13 ,
20190922092474 : 4 ,
20190922093131 : 8 ,
20190922093497 : 5 ,
20190922093615 : 5 ,
20190922093636 : 13 ,
20190922093657 : 7 ,
20190922093678 : 4 ,
20190922093703 : 6 ,
20190922093724 : 2 ,
20190922093892 : 8 ,
20190922110284 : 4 ,
20190922110697 : 16 ,
20190922111279 : 7 ,
20190922111300 : 0 ,
20190922111376 : 4 ,
20190922111629 : 0 ,
20190922113548 : 7 ,
20190922113607 : -1 ,
20190922114006 : 3 ,
20190922120256 : 4 ,
20190922120499 : 5 ,
20190922121760 : 4 ,
20190922122038 : 6 ,
20190922122168 : 5 ,
20190922122189 : 6 ,
20190922122713 : 9 ,
20190922122800 : 5 ,
20190922123251 : 3 ,
20190922123500 : 5 ,
20190922123525 : 19 ,
20190922123546 : 6 ,
20190922123573 : 5 ,
20190922130338 : 9 ,
20190922130817 : 2 ,
20190922130838 : 7 ,
20190922131004 : 2 ,
20190922132070 : 7 ,
20190922132417 : 9 ,
20190922132948 : 5 ,
20190922133177 : 13 ,
20190922133321 : -22 ,
20190922133342 : 4 ,
20190923001489 : 8 ,
20190923002627 : 1 ,
20190923002779 : 11 ,
20190923003450 : 2 ,
20190923003562 : 3 ,
20190923003819 : 8 ,
20190923003840 : 1 ,
20190923003924 : 8 ,
20190923003945 : 4 ,
20190923003966 : 25 ,
20190923003989 : 3 ,
20190923004072 : 4 ,
20190926000051 : 4 ,
20190926000371 : 4 ,
20190926001290 : 4 ,
20190926001388 : 6 ,
20190926001538 : 8 ,
20190926001838 : 3 ,
20190926002350 : 3 ,
20190926003101 : 30 ,
20190926003294 : 16 ,
20190926003696 : 7 ,
20190926003719 : 10 ,
20190929000449 : 10 ,
20190929000845 : 16 ,
20190929001564 : 7 ,
20190929001674 : -21 ,
20190929001695 : 5 ,
20190929002762 : 8 ,
20190929002945 : 5 ,
20190929003234 : 13 ,
20190929004058 : 0 ,
20190929004079 : -1 ,
20190929010302 : -2 ,
20190929011020 : 9 ,
20190929011388 : 9 ,
20190929011409 : 4 ,
20190929011430 : 5 ,
20190929011451 : 5 ,
20190929012295 : 9 ,
20190929012316 : 8 ,
20190929012382 : 3 ,
20190929012440 : 17 ,
20190929013421 : 3 ,
20190929013825 : 5 ,
20190929013902 : 4 ,
20190929013923 : 11 ,
20190929020058 : 15 ,
20190929020252 : 9 ,
20190929020790 : 28 ,
20190929020966 : 4 ,
20190929021352 : 2 ,
20190929021509 : 1 ,
20190929021680 : 6 ,
20190929021877 : 5 ,
20190929022685 : 5 ,
20190929023200 : 5 ,
20190929024641 : 8 ,
20190929024667 : 9 ,
20190929030105 : 1 ,
20190929030126 : 8 ,
20190929030218 : 2 ,
20190929031658 : 1 ,
20190929031679 : 0 ,
20190929032246 : 5 ,
20190929032267 : 11 ,
20190929032288 : 13 ,
20190929033132 : 12 ,
20190929034101 : 9 ,
20190929040106 : 4 ,
20190929040340 : 4 ,
20190929040595 : 5 ,
20190929042436 : 10 ,
20190929042537 : 6 ,
20190929043306 : 1 ,
20190929043933 : 3 ,
20190929050166 : 12 ,
20190929050187 : 1 ,
20190929050669 : 18 ,
20190929050893 : 13 ,
20190929051683 : 3 ,
20190929052750 : 1 ,
20190929052851 : 7 ,
20190929052872 : 6 ,
20190929053012 : 4 ,
20190929053506 : 0 ,
20190929053965 : 8 ,
20190929060587 : 1 ,
20190929060748 : 3 ,
20190929060887 : 5 ,
20190929061728 : 8 ,
20190929061749 : 1 ,
20190929062270 : 8 ,
20190929062331 : 8 ,
20190929062411 : 1 ,
20190929062571 : 7 ,
20190929062637 : 7 ,
20190929062658 : 4 ,
20190929063315 : 4 ,
20190929063336 : 9 ,
20190929063361 : 4 ,
20190929063675 : 2 ,
20190929070661 : 2 ,
20190929071414 : 9 ,
20190929072286 : 2 ,
20190929072576 : 4 ,
20190929072741 : 5 ,
20190929073443 : 1 ,
20190929073514 : 2 ,
20190929073535 : 3 ,
20190929073611 : 1 ,
20190929073758 : 3 ,
20190929080051 : 8 ,
20190929080184 : 7 ,
20190929080419 : 8 ,
20190929081771 : 4 ,
20190929081873 : 8 ,
20190929081896 : 11 ,
20190929082595 : 5 ,
20190929082809 : 6 ,
20190929083400 : 6 ,
20190929083789 : -3 ,
20190929090136 : 7 ,
20190929090203 : 0 ,
20190929091356 : 3 ,
20190929093114 : 0 ,
20190929093476 : -1 ,
20190929094404 : 6 ,
20190929094547 : 24 ,
20190929100724 : 0 ,
20190929101208 : 4 ,
20190929102671 : 3 ,
20190929103196 : 4 ,
20190929103574 : 2 ,
20190929110517 : 1 ,
20190929111108 : 11 ,
20190929111438 : 3 ,
20190929111459 : 6 ,
20190929112350 : 13 ,
20190929112371 : 8 ,
20190929112392 : 6 ,
20190929112620 : 6 ,
20190929112641 : 3 ,
20190929112662 : 0 ,
20190929112685 : 2 ,
20190929112708 : 2 ,
20190929113299 : 11 ,
20190929113574 : 26 ,
20190929113595 : 2 ,
20190929113663 : 16 ,
20190929113684 : 3 ,
20190929120441 : 6 ,
20190929120778 : 2 ,
20190929122559 : 1 ,
20190929122641 : 9 ,
20190929122667 : 0 ,
20190929122793 : 3 ,
20190929122820 : 11 ,
20190929123622 : 2 ,
20190929123649 : 9 ,
20190929123672 : 5 ,
20190929123693 : 4 ,
20190930000058 : 4 ,
20190930002015 : 21 ,
20190930002036 : 4 ,
20190930002436 : 15 ,
20190930002457 : 5 ,
20190930002642 : 7 ,
20190930002723 : 4 ,
20191003000214 : 9 ,
20191003000343 : 4 ,
20191003000364 : 7 ,
20191003000557 : 12 ,
20191003000583 : 8 ,
20191003001287 : 0 ,
20191003001403 : 6 ,
20191003001771 : 4 ,
20191003001792 : 8 ,
20191003002750 : 7 ,
20191003003112 : 7 ,
20191003003861 : 8 ,
20191003003924 : 1 ,
20191003003999 : 2 ,
20191003004022 : 14 ,
20191006001388 : -1 ,
20191006001655 : 6 ,
20191006003377 : 10 ,
20191006003515 : -88 ,
20191006003536 : 48 ,
20191006003559 : 4 ,
20191006003580 : 5 ,
20191006010172 : 9 ,
20191006010193 : 3 ,
20191006010214 : 13 ,
20191006010235 : 5 ,
20191006010256 : 18 ,
20191006010323 : 4 ,
20191006010869 : 17 ,
20191006011111 : 4 ,
20191006011611 : 6 ,
20191006011990 : 1 ,
20191006012469 : 4 ,
20191006012736 : 2 ,
20191006014216 : 9 ,
20191006020158 : 1 ,
20191006020480 : 6 ,
20191006020501 : 14 ,
20191006020847 : 3 ,
20191006021251 : 4 ,
20191006021470 : 8 ,
20191006022310 : 6 ,
20191006023530 : 0 ,
20191006023693 : 10 ,
20191006023804 : 24 ,
20191006030323 : 5 ,
20191006030785 : 5 ,
20191006031337 : 14 ,
20191006032095 : 8 ,
20191006032116 : 4 ,
20191006032299 : 4 ,
20191006032407 : 5 ,
20191006033608 : 4 ,
20191006033630 : 16 ,
20191006033656 : 1 ,
20191006040592 : 0 ,
20191006040929 : 5 ,
20191006042807 : 5 ,
20191006043682 : 2 ,
20191006043759 : 6 ,
20191006043849 : 3 ,
20191006044088 : 2 ,
20191006044147 : 5 ,
20191006050083 : 5 ,
20191006050104 : 3 ,
20191006050207 : 4 ,
20191006050765 : 9 ,
20191006050964 : 3 ,
20191006051030 : 5 ,
20191006051187 : -1 ,
20191006051903 : 6 ,
20191006051997 : 4 ,
20191006053042 : 0 ,
20191006053662 : 8 ,
20191006060051 : 1 ,
20191006060196 : 5 ,
20191006060380 : 5 ,
20191006060539 : 3 ,
20191006060560 : 6 ,
20191006062381 : 8 ,
20191006062402 : 1 ,
20191006062723 : 12 ,
20191006062744 : 3 ,
20191006062765 : 13 ,
20191006062786 : 0 ,
20191006063640 : 3 ,
20191006063661 : 0 ,
20191006063754 : 4 ,
20191006070205 : 14 ,
20191006070346 : 2 ,
20191006070622 : -2 ,
20191006070741 : 8 ,
20191006070868 : 5 ,
20191006072267 : 4 ,
20191006072330 : 7 ,
20191006072351 : 4 ,
20191006073822 : 4 ,
20191006081653 : 9 ,
20191006082009 : 2 ,
20191006082284 : 17 ,
20191006082820 : 6 ,
20191006083718 : -1 ,
20191006083739 : 11 ,
20191006083760 : 11 ,
20191006090105 : 2 ,
20191006090410 : 2 ,
20191006091022 : 7 ,
20191006091201 : 4 ,
20191006092585 : 2 ,
20191006092651 : 5 ,
20191006092672 : 11 ,
20191006093004 : 25 ,
20191006093128 : 12 ,
20191006093592 : 6 ,
20191006093725 : 12 ,
20191006093746 : 7 ,
20191006094011 : -1 ,
20191006094218 : 0 ,
20191006094244 : 1 ,
20191006094351 : 12 ,
20191006094372 : 2 ,
20191006100075 : 21 ,
20191006100146 : 5 ,
20191006100167 : 1 ,
20191006101306 : 6 ,
20191006102259 : 16 ,
20191006102663 : 7 ,
20191006102777 : 5 ,
20191006103155 : 3 ,
20191006103242 : 6 ,
20191006103758 : 32 ,
20191006110721 : 7 ,
20191006111288 : 6 ,
20191006111309 : 7 ,
20191006111333 : 5 ,
20191006111629 : 7 ,
20191006111650 : 4 ,
20191006113994 : 5 ,
20191006114237 : 11 ,
20191006120464 : 4 ,
20191006120554 : 2 ,
20191006120575 : 30 ,
20191006121149 : 4 ,
20191006121417 : 11 ,
20191006121720 : 2 ,
20191006123495 : 4 ,
20191006123619 : 3 ,
20191006123640 : 5 ,
20191006123661 : 3 ,
20191006123747 : 9 ,
20191006123768 : 3 ,
20191006123789 : 8 ,
20191006124026 : 33 ,
20191006124047 : 6 ,
20191006124182 : 3 ,
20191007000508 : 6 ,
20191007000783 : 4 ,
20191007000804 : 8 ,
20191007000825 : 4 ,
20191007001179 : 11 ,
20191007001342 : 15 ,
20191007001363 : 3 ,
20191007001711 : 1 ,
20191007001736 : 4 ,
20191007002778 : 6 ,
20191007002893 : 3 ,
20191007002918 : 19 ,
20191007003141 : 5 ,
20191007003817 : 3 ,
20191007003902 : 3 ,
20191007003923 : 2 }
df = pd.read_csv('/kaggle/input/nfl-big-data-bowl-2020/train.csv', low_memory=False)
 n = len(df)
 prior = 199 * [0.]
counts = df.Yards.value_counts()
for i, ni in zip(counts.index, counts.values):
prior[i+99] = ni/n
pred = np.cumsum(prior)
 names = dict(zip(range(199), ['Yards%d' % i for i in range(-99, 100)]))
for(test_df, sample_prediction_df)in env.iter_test() :
play = test_df["PlayId"].values[0]
if play in labels:
preds = [0 if i < labels[play] else 1 for i in range(-99, 100)]
else:
preds = pred
env.predict(pd.DataFrame(preds ).transpose().rename(names, axis=1))
env.write_submission_file()<set_options>
me = np.mean(ds['trip_duration'])
 st = np.std(ds['trip_duration'])
 ds = ds[ds['trip_duration'] <= me + 2*st]
ds = ds[ds['trip_duration'] >= me - 2*st]
pd.set_option('display.max_columns', 50)
 pd.set_option('display.max_rows', 150 )<import_modules>
ds['trip_duration_log']=(ds['trip_duration']+1 ).apply(np.log )
from keras.layers import Dense
from keras.models import Sequential
from keras.callbacks import Callback, EarlyStopping<load_from_csv>
ds = ds[ds['pickup_longitude'] <= -73.75]
ds = ds[ds['pickup_longitude'] >= -74.03]
ds = ds[ds['pickup_latitude'] <= 40.85]
ds = ds[ds['pickup_latitude'] >= 40.63]
ds = ds[ds['dropoff_longitude'] <= -73.75]
ds = ds[ds['dropoff_longitude'] >= -74.03]
ds = ds[ds['dropoff_latitude'] <= 40.85]
ds = ds[ds['dropoff_latitude'] >= 40.63]
train = pd.read_csv('/kaggle/input/nfl-big-data-bowl-2020/train.csv', usecols=['GameId', 'PlayId', 'Team', 'X', 'Y', 'S', 'A', 'Dis',
'Orientation', 'Dir', 'NflId', 'DisplayName', 'YardLine',
'Quarter', 'GameClock', 'PossessionTeam', 'Down', 'Distance',
'FieldPosition', 'NflIdRusher', 'OffenseFormation',
'OffensePersonnel', 'DefendersInTheBox', 'DefensePersonnel',
'PlayDirection', 'TimeHandoff', 'TimeSnap', 'Yards'] )<remove_duplicates>
coords = np.vstack(( ds[['pickup_latitude', 'pickup_longitude']].values,
ds[['dropoff_latitude', 'dropoff_longitude']].values))
outcomes = train[['GameId','PlayId','Yards']].drop_duplicates()<prepare_x_and_y>
sample_ind = np.random.permutation(len(coords)) [:500000]
kmeans = MiniBatchKMeans(n_clusters=50, batch_size=10000 ).fit(coords[sample_ind] )
def create_features(df, deploy=False):
def new_X(x_coordinate, play_direction):
if play_direction == 'left':
return 120.0 - x_coordinate
else:
return x_coordinate
def new_line(rush_team, field_position, yardline):
if rush_team == field_position:
return 10.0 + yardline
else:
return 60.0 +(50 - yardline)
 def new_orientation(angle, play_direction):
if play_direction == 'left':
new_angle = 360.0 - angle
if new_angle == 360.0:
new_angle = 0.0
return new_angle
else:
return angle
def euclidean_distance(x1,y1,x2,y2):
x_diff =(x1-x2)**2
y_diff =(y1-y2)**2
return np.sqrt(x_diff + y_diff)
 def back_direction(orientation):
if orientation > 180.0:
return 1
else:
return 0
def update_yardline(df):
new_yardline = df[df['NflId'] == df['NflIdRusher']]
new_yardline['YardLine'] = new_yardline[['PossessionTeam','FieldPosition','YardLine']].apply(lambda x: new_line(x[0],x[1],x[2]), axis=1)
 new_yardline = new_yardline[['GameId','PlayId','YardLine']]
return new_yardline
def update_orientation(df, yardline):
df['X'] = df[['X','PlayDirection']].apply(lambda x: new_X(x[0],x[1]), axis=1)
 df['Orientation'] = df[['Orientation','PlayDirection']].apply(lambda x: new_orientation(x[0],x[1]), axis=1)
 df['Dir'] = df[['Dir','PlayDirection']].apply(lambda x: new_orientation(x[0],x[1]), axis=1)
 df = df.drop('YardLine', axis=1)
 df = pd.merge(df, yardline, on=['GameId','PlayId'], how='inner')
 return df
def back_features(df):
carriers = df[df['NflId'] == df['NflIdRusher']][['GameId','PlayId','NflIdRusher','X','Y','Orientation','Dir','YardLine']]
carriers['back_from_scrimmage'] = carriers['YardLine'] - carriers['X']
carriers['back_oriented_down_field'] = carriers['Orientation'].apply(lambda x: back_direction(x))
carriers['back_moving_down_field'] = carriers['Dir'].apply(lambda x: back_direction(x))
carriers = carriers.rename(columns={'X':'back_X',
'Y':'back_Y'})
 carriers = carriers[['GameId','PlayId','NflIdRusher','back_X','back_Y','back_from_scrimmage','back_oriented_down_field','back_moving_down_field']]
return carriers
def features_relative_to_back(df, carriers):
player_distance = df[['GameId','PlayId','NflId','X','Y']]
player_distance = pd.merge(player_distance, carriers, on=['GameId','PlayId'], how='inner')
 player_distance = player_distance[player_distance['NflId'] != player_distance['NflIdRusher']]
player_distance['dist_to_back'] = player_distance[['X','Y','back_X','back_Y']].apply(lambda x: euclidean_distance(x[0],x[1],x[2],x[3]), axis=1)
 player_distance = player_distance.groupby(['GameId','PlayId','back_from_scrimmage','back_oriented_down_field','back_moving_down_field'])\ 
.agg({'dist_to_back':['min','max','mean','std']})\ 
.reset_index()
player_distance.columns = ['GameId','PlayId','back_from_scrimmage','back_oriented_down_field','back_moving_down_field',
'min_dist','max_dist','mean_dist','std_dist']
return player_distance
def defense_features(df):
rusher = df[df['NflId'] == df['NflIdRusher']][['GameId','PlayId','Team','X','Y']]
rusher.columns = ['GameId','PlayId','RusherTeam','RusherX','RusherY']
defense = pd.merge(df,rusher,on=['GameId','PlayId'],how='inner')
 defense = defense[defense['Team'] != defense['RusherTeam']][['GameId','PlayId','X','Y','RusherX','RusherY']]
defense['def_dist_to_back'] = defense[['X','Y','RusherX','RusherY']].apply(lambda x: euclidean_distance(x[0],x[1],x[2],x[3]), axis=1)
 defense = defense.groupby(['GameId','PlayId'])\ 
.agg({'def_dist_to_back':['min','max','mean','std']})\ 
.reset_index()
defense.columns = ['GameId','PlayId','def_min_dist','def_max_dist','def_mean_dist','def_std_dist']
return defense
def static_features(df):
static_features = df[df['NflId'] == df['NflIdRusher']][['GameId','PlayId','X','Y','S','A','Dis','Orientation','Dir',
'YardLine','Quarter','Down','Distance','DefendersInTheBox']].drop_duplicates()
static_features['DefendersInTheBox'] = static_features['DefendersInTheBox'].fillna(np.mean(static_features['DefendersInTheBox']))
return static_features
def combine_features(relative_to_back, defense, static, deploy=deploy):
df = pd.merge(relative_to_back,defense,on=['GameId','PlayId'],how='inner')
 df = pd.merge(df,static,on=['GameId','PlayId'],how='inner')
 if not deploy:
df = pd.merge(df, outcomes, on=['GameId','PlayId'], how='inner')
 return df
yardline = update_yardline(df)
 df = update_orientation(df, yardline)
 back_feats = back_features(df)
 rel_back = features_relative_to_back(df, back_feats)
 def_feats = defense_features(df)
 static_feats = static_features(df)
 basetable = combine_features(rel_back, def_feats, static_feats, deploy=deploy)
 return basetable<feature_engineering>
ds['pickup_id']=kmeans.predict(ds[['pickup_latitude', 'pickup_longitude']])
 ds['dropoff_id']=kmeans.predict(ds[['dropoff_latitude', 'dropoff_longitude']] )
%time train_basetable = create_features(train, False )<prepare_x_and_y>
test['pickup_id']=kmeans.predict(test[['pickup_latitude', 'pickup_longitude']])
 test['dropoff_id']=kmeans.predict(test[['dropoff_latitude', 'dropoff_longitude']] )
X = train_basetable.copy()
yards = X.Yards
y = np.zeros(( yards.shape[0], 199))
for idx, target in enumerate(list(yards)) :
y[idx][99 + target] = 1
X.drop(['GameId','PlayId','Yards'], axis=1, inplace=True )<normalization>
ds['pickup_datetime']=pd.to_datetime(ds['pickup_datetime'])
 test['pickup_datetime']=pd.to_datetime(test['pickup_datetime'] )
scaler = StandardScaler()
X = scaler.fit_transform(X )<split>
meanvisible=np.mean(weather['Visibility'])
 weather.fillna(value=meanvisible,inplace=True )
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.15, random_state=12345 )<train_model>
weather['Time']=pd.to_datetime(weather['Time'])
 weather['year']=weather['Time'].dt.year
weather['pickup_day']=weather['Time'].dt.day
weather['pickup_month']=weather['Time'].dt.month
weather['pickup_hour']=weather['Time'].dt.hour
weather=weather[weather['year']==2016][['pickup_day','pickup_month','pickup_hour','Temp.','Precip','Visibility']]
class Metric(Callback):
def __init__(self, model, callbacks, data):
super().__init__()
self.model = model
self.callbacks = callbacks
self.data = data
def on_train_begin(self, logs=None):
for callback in self.callbacks:
callback.on_train_begin(logs)
 def on_train_end(self, logs=None):
for callback in self.callbacks:
callback.on_train_end(logs)
 def on_epoch_end(self, batch, logs=None):
X_train, y_train = self.data[0][0], self.data[0][1]
y_pred = self.model.predict(X_train)
 y_true = np.clip(np.cumsum(y_train, axis=1), 0, 1)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1)
 tr_s =(( y_true - y_pred)** 2 ).sum(axis=1 ).sum(axis=0)/(199 * X_train.shape[0])
 tr_s = np.round(tr_s, 6)
 logs['tr_CRPS'] = tr_s
X_valid, y_valid = self.data[1][0], self.data[1][1]
y_pred = self.model.predict(X_valid)
 y_true = np.clip(np.cumsum(y_valid, axis=1), 0, 1)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1)
 val_s =(( y_true - y_pred)** 2 ).sum(axis=1 ).sum(axis=0)/(199 * X_valid.shape[0])
 val_s = np.round(val_s, 6)
 logs['val_CRPS'] = val_s
print('tr CRPS', tr_s, 'val CRPS', val_s)
 for callback in self.callbacks:
callback.on_epoch_end(batch, logs )<choose_model_class>
ds['distance']=ds.apply(lambda x: haversine(( x['pickup_latitude'] ,x['pickup_longitude']),(x['dropoff_latitude'], x['dropoff_longitude'])) ,axis=1)
 test['distance']=test.apply(lambda x: haversine(( x['pickup_latitude'] ,x['pickup_longitude']),(x['dropoff_latitude'], x['dropoff_longitude'])) ,axis=1 )
model = Sequential()
model.add(Dense(512, input_dim=X.shape[1], activation='relu'))
model.add(BatchNormalization())
 model.add(Dropout(0.5))
model.add(Dense(256, activation='relu'))
model.add(BatchNormalization())
 model.add(Dropout(0.5))
model.add(Dense(199, activation='softmax'))<choose_model_class>
model.compile(optimizer='Adam', loss='categorical_crossentropy', metrics=[] )<choose_model_class>
es = EarlyStopping(monitor='val_CRPS',
mode='min',
restore_best_weights=True,
verbose=2,
patience=5)
 es.set_model(model )<create_dataframe>
ds['pickup_weekday']=ds['pickup_datetime'].dt.weekday
ds['pickup_hour']=ds['pickup_datetime'].dt.hour
ds['pickup_month']=ds['pickup_datetime'].dt.month
ds['pickup_day']=ds['pickup_datetime'].dt.day
metric = Metric(model, [es], [(X_train,y_train),(X_val,y_val)] )<train_model>
test['pickup_weekday']=test['pickup_datetime'].dt.weekday
test['pickup_hour']=test['pickup_datetime'].dt.hour
test['pickup_month']=test['pickup_datetime'].dt.month
test['pickup_day']=ds['pickup_datetime'].dt.day
%%time
model.fit(X_train, y_train, callbacks=[metric], epochs=100, batch_size=1024 )<import_modules>
ds['isweekend']= ds.apply(lambda x :(x['pickup_weekday']==6 | x['pickup_weekday']==5),axis=1)
 ds['isweekend']=ds['isweekend'].map({True: 1, False:0})
 ds['store_and_fwd_flag']=ds['store_and_fwd_flag'].map({'N': 1, 'Y':0} )
class GP:
def __init__(self):
self.classes = 20
self.class_names = [ 'class_0',
'class_1',
'class_2',
'class_3',
'class_4',
'class_5',
'class_6',
'class_7',
'class_8',
'class_9',
'class_10',
'class_11',
'class_12',
'class_13',
'class_14',
'class_15',
'class_16',
'class_17',
'class_18',
'class_19',
]
def GrabPredictions(self, data):
oof_preds = np.zeros(( len(data), len(self.class_names)))
 oof_preds[:,0] = self.GP_class_0(data)
 oof_preds[:,1] = self.GP_class_1(data)
 oof_preds[:,2] = self.GP_class_2(data)
 oof_preds[:,3] = self.GP_class_3(data)
 oof_preds[:,4] = self.GP_class_4(data)
 oof_preds[:,5] = self.GP_class_5(data)
 oof_preds[:,6] = self.GP_class_6(data)
 oof_preds[:,7] = self.GP_class_7(data)
 oof_preds[:,8] = self.GP_class_8(data)
 oof_preds[:,9] = self.GP_class_9(data)
 oof_preds[:,10] = self.GP_class_10(data)
 oof_preds[:,11] = self.GP_class_11(data)
 oof_preds[:,12] = self.GP_class_12(data)
 oof_preds[:,13] = self.GP_class_13(data)
 oof_preds[:,14] = self.GP_class_14(data)
 oof_preds[:,15] = self.GP_class_15(data)
 oof_preds[:,16] = self.GP_class_16(data)
 oof_preds[:,17] = self.GP_class_17(data)
 oof_preds[:,18] = self.GP_class_18(data)
 oof_preds[:,19] = self.GP_class_19(data)
 oof_df = pd.DataFrame(np.exp(oof_preds), columns=self.class_names)
 oof_df =oof_df.div(oof_df.sum(axis=1), axis=0)
 return oof_df.values
def GP_class_0(self,data):
return(0.250000*np.tanh(((((((data[:,0])-(((data[:,0])+(data[:,0])))))+(data[:,0])))+(((((data[:,0])* 2.0)) * 2.0)))) +
0.250000*np.tanh(((((((((((((data[:,2])-(data[:,7])))* 2.0)) +(data[:,7])))* 2.0)) +(data[:,0])))+(((((data[:,2])+(data[:,0])))-(data[:,7])))))+
0.250000*np.tanh(((((((((((((((((((data[:,3])-(data[:,7])))-(((data[:,0])/ 2.0)))) +(data[:,0])))-(data[:,7])))+(data[:,2])))+(((data[:,7])+(data[:,2])))))+(data[:,7])))-(data[:,7])))+(data[:,0])))+
0.250000*np.tanh(((((((((data[:,0])-(data[:,7])))-(data[:,14])))+(((data[:,17])-(data[:,14])))))+(((((((data[:,0])-(( 1.0)))) -(data[:,0])))+(data[:,20])))))+
0.250000*np.tanh(((((data[:,18])+(((((((data[:,0])-(data[:,7])))+(data[:,2])))+(data[:,0])))))-(((data[:,7])+(data[:,2])))))+
0.250000*np.tanh(((((((( data[:,8])+(((((((( data[:,13])+(data[:,3])))+(data[:,0])) /2.0)) +(((((((( data[:,0])+(((((data[:,0])-(data[:,0])))/ 2.0)))) +(data[:,17])) /2.0)) +(data[:,11])))))) /2.0)) +(data[:,0])))-(data[:,13])))+
0.250000*np.tanh(((((data[:,0])* 2.0)) +(((((((((data[:,2])+(data[:,2])))* 2.0)) -(((data[:,14])-(((np.tanh(( data[:,2])))* 2.0)))))) -(data[:,7])))))+
0.250000*np.tanh(((((((((((((data[:,17])-(((data[:,17])*(((((data[:,17])*(data[:,17])))* 2.0)))))) +(((((((data[:,17])* 2.0)) * 2.0)) * 2.0)))/2.0)) / 2.0)) +(((data[:,17])-(( 7.76236486434936523)))))/2.0)) +(((((((data[:,17])*(data[:,17])))* 2.0)) * 2.0)))) +
0.250000*np.tanh(((((((((((data[:,17])+(data[:,17])) /2.0)) +(((( data[:,17])+(((( data[:,17])+(data[:,17])) /2.0)))/2.0)))/2.0)) *(data[:,17])))-(data[:,13])))+
0.250000*np.tanh(((((( data[:,19])+(((((((((data[:,19])* 2.0)) +(data[:,19])))-(( 1.07645297050476074)))) +(((data[:,22])+(data[:,22])))))) /2.0)) +(((data[:,22])+(data[:,4]))))))
def GP_class_1(self,data):
return(0.250000*np.tanh(((((((((((((data[:,3])+(((np.tanh(( data[:,2])))-(data[:,14])))))-(( 10.0)))) -(( 4.88989353179931641)))) -(( 13.92175483703613281)))) / 2.0)) -(data[:,6])))+
0.250000*np.tanh(data[:,3])+
0.250000*np.tanh(((data[:,2])+(((((np.tanh(((( data[:,14])* 2.0)))) -(((((((data[:,7])* 2.0)) -(((((data[:,0])-(data[:,14])))-(data[:,7])))))-(data[:,0])))))+(data[:,0])))))+
0.250000*np.tanh(((((((data[:,0])-(( -1.0*(( data[:,14])))))) +(((((((((( data[:,0])-(data[:,7])))-(((( data[:,14])+(data[:,14])) /2.0)))) +(((data[:,2])-(((data[:,0])*(data[:,14])))))) /2.0)) -(data[:,14])))))-(data[:,7])))+
0.250000*np.tanh(((((data[:,0])/ 2.0)) +(data[:,0])))+
0.250000*np.tanh(((((data[:,19])-(data[:,19])))/ 2.0)) +
0.250000*np.tanh(((((np.tanh(((( np.tanh(( data[:,5])))-(((( 1.69341480731964111)) +(((((( np.tanh(( data[:,14])))-(data[:,14])))+(data[:,14])) /2.0)))))))) -(data[:,2])))-(((data[:,14])* 2.0)))) +
0.250000*np.tanh(((((( data[:,22])+(((data[:,0])+(((((((( data[:,22])/ 2.0)) +(( -1.0*(( data[:,13])))))/2.0)) +(data[:,19])))))) /2.0)) -(data[:,13])))+
0.250000*np.tanh(((((((data[:,17])/ 2.0)) *(data[:,17])))*(((data[:,17])+(((data[:,17])*(((((((((data[:,17])+(data[:,17])))*(data[:,17])))*(data[:,17])))+(((np.tanh(( data[:,17])))/ 2.0)))))))))) +
0.250000*np.tanh(((((( data[:,14])*(((data[:,13])+(data[:,3])))))+(((data[:,14])*(((data[:,14])-(( -1.0*(( data[:,3])))))))))/2.0)))
 def GP_class_2(self,data):
return(0.250000*np.tanh(((data[:,0])+(np.tanh(((((((((( data[:,2])+(((data[:,2])/ 2.0)))/2.0)) +(data[:,0])) /2.0)) *(data[:,7])))))))+
0.250000*np.tanh(((( data[:,22])+(data[:,22])) /2.0)) +
0.250000*np.tanh(((((( data[:,14])+(( -1.0*(((((( 4.73206138610839844)) +(((((((((((np.tanh(( data[:,7])))+(data[:,1])) /2.0)) -(np.tanh(((((( data[:,0])-(data[:,20])))-(data[:,14])))))))*(( 7.0)))) +(data[:,14])) /2.0)))/2.0)))))) /2.0)) -(data[:,14])))+
0.250000*np.tanh(((((data[:,1])+(( 4.15603733062744141)))) / 2.0)) +
0.250000*np.tanh(((((((((((((data[:,0])-(data[:,7])))-(data[:,7])))+(((( data[:,0])+(data[:,0])) /2.0)))) * 2.0)) +(data[:,0])))* 2.0)) +
0.250000*np.tanh(((((data[:,11])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((((((((((data[:,2])/ 2.0)) +(((data[:,2])/ 2.0)))/2.0)) / 2.0)) / 2.0)) / 2.0)) +(((( -1.0*(((( data[:,0])/ 2.0)))))*(((data[:,0])/ 2.0)))))/2.0)) +(data[:,0])) /2.0)) +(np.tanh(( data[:,0])))) /2.0)) / 2.0)) +
0.250000*np.tanh(((((data[:,0])+(((data[:,0])+(((((((data[:,14])*(data[:,14])))+(data[:,14])))-(data[:,0])))))))-(data[:,14])))+
0.250000*np.tanh(((((( np.tanh(( np.tanh(((0.0)))))) *(data[:,15])))+(data[:,20])) /2.0)) +
0.250000*np.tanh(((data[:,14])*(((( data[:,13])+(((( data[:,13])+(((( data[:,14])+(((((( data[:,14])+(((( data[:,14])+(((data[:,13])-(((( -1.0*(((((data[:,14])+(data[:,14])) /2.0)))))* 2.0)))))/2.0)))) +(data[:,14])) /2.0)))/2.0)))/2.0)))/2.0)))))
 def GP_class_3(self,data):
return(0.250000*np.tanh(((((((((8.0)) +(((((((5.33416414260864258)) +(( 9.0)))/2.0)) +(((( 8.0)) * 2.0)))))) * 2.0)) +(( 5.33416414260864258)))/2.0)) +
0.250000*np.tanh(((( 9.48088836669921875)) +(((((10.56953334808349609)) +(((( 4.48959350585937500)) +(np.tanh(((((3.0)) +(( 9.0)))))))))/2.0)))) +
0.250000*np.tanh(((((((((( data[:,22])/ 2.0)) +(data[:,22])) /2.0)) * 2.0)) / 2.0)) +
0.250000*np.tanh(( 10.44883441925048828)) +
0.250000*np.tanh(((((data[:,0])+(((data[:,0])+(( -1.0*(( data[:,9])))))))) +(((((data[:,0])-(data[:,7])))-(data[:,9])))))+
0.250000*np.tanh(((np.tanh(( data[:,6])))-(data[:,21])))+
0.250000*np.tanh(((data[:,0])-(((((data[:,14])+(((((data[:,14])+(((data[:,14])+(((data[:,14])-(data[:,0])))))))-(((((data[:,0])-(data[:,14])))+(data[:,14])))))))-(((((data[:,14])*(data[:,14])))+(data[:,18])))))))+
0.250000*np.tanh(((data[:,14])*(((( data[:,13])+(data[:,14])) /2.0)))) +
0.250000*np.tanh(((((( data[:,8])*(((data[:,8])/ 2.0)))) +(((((( data[:,9])*(data[:,8])))+(data[:,8])) /2.0)))/2.0)) +
0.250000*np.tanh(((( data[:,2])+(((((((data[:,2])+(data[:,20])) /2.0)) +(((((((( data[:,2])+(data[:,8])) /2.0)) / 2.0)) -(data[:,8])))) /2.0)))/2.0)))
 def GP_class_4(self,data):
return(0.250000*np.tanh(((( 12.98819637298583984)) / 2.0)) +
0.250000*np.tanh(((((4.75780344009399414)) +(((((((8.66014671325683594)) +(( 4.18107128143310547)))/2.0)) *(( 8.97841739654541016)))))/2.0)) +
0.250000*np.tanh(((( 9.0)) / 2.0)) +
0.250000*np.tanh(((((((((((10.0)) +(np.tanh(((((( 6.0)) +(((( 13.80149555206298828)) +(( 7.0)))))/2.0)))))) +(( 10.0)))) +(((((((data[:,0])+(( 8.0)))) / 2.0)) / 2.0)))/2.0)) +(((( -1.0*(((( data[:,2])*(data[:,9])))))) * 2.0)))) +
0.250000*np.tanh(((((data[:,0])+(((((((data[:,22])+(data[:,22])) /2.0)) +(data[:,22])) /2.0)))) +(((((( data[:,22])+(((((( data[:,22])* 2.0)) +(data[:,22])) /2.0)))) +(data[:,18])) /2.0)))) +
0.250000*np.tanh(((((((((((((np.tanh(( data[:,18])))+(((( data[:,1])+(data[:,18])) /2.0)))/2.0)) *(data[:,18])))*(data[:,18])))+(((data[:,18])*(data[:,18])))) /2.0)) -(((((((np.tanh(( data[:,18])))+(((data[:,18])*(data[:,18])))) /2.0)) +(data[:,17])) /2.0)))) +
0.250000*np.tanh(((np.tanh(((((((np.tanh(( data[:,6])))-(((np.tanh(( data[:,6])))-(data[:,6])))))+(np.tanh(( data[:,6])))) /2.0)))) -(((( data[:,10])+(((( data[:,2])+(((np.tanh(( data[:,6])))-(((np.tanh(( np.tanh(( data[:,6])))))-(data[:,10])))))) /2.0)))/2.0)))) +
0.250000*np.tanh(((((((((((( data[:,10])+(data[:,4])))+(((data[:,10])+(((data[:,0])*(data[:,10])))))) /2.0)) +(((data[:,4])*(((data[:,10])+(data[:,4])))))) /2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((( data[:,11])+(((((data[:,18])/ 2.0)) *(((data[:,11])*(data[:,18])))))) /2.0)) *(((data[:,18])*(((((((((data[:,18])*(((((((data[:,11])/ 2.0)) / 2.0)) *(data[:,18])))))/ 2.0)) / 2.0)) *(( -1.0*(( data[:,21])))))))))) +
0.250000*np.tanh(((( -1.0*(((((((((((( data[:,2])-(data[:,2])))*(np.tanh(( data[:,2])))))+(np.tanh(((( data[:,14])* 2.0)))))/2.0)) +(data[:,2])) /2.0)))))-(data[:,2]))))
def GP_class_5(self,data):
return(0.250000*np.tanh(((((((((((3.46574378013610840)) +(((( np.tanh(((3.46574378013610840)))) +(( 8.46705245971679688)))/2.0)))/2.0)) * 2.0)) +(((( 3.46574378013610840)) +(( 4.0)))))) +(((( 4.0)) * 2.0)))) +
0.250000*np.tanh(((( 10.55856513977050781)) / 2.0)) +
0.250000*np.tanh(((( 3.76695251464843750)) / 2.0)) +
0.250000*np.tanh(((((( 6.0)) / 2.0)) +(((( 8.57984828948974609)) * 2.0)))) +
0.250000*np.tanh(((((((((((( 3.42168045043945312)) +(data[:,7])))+(np.tanh(( data[:,7])))))+(np.tanh(( np.tanh(( np.tanh(((3.42168045043945312)))))))))/2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((((((((data[:,6])-(data[:,9])))+(data[:,7])) /2.0)) * 2.0)) +(((((( data[:,7])+(data[:,9])) /2.0)) -(data[:,9])))) /2.0)) +
0.250000*np.tanh(((((((((((data[:,22])+(data[:,22])))+(data[:,11])) /2.0)) +(data[:,22])) /2.0)) / 2.0)) +
0.250000*np.tanh(((((((((( 0.76044219732284546)) / 2.0)) +(( 0.76044219732284546)))/2.0)) +(np.tanh(( np.tanh(((((((( 0.76043862104415894)) / 2.0)) +(( 1.0)))/2.0)))))))/2.0)) +
0.250000*np.tanh(((((((data[:,12])+(np.tanh(( data[:,9])))) /2.0)) +(((((((((((data[:,12])+(((((0.0)) +(np.tanh(((((((( data[:,7])+(data[:,6])) /2.0)) +(data[:,7])) /2.0)))))/2.0)))/2.0)) / 2.0)) / 2.0)) +(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((data[:,20])/ 2.0)) / 2.0)) *(((np.tanh(( data[:,20])))*(((data[:,20])/ 2.0)))))) *(((((( data[:,20])/ 2.0)) +(((data[:,20])/ 2.0)))/2.0)))))
 def GP_class_6(self,data):
return(0.250000*np.tanh(((((((11.68076229095458984)) +(((((11.68075847625732422)) +(((( 11.47270107269287109)) +(((((11.47269725799560547)) +(( 11.68076229095458984)))/2.0)))))/2.0)))/2.0)) +(((( 4.0)) * 2.0)))) +
0.250000*np.tanh(((( 8.0)) +(((( 10.0)) +(( 6.59042119979858398)))))) +
0.250000*np.tanh(((((((((((13.33760547637939453)) +(((((3.86388397216796875)) +(((((((8.18321037292480469)) +(data[:,4])))+(((((((5.95386552810668945)) +(( 12.93883609771728516)))) +(((((10.73907089233398438)) +(( 4.0)))/2.0)))/2.0)))/2.0)))/2.0)))/2.0)) +(np.tanh(((3.0)))))) -(( 2.0)))) +(((((10.61559963226318359)) +(data[:,1])) /2.0)))) +
0.250000*np.tanh(((np.tanh(((((((((((7.13513946533203125)) +(( 12.48778533935546875)))/2.0)) +(((((((7.13513565063476562)) -(( 8.12031841278076172)))) +(((((((((7.13513565063476562)) +(((( 10.69830417633056641)) +(( 10.69830799102783203)))))) +(( 10.69830799102783203)))) +(( 7.83078956604003906)))/2.0)))/2.0)))/2.0)) * 2.0)))) +(( 3.0)))) +
0.250000*np.tanh(((((((((((data[:,7])-(data[:,0])))* 2.0)) -(data[:,7])))+(data[:,7])))+(data[:,0])))+
0.250000*np.tanh(((((data[:,7])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((( 1.0)) +(((((((data[:,2])+(((((((1.0)) *(data[:,2])))+(data[:,14])) /2.0)))/2.0)) +(( 1.0)))/2.0)))) +(((( 1.0)) -(((data[:,2])*(data[:,14])))))) /2.0)) -(data[:,2])))* 2.0)) +(data[:,14])) /2.0)) +(data[:,14])))+
0.250000*np.tanh(((np.tanh(( np.tanh(((((((data[:,19])*(( 0.0)))) +(( 0.0)))/2.0)))))) / 2.0)) +
0.250000*np.tanh(((((((( 0.0)) / 2.0)) / 2.0)) *(((((((((data[:,15])/ 2.0)) *(( 0.0)))) / 2.0)) *(((( -1.0*(((0.0)))))/ 2.0)))))) +
0.250000*np.tanh(((((data[:,15])*(((((((((((((np.tanh(((((0.09032609313726425)) / 2.0)))) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)))) / 2.0)))
 def GP_class_7(self,data):
return(0.250000*np.tanh(( 10.27210903167724609)) +
0.250000*np.tanh(((((((((( 10.0)) +(((((((((8.26972770690917969)) +(( 11.06334972381591797)))/2.0)) * 2.0)) / 2.0)))) +(((((( 5.0)) +(((( 5.0)) +(( 7.92727756500244141)))))) * 2.0)))) *(( 7.92728137969970703)))) +(( 10.0)))) +
0.250000*np.tanh(( 8.42519950866699219)) +
0.250000*np.tanh(((((((data[:,14])+(data[:,14])))+(((((( 1.59392631053924561)) +(data[:,14])))+(data[:,14])))))+(np.tanh(((((( data[:,14])+(((((((3.0)) +(((data[:,14])* 2.0)))/2.0)) +(( 1.59391915798187256)))))) +(( 1.59392631053924561)))))))) +
0.250000*np.tanh(((( data[:,7])+(((data[:,0])+(((((((data[:,7])+(data[:,4])) /2.0)) +(((data[:,7])* 2.0)))/2.0)))))/2.0)) +
0.250000*np.tanh(((((((((((((( data[:,9])-(((data[:,0])-(data[:,0])))))-(((data[:,0])/ 2.0)))) / 2.0)) -(((data[:,21])-(data[:,7])))))+(data[:,21])) /2.0)) -(data[:,0])))+
0.250000*np.tanh(((((((((( 2.0)) +(((((( data[:,21])+(((( data[:,13])+(((((((((((data[:,13])* 2.0)) +(data[:,21])) /2.0)) +(data[:,13])) /2.0)) * 2.0)))/2.0)))/2.0)) -(np.tanh(((((0.0)) -(data[:,21])))))))))+(( 1.0)))/2.0)) +(data[:,13])) /2.0)) +
0.250000*np.tanh(((((data[:,14])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((( -1.0*(((((((data[:,21])/ 2.0)) +(data[:,8])) /2.0)))))/ 2.0)) / 2.0)) / 2.0)) +(data[:,9])) /2.0)) / 2.0)) +(((((((((((( data[:,7])/ 2.0)) / 2.0)) / 2.0)) / 2.0)) +(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((np.tanh(((1.0)))) / 2.0)) / 2.0)) / 2.0)))
 def GP_class_8(self,data):
return(0.250000*np.tanh(((((((data[:,0])+(((((6.71804094314575195)) +(data[:,15])) /2.0)))) +(((((( 11.56385326385498047)) * 2.0)) *(((( 10.48986148834228516)) +(( 11.56385326385498047)))))))) / 2.0)) +
0.250000*np.tanh(((((((((( data[:,14])/ 2.0)) +(( 2.83755254745483398)))/2.0)) +(((((( data[:,12])+(data[:,14])) /2.0)) +(data[:,14])))))+(((( data[:,9])+(((data[:,12])+(data[:,14])))) /2.0)))) +
0.250000*np.tanh(((((((((data[:,6])+(((((((3.50821948051452637)) +(((( data[:,21])+(( 11.92932796478271484)))/2.0)))) +(( 1.0)))/2.0)))) +(data[:,10])) /2.0)) +(data[:,21])) /2.0)) +
0.250000*np.tanh(((data[:,14])+(np.tanh(( np.tanh(((-1.0*(((( data[:,22])-(data[:,13])))))))))))) +
0.250000*np.tanh(((((1.0)) +(((( data[:,7])+(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((data[:,21])/ 2.0)) / 2.0)) *(((((((np.tanh(((( np.tanh(( data[:,13])))/ 2.0)))) / 2.0)) +(((((((np.tanh(((((data[:,21])+(data[:,21])) /2.0)))) / 2.0)) -(data[:,12])))/ 2.0)))) / 2.0)))) -(data[:,12])))+
0.250000*np.tanh(((( data[:,7])+(np.tanh(((((data[:,12])+(((data[:,7])*(((( data[:,13])+(data[:,13])) /2.0)))))/2.0)))))/2.0)) +
0.250000*np.tanh(((((((data[:,13])/ 2.0)) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((( np.tanh(( data[:,9])))+(data[:,13])) /2.0)) +(((((((( data[:,21])/ 2.0)) * 2.0)) +(((( 3.94983267784118652)) / 2.0)))/2.0)))/2.0)) +(((( np.tanh(((3.94983267784118652)))) +(data[:,9])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((((((((data[:,14])*(((((((((data[:,19])/ 2.0)) *(np.tanh(((( data[:,2])/ 2.0)))))) / 2.0)) / 2.0)))) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)) *(((((data[:,11])/ 2.0)) / 2.0)))))
 def GP_class_9(self,data):
return(0.250000*np.tanh(((((((data[:,14])* 2.0)) / 2.0)) +(((((data[:,14])+(np.tanh(((( data[:,14])* 2.0)))))) +(data[:,14])))))+
0.250000*np.tanh(((data[:,9])-(((((-1.0*(( data[:,11])))) +(data[:,9])) /2.0)))) +
0.250000*np.tanh(((data[:,21])* 2.0)) +
0.250000*np.tanh(((((( data[:,14])+(data[:,14])) /2.0)) +(((( data[:,13])+(((( np.tanh(((( data[:,9])+(( 6.0)))))) +(data[:,9])) /2.0)))/2.0)))) +
0.250000*np.tanh(np.tanh(((1.0)))) +
0.250000*np.tanh(((np.tanh(( np.tanh(((((np.tanh(((( data[:,20])*(((((((np.tanh(((( data[:,20])/ 2.0)))) +(data[:,12])) /2.0)) +(((( data[:,15])+(((( data[:,17])+(data[:,9])) /2.0)))/2.0)))/2.0)))))) +(data[:,9])) /2.0)))))) / 2.0)) +
0.250000*np.tanh(((((data[:,2])-(data[:,11])))/ 2.0)) +
0.250000*np.tanh(((((((( data[:,13])/ 2.0)) +(((data[:,7])+(data[:,7])))) /2.0)) -(((((data[:,22])+(((((data[:,14])*(((((data[:,7])*(((data[:,13])-(((( data[:,7])+(((((data[:,13])/ 2.0)) +(data[:,7])))) /2.0)))))) / 2.0)))) * 2.0)))) / 2.0)))) +
0.250000*np.tanh(((((((((((((((data[:,1])/ 2.0)) +(( 1.0)))/2.0)) +(( 1.0)))/2.0)) +(((((((((( 1.0)) / 2.0)) +(np.tanh(((1.0)))))/2.0)) +(np.tanh(((((( 1.0)) +(( 1.0)))/2.0)))))/2.0)))/2.0)) +(((( data[:,20])+(( 1.0)))/2.0)))/2.0)) +
0.250000*np.tanh(((data[:,1])*(((( data[:,14])+(np.tanh(((((0.0)) / 2.0)))))/2.0)))))
 def GP_class_10(self,data):
return(0.250000*np.tanh(((((((((( data[:,2])+(((data[:,9])*(np.tanh(( data[:,14])))))) /2.0)) +(((((( data[:,14])+(data[:,20])) /2.0)) +(data[:,0])))) /2.0)) +(data[:,14])) /2.0)) +
0.250000*np.tanh(((((( data[:,9])+(( -1.0*(((((((( 2.04309988021850586)) +(((data[:,11])+(((np.tanh(( data[:,0])))/ 2.0)))))/2.0)) * 2.0)))))) /2.0)) +(data[:,2])))+
0.250000*np.tanh(data[:,21])+
0.250000*np.tanh(((((((( data[:,14])+(np.tanh(((( data[:,6])/ 2.0)))))/2.0)) +(data[:,14])))+(((((data[:,14])* 2.0)) +(((( data[:,13])+(data[:,14])) /2.0)))))) +
0.250000*np.tanh(data[:,9])+
0.250000*np.tanh(((((((data[:,15])* 2.0)) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((((( 2.72836518287658691)) *(((( 1.0)) / 2.0)))) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((np.tanh(((( data[:,7])+(np.tanh(((((((((((0.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)))))))) / 2.0)) / 2.0)) +
0.250000*np.tanh(np.tanh(((( np.tanh(((11.43236827850341797)))) / 2.0)))) +
0.250000*np.tanh(np.tanh(((( data[:,7])/ 2.0)))))
 def GP_class_11(self,data):
return(0.250000*np.tanh(( -1.0*(((((((((((((( data[:,5])-(((data[:,9])-(((( -1.0*(((11.40053558349609375)))))/ 2.0)))))) +(((( 11.40053558349609375)) +(((( 11.40053558349609375)) * 2.0)))))) / 2.0)) -(data[:,7])))-(( -1.0*(((11.40053939819335938)))))))* 2.0)))))+
0.250000*np.tanh(((((data[:,14])* 2.0)) +(data[:,14])))+
0.250000*np.tanh(((data[:,2])+(((((data[:,5])+(data[:,3])))+(((( data[:,2])+(((data[:,3])* 2.0)))/2.0)))))) +
0.250000*np.tanh(((((((((((data[:,21])+(data[:,21])))+(( -1.0*(((((np.tanh(( np.tanh(((( data[:,14])/ 2.0)))))) +(data[:,21])) /2.0)))))) /2.0)) * 2.0)) +(((( data[:,14])+(data[:,3])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((data[:,0])+(((( data[:,9])+(((( data[:,9])+(((((((((((((((data[:,9])/ 2.0)) -(data[:,10])))+(data[:,5])) /2.0)) -(data[:,9])))+(data[:,9])) /2.0)) / 2.0)))/2.0)))/2.0)))/2.0)) +(data[:,9])) /2.0)) +
0.250000*np.tanh(((((((( data[:,13])+(((( data[:,13])+(data[:,13])) /2.0)))) +(data[:,1])) /2.0)) / 2.0)) +
0.250000*np.tanh(data[:,14])+
0.250000*np.tanh(((((data[:,2])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((( data[:,9])+(data[:,9])) /2.0)) +
0.250000*np.tanh(data[:,2]))
def GP_class_12(self,data):
return(0.250000*np.tanh(((((((( -1.0*(( data[:,18])))) -(np.tanh(( data[:,9])))))+(( 8.0)))) -(( 14.74865913391113281)))) +
0.250000*np.tanh(((((( data[:,21])+(np.tanh(( data[:,9])))))+(((((((( data[:,5])/ 2.0)) * 2.0)) +(data[:,5])) /2.0)))/2.0)) +
0.250000*np.tanh(((((data[:,14])+(data[:,14])))+(((data[:,14])* 2.0)))) +
0.250000*np.tanh(((data[:,2])+(((((((data[:,14])+(((( np.tanh(( data[:,10])))+(data[:,17])) /2.0)))/2.0)) +(data[:,21])) /2.0)))) +
0.250000*np.tanh(((( data[:,9])+(((((((((((( data[:,9])+(((((( data[:,9])/ 2.0)) +(((data[:,9])* 2.0)))/2.0)))/2.0)) +(( -1.0*(( data[:,21])))))/2.0)) *(data[:,9])))+(((((np.tanh(((( data[:,21])/ 2.0)))) / 2.0)) / 2.0)))/2.0)))/2.0)) +
0.250000*np.tanh(((((0.0)) +(data[:,13])) /2.0)) +
0.250000*np.tanh(((((((( data[:,2])/ 2.0)) * 2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((( data[:,14])* 2.0)) +(np.tanh(( data[:,14])))) /2.0)) +
0.250000*np.tanh(np.tanh(((((((((( -1.0*(((( np.tanh(( data[:,9])))/ 2.0)))))/ 2.0)) / 2.0)) +(((data[:,3])*(data[:,13])))) /2.0)))) +
0.250000*np.tanh(( -1.0*(((((((( -1.0*(((((((-1.0*(( data[:,18])))) -(((( 0.0)) / 2.0)))) / 2.0)))))+(np.tanh(((((-1.0*(((-1.0*(( data[:,22])))))))/ 2.0)))))/2.0)) / 2.0))))))
def GP_class_13(self,data):
return(0.250000*np.tanh(((((np.tanh(( np.tanh(( data[:,2])))))-(( 10.0)))) -(np.tanh(((((( data[:,7])-(((((( 6.0)) -(( 4.87243366241455078)))) -(( 9.0)))))) -(( 14.80352973937988281)))))))) +
0.250000*np.tanh(((np.tanh(((((( 3.0)) +(data[:,1])) /2.0)))) -(( 7.0)))) +
0.250000*np.tanh(((((np.tanh(( np.tanh(( np.tanh(( data[:,6])))))))* 2.0)) -(( 6.10337877273559570)))) +
0.250000*np.tanh(((((((data[:,9])+(data[:,14])))+(data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((((np.tanh(((((-1.0*(((((((data[:,2])+(( 10.0)))/2.0)) / 2.0)))))-(( 13.28130435943603516)))))) +(( 10.0)))) -(( 13.28130435943603516)))) +(( -1.0*(( data[:,5])))))) +
0.250000*np.tanh(((((((((((data[:,20])+(((((((((data[:,20])* 2.0)) * 2.0)) * 2.0)) +(data[:,13])))) /2.0)) +(((data[:,9])+(((data[:,9])+(((data[:,6])+(data[:,9])))))))) /2.0)) +(data[:,20])))+(data[:,15])))+
0.250000*np.tanh(((((((((data[:,14])/ 2.0)) +(((( data[:,9])+(((data[:,15])+(((data[:,5])+(((((( data[:,9])+(((data[:,5])+(data[:,14])))))+(data[:,9])) /2.0)))))))/2.0)))) * 2.0)) +(data[:,14])))+
0.250000*np.tanh(((( data[:,13])+(data[:,7])) /2.0)) +
0.250000*np.tanh(((data[:,9])+(((( data[:,3])+(((( data[:,21])+(data[:,3])) /2.0)))/2.0)))) +
0.250000*np.tanh(((( data[:,2])+(((((((((((((((data[:,20])+(data[:,1])))+(((data[:,2])+(data[:,14])))))+(data[:,2])))+(np.tanh(( data[:,2])))) /2.0)) +(((data[:,14])+(data[:,2])))))+(data[:,14])) /2.0)))/2.0)))
 def GP_class_14(self,data):
return(0.250000*np.tanh(((((((((((( 5.54024744033813477)) -(((((( 9.0)) * 2.0)) * 2.0)))) -(data[:,0])))-(((( 7.0)) +(( 4.74105215072631836)))))) -(((((7.0)) +(((data[:,5])* 2.0)))/2.0)))) -(( 9.0)))) +
0.250000*np.tanh(((((((((9.0)) -(( 14.27298927307128906)))) -(data[:,0])))+(np.tanh(((((12.77708148956298828)) -(( 14.80560111999511719)))))))/2.0)) +
0.250000*np.tanh(((((((0.0)) +(( -1.0*(((( data[:,22])+(((((((((13.30077362060546875)) -(np.tanh(( data[:,4])))))+(((data[:,22])/ 2.0)))/2.0)) / 2.0)))))))) /2.0)) -(((np.tanh(((( data[:,7])-(data[:,7])))))/ 2.0)))) +
0.250000*np.tanh(((((((data[:,6])+(data[:,14])) /2.0)) +(((np.tanh(((((( data[:,14])+(data[:,14])))+(((data[:,6])-(((data[:,5])+(((np.tanh(( data[:,21])))+(((( data[:,14])+(((( data[:,14])+(data[:,14])) /2.0)))/2.0)))))))))))) +(data[:,5])))) /2.0)) +
0.250000*np.tanh(((((((((((((((((( data[:,2])+(data[:,16])))+(((((( data[:,2])/ 2.0)) +(data[:,9])) /2.0)))/2.0)) +(np.tanh(( data[:,10])))) /2.0)) +(data[:,9])))+(data[:,9])) /2.0)) +(data[:,21])))+(data[:,3])))+
0.250000*np.tanh(((( data[:,13])+(((((((((((data[:,3])/ 2.0)) / 2.0)) / 2.0)) *(data[:,3])))/ 2.0)))/2.0)) +
0.250000*np.tanh(((data[:,14])+(((((((data[:,14])/ 2.0)) +(data[:,14])))* 2.0)))) +
0.250000*np.tanh(data[:,9])+
0.250000*np.tanh(((data[:,1])/ 2.0)) +
0.250000*np.tanh(((((( data[:,2])+(((((( data[:,13])+(data[:,14])))+(data[:,13])) /2.0)))) +(np.tanh(( data[:,2])))) /2.0)))
 def GP_class_15(self,data):
return(0.250000*np.tanh(((((((( 4.0)) +(((( 8.0)) / 2.0)))) -(( 9.56193733215332031)))) -(((((np.tanh(((13.93556308746337891)))) -(data[:,18])))+(( 13.93556308746337891)))))) +
0.250000*np.tanh(((data[:,4])-(((( 12.76094818115234375)) -(data[:,8])))))+
0.250000*np.tanh(((( -1.0*(((12.35446166992187500)))))-(((((12.35446166992187500)) +(((((( 12.35446166992187500)) -(( -1.0*(((0.0)))))))-(data[:,0])))) /2.0)))) +
0.250000*np.tanh(((data[:,21])-(( 14.46367263793945312)))) +
0.250000*np.tanh(((((data[:,2])+(((( data[:,9])+(( -1.0*(((-1.0*(((-1.0*(((( data[:,7])*(((data[:,21])* 2.0)))))))))))))) /2.0)))) +(data[:,9])))+
0.250000*np.tanh(((((((((((data[:,7])+(data[:,3])) /2.0)) +(data[:,20])) /2.0)) -(((( 2.33354020118713379)) / 2.0)))) -(((( 2.0)) +(( 8.78930377960205078)))))) +
0.250000*np.tanh(((((((data[:,14])+(((((((data[:,14])+(((data[:,15])+(data[:,14])))))+(((data[:,15])+(data[:,14])))))+(((data[:,14])/ 2.0)))))) +(data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((((((data[:,13])+(data[:,13])))+(((data[:,13])+(data[:,12])))))+(data[:,9])))+(((((( data[:,9])+(((data[:,13])+(((( data[:,9])+(((((data[:,13])* 2.0)) / 2.0)))/2.0)))))/2.0)) * 2.0)))) +
0.250000*np.tanh(((( data[:,9])+(((((( data[:,9])+(data[:,9])) /2.0)) / 2.0)))/2.0)) +
0.250000*np.tanh(((((( data[:,14])+(data[:,8])))+(data[:,14])) /2.0)))
 def GP_class_16(self,data):
return(0.250000*np.tanh(((((((((((((9.37592792510986328)) -(( 13.36316204071044922)))) +(( 11.89122962951660156)))/2.0)) -(((( 9.0)) -(((((((data[:,13])/ 2.0)) / 2.0)) +(((( -1.0*(((( data[:,4])/ 2.0)))))* 2.0)))))))) -(( 12.24639320373535156)))) -(( 11.89122581481933594)))) +
0.250000*np.tanh(((((np.tanh(((4.51821422576904297)))) -(( 13.23712635040283203)))) -(((((( 13.23712635040283203)) +(((data[:,22])-(((( 11.40539550781250000)) -(((((9.0)) +(((((((( data[:,7])+(((data[:,17])/ 2.0)))/2.0)) * 2.0)) / 2.0)))/2.0)))))))) -(data[:,5])))))+
0.250000*np.tanh(((data[:,14])-(((( 4.0)) +(((((13.41770648956298828)) +(( 12.42538261413574219)))/2.0)))))) +
0.250000*np.tanh(((( 5.0)) -(( 9.27778816223144531)))) +
0.250000*np.tanh(((((data[:,16])-(((((((data[:,1])-(((np.tanh(((((((( 9.29507255554199219)) -(((((((14.34461498260498047)) * 2.0)) +(((((7.0)) +(( 9.10683441162109375)))/2.0)))/2.0)))) +(( 4.21145153045654297)))/2.0)))) * 2.0)))) -(( 9.10683441162109375)))) * 2.0)))) -(((( 14.34461498260498047)) * 2.0)))) +
0.250000*np.tanh(((((((((( data[:,17])/ 2.0)) +(((data[:,13])+(data[:,9])))) /2.0)) +(((data[:,17])+(data[:,9])))))+(data[:,0])))+
0.250000*np.tanh(((data[:,13])+(((data[:,14])-(data[:,21])))))+
0.250000*np.tanh(((((( data[:,14])+(data[:,5])) /2.0)) +(((((((data[:,9])/ 2.0)) +(data[:,14])))/ 2.0)))) +
0.250000*np.tanh(((((( data[:,17])+(data[:,9])))+(((((data[:,17])/ 2.0)) +(((((((((( data[:,9])+(data[:,9])))-(( 3.0)))) +(data[:,7])))+(data[:,9])) /2.0)))))/2.0)) +
0.250000*np.tanh(np.tanh(((((((((((((((data[:,2])+(((((((((((data[:,22])+(data[:,21])) /2.0)) +(data[:,2])) /2.0)) * 2.0)) +(((((( data[:,21])* 2.0)) +(data[:,21])) /2.0)))))) +(data[:,2])) /2.0)) +(data[:,17])) /2.0)) +(np.tanh(( data[:,8])))) /2.0)) +(data[:,2]))))))
def GP_class_17(self,data):
return(0.250000*np.tanh(((((data[:,14])-(((( data[:,5])+(((((14.43326377868652344)) +(( 6.0)))/2.0)))/2.0)))) -(((((((10.0)) +(( 14.84462165832519531)))/2.0)) -(((( 7.0)) +(data[:,13])))))))+
0.250000*np.tanh(((((((((( data[:,14])+(((((((((data[:,11])-(( 9.71331787109375000)))) / 2.0)) +(( 9.0)))) -(( 3.0)))))/2.0)) -(( 10.0)))) -(((( 10.0)) +(((( 9.0)) -(((((( 10.0)) -(( 9.0)))) / 2.0)))))))) -(( 10.0)))) +
0.250000*np.tanh(((((((((( 8.0)) -(( 12.78277492523193359)))) -(data[:,10])))-(np.tanh(((((((7.0)) -(( 14.95321178436279297)))) -(( 8.0)))))))) -(( 14.95321178436279297)))) +
0.250000*np.tanh(((( 7.45682907104492188)) -(( 14.98023796081542969)))) +
0.250000*np.tanh(((((((((((7.0)) +(((((np.tanh(((((((( 8.0)) *(data[:,8])))+(data[:,11])) /2.0)))) / 2.0)) -(( 8.0)))))/2.0)) -(data[:,20])))-(((( 8.0)) * 2.0)))) +(( 8.0)))) +
0.250000*np.tanh(((data[:,8])+(((data[:,4])+(((np.tanh(( data[:,4])))+(((data[:,13])+(data[:,13])))))))))+
0.250000*np.tanh(data[:,14])+
0.250000*np.tanh(((((((((((data[:,14])+(np.tanh(((( data[:,3])*(data[:,13])))))))+(data[:,14])))+(data[:,0])))+(data[:,8])))/ 2.0)) +
0.250000*np.tanh(((((( data[:,9])+(np.tanh(((((((data[:,19])*(((((((data[:,1])+(((((((data[:,21])+(data[:,9])) /2.0)) +(data[:,6])) /2.0)))/2.0)) +(data[:,17])) /2.0)))) +(((data[:,15])/ 2.0)))/2.0)))))/2.0)) * 2.0)) +
0.250000*np.tanh(((data[:,1])+(((((data[:,3])+(data[:,15])))+(np.tanh(((((data[:,20])+(((data[:,1])* 2.0)))/2.0)))))))))
 def GP_class_18(self,data):
return(0.250000*np.tanh(((((((((( 12.59485149383544922)) -(( 12.59485149383544922)))) -(( 12.59485149383544922)))) -(((( 11.47756862640380859)) / 2.0)))) -(( 12.59485149383544922)))) +
0.250000*np.tanh(((((( -1.0*(((11.26121807098388672)))))-(((((((((11.33140659332275391)) -(( -1.0*(((9.76293182373046875)))))))-(((((11.33140659332275391)) +(( 8.0)))/2.0)))) +(( 9.76293182373046875)))/2.0)))) -(data[:,11])))+
0.250000*np.tanh(((((((((((3.40250444412231445)) -(np.tanh(((14.86789989471435547)))))) -(( 14.86789989471435547)))) +(((((( data[:,5])+(( -1.0*(((((14.86789989471435547)) * 2.0)))))) /2.0)) -(( 14.86789989471435547)))))/2.0)) -(((((14.86789989471435547)) +(((((7.0)) +(( -1.0*(( data[:,16])))))/2.0)))/2.0)))) +
0.250000*np.tanh(((data[:,18])-(( 11.84332561492919922)))) +
0.250000*np.tanh(((((np.tanh(((((8.96548557281494141)) *(data[:,12])))))-(( -1.0*(((( data[:,2])*(((((data[:,4])-(( -1.0*(( data[:,9])))))) -(( 9.0)))))))))))-(( 8.96548557281494141)))) +
0.250000*np.tanh(((((((10.0)) -(data[:,12])))+(((((((((data[:,13])-(( 12.43707370758056641)))) -(((( 12.43707370758056641)) -(((data[:,12])/ 2.0)))))) -(((( 12.43707370758056641)) -(((( data[:,13])+(( 12.43707370758056641)))/2.0)))))) -(( 12.43707370758056641)))))/2.0)) +
0.250000*np.tanh(((((((np.tanh(((( np.tanh(( data[:,14])))+(data[:,13])))))* 2.0)) +(data[:,14])))+(data[:,13])))+
0.250000*np.tanh(((np.tanh(( data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((data[:,9])+(((((data[:,13])+(data[:,4])))+(data[:,13])))))/ 2.0)) +
0.250000*np.tanh(((data[:,15])-(((( data[:,3])+(( 5.0)))/2.0)))))
 def GP_class_19(self,data):
return(0.250000*np.tanh(((((( data[:,13])+(data[:,13])) /2.0)) +(((((( data[:,8])+(((( data[:,14])+(data[:,14])) /2.0)))/2.0)) * 2.0)))) +
0.250000*np.tanh(((( data[:,3])+(((data[:,8])+(np.tanh(((((((-1.0*(((((( 9.05535793304443359)) +(((( data[:,14])+(((((((data[:,1])-(((data[:,12])* 2.0)))) *(( -1.0*(( data[:,17])))))) / 2.0)))/2.0)))/2.0)))))+(data[:,2])))* 2.0)))))))/2.0)) +
0.250000*np.tanh(((((((((data[:,3])+(((((data[:,14])+(data[:,14])))* 2.0)))) +(((( data[:,14])+(np.tanh(((( data[:,14])+(np.tanh(( data[:,14])))))))) /2.0)))) * 2.0)) +(((( data[:,14])+(data[:,2])) /2.0)))) +
0.250000*np.tanh(((((data[:,8])+(((data[:,4])+(((data[:,13])+(data[:,10])))))))+(((((data[:,13])+(((((data[:,13])/ 2.0)) +(data[:,9])))))+(np.tanh(((((data[:,8])+(data[:,8])) /2.0)))))))) +
0.250000*np.tanh(((((( data[:,19])+(((((data[:,10])+(((( data[:,11])+(data[:,19])) /2.0)))) +(data[:,10])))) /2.0)) +(data[:,2])))+
0.250000*np.tanh(((((( data[:,0])+(((((((((data[:,0])+(((((data[:,0])-(data[:,11])))/ 2.0)))/2.0)) * 2.0)) +(((((( np.tanh(( data[:,13])))+(((data[:,0])/ 2.0)))/2.0)) / 2.0)))/2.0)))/2.0)) * 2.0)) +
0.250000*np.tanh(((((-1.0*(( data[:,15])))) +(((data[:,14])+(data[:,14])))) /2.0)) +
0.250000*np.tanh(((((((((data[:,0])+(data[:,15])) /2.0)) +(((data[:,15])*(data[:,15])))) /2.0)) -(data[:,11])))+
0.250000*np.tanh(data[:,13])+
0.250000*np.tanh(((((((((data[:,18])+(((( data[:,4])+(data[:,18])) /2.0)))) / 2.0)) +(((( data[:,18])+(data[:,4])) /2.0)))) *(data[:,4]))))<predict_on_test>
test['isweekend']= test.apply(lambda x :(x['pickup_weekday']==6 | x['pickup_weekday']==5),axis=1)
 test['isweekend']=test['isweekend'].map({True: 1, False:0})
 test['store_and_fwd_flag']=test['store_and_fwd_flag'].map({'N': 1, 'Y':0} )
warnings.filterwarnings("ignore")
 env = nflrush.make_env()
iter_test = env.iter_test()
gp = GP()
for(test_df, sample_prediction_df)in iter_test:
basetable = create_features(test_df, deploy=True)
 basetable.drop(['GameId','PlayId'], axis=1, inplace=True)
 scaled_basetable = scaler.transform(basetable)
 y_pred_nn = model.predict(scaled_basetable)
 y_pred_gp = np.zeros(( test_df.shape[0],199))
ans = gp.GrabPredictions(scaled_basetable)
 y_pred_gp[:,96:96+20] = ans
y_pred = (.6*y_pred_nn+.4*y_pred_gp)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1 ).tolist() [0]
preds_df = pd.DataFrame(data=[y_pred], columns=sample_prediction_df.columns)
 env.predict(preds_df)
 env.write_submission_file()<import_modules>
feature_cols=['vendor_id','passenger_count','pickup_id','dropoff_id','pickup_weekday','pickup_hour'
,'pickup_month','store_and_fwd_flag' ,'distance']
X=ds[feature_cols]
Y=ds['trip_duration_log']
test_features=test[feature_cols]
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import datetime
from kaggle.competitions import nflrush
from tqdm import tqdm
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import LabelEncoder
import keras
from keras.callbacks import EarlyStopping
from keras import backend as K
from collections import Counter
from sklearn.model_selection import RepeatedKFold
from keras.models import Sequential, Model
from keras.layers import Input, Dense, Embedding, Concatenate, Flatten, BatchNormalization, Dropout
from keras.callbacks import ModelCheckpoint
from keras.utils.vis_utils import plot_model
from keras import metrics<load_from_csv>
X_train,X_test,Y_train,Y_test= b.train_test_split(X,Y,test_size=0.2, random_state=420)
 X_train,X_Val,Y_train,Y_Val= b.train_test_split(X_train,Y_train,test_size=0.1, random_state=420 )
train = pd.read_csv('.. /input/nfl-big-data-bowl-2020/train.csv', dtype={'WindSpeed': 'object'} )<feature_engineering>
taxi_trip_model = XGBRegressor(n_estimators=200,learning_rate=0.05)
 taxi_trip_model.fit(X_train,Y_train,early_stopping_rounds=10,
eval_set=[(X_Val, Y_Val)])
 pred_test = taxi_trip_model.predict(X_test, ntree_limit=taxi_trip_model.best_ntree_limit )
def fix_play_direction(df):
df.loc[df['PlayDirection'] == 'left', 'X'] = 120 - df.loc[df['PlayDirection'] == 'left', 'X']
df.loc[df['PlayDirection'] == 'left', 'Y'] =(160 / 3)- df.loc[df['PlayDirection'] == 'left', 'Y']
df.loc[df['PlayDirection'] == 'left', 'Orientation'] = np.mod(180 + df.loc[df['PlayDirection'] == 'left', 'Orientation'], 360)
 df.loc[df['PlayDirection'] == 'left', 'Dir'] = np.mod(180 + df.loc[df['PlayDirection'] == 'left', 'Dir'], 360)
 df['FieldPosition'].fillna('', inplace=True)
 df.loc[df['PossessionTeam'] != df['FieldPosition'], 'YardLine'] = 100 - df.loc[df['PossessionTeam'] != df['FieldPosition'], 'YardLine']
return df
train = fix_play_direction(train )<feature_engineering>
mae = mean_absolute_error(Y_test,pred_test)
 print(mae )
train['GameClock'] = train['GameClock'].apply(strtoseconds )<feature_engineering>
predtest = taxi_trip_model.predict(test_features,ntree_limit=taxi_trip_model.best_ntree_limit )
train['PlayerHeight'] = train['PlayerHeight'].apply(lambda x: 12*int(x.split('-')[0])+int(x.split('-')[1]))<data_type_conversions>
y_test =np.exp(predtest)-1
train['TimeHandoff'] = train['TimeHandoff'].apply(lambda x: datetime.datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%fZ"))
train['TimeSnap'] = train['TimeSnap'].apply(lambda x: datetime.datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%fZ"))<feature_engineering>
output = pd.DataFrame({'id': test['id'],
'trip_duration': y_test})
 output.to_csv('submission_xgb_best.csv', index=False )
<feature_engineering><EOS>