--- title: Featurizing Time Series keywords: fastai sidebar: home_sidebar summary: "Functions used to transform time series into a dataframe that can be used to create tabular dataloaders." description: "Functions used to transform time series into a dataframe that can be used to create tabular dataloaders." nb_path: "nbs/020_data.features.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
{% endraw %}

In this case we are using tsfresh that is one of the most widely known libraries used to create features from time series. You can get more details about this library here: https://tsfresh.readthedocs.io/en/latest/

{% raw %}
{% endraw %} {% raw %}

get_ts_features[source]

get_ts_features(X:Union[ndarray, Tensor], y:Union[NoneType, ndarray, Tensor]=None, features:Union[str, dict]='min', n_jobs:Optional[int]=None, **kwargs)

Args: X: np.array or torch.Tesnor of shape [samples, dimensions, timesteps]. y: Not required for unlabeled data. Otherwise, you need to pass it. features: 'min', 'efficient', 'all', or a dictionary. Be aware that 'efficient' and 'all' may required substantial memory and time.

{% endraw %} {% raw %}
{% endraw %} {% raw %}
dsid = 'NATOPS'
X, y, splits = get_UCR_data(dsid, return_split=False)
X.shape
(360, 24, 51)
{% endraw %}

There are 3 levels of fatures you can extract: 'min', 'efficient' and 'all'. I'd encourage you to start with min as feature creation may take a long time.

In addition to this, you can pass a dictionary to build the desired features (see tsfresh documentation in the link above).

{% raw %}
ts_features_df = get_ts_features(X, y)
ts_features_df.shape
Feature Extraction: 100%|████████████████████████████████████| 40/40 [00:05<00:00,  7.11it/s]
(360, 217)
{% endraw %}

The 'min' set creates a dataframe with 8 features per channel + 1 per target (total 193) for each time series sample (360).

{% raw %}
cont_names = ts_features_df.columns[:-1]
y_names = 'target'
dls = get_tabular_dls(ts_features_df, splits=splits, cont_names=cont_names, y_names=y_names)
dls.show_batch()
0__sum_values 0__median 0__mean 0__length 0__standard_deviation 0__variance 0__root_mean_square 0__maximum 0__minimum 1__sum_values 1__median 1__mean 1__length 1__standard_deviation 1__variance 1__root_mean_square 1__maximum 1__minimum 2__sum_values 2__median 2__mean 2__length 2__standard_deviation 2__variance 2__root_mean_square 2__maximum 2__minimum 3__sum_values 3__median 3__mean 3__length 3__standard_deviation 3__variance 3__root_mean_square 3__maximum 3__minimum 4__sum_values 4__median 4__mean 4__length 4__standard_deviation 4__variance 4__root_mean_square 4__maximum 4__minimum 5__sum_values 5__median 5__mean 5__length 5__standard_deviation 5__variance 5__root_mean_square 5__maximum 5__minimum 6__sum_values 6__median 6__mean 6__length 6__standard_deviation 6__variance 6__root_mean_square 6__maximum 6__minimum 7__sum_values 7__median 7__mean 7__length 7__standard_deviation 7__variance 7__root_mean_square 7__maximum 7__minimum 8__sum_values 8__median 8__mean 8__length 8__standard_deviation 8__variance 8__root_mean_square 8__maximum 8__minimum 9__sum_values 9__median 9__mean 9__length 9__standard_deviation 9__variance 9__root_mean_square 9__maximum 9__minimum 10__sum_values 10__median 10__mean 10__length 10__standard_deviation 10__variance 10__root_mean_square 10__maximum 10__minimum 11__sum_values 11__median 11__mean 11__length 11__standard_deviation 11__variance 11__root_mean_square 11__maximum 11__minimum 12__sum_values 12__median 12__mean 12__length 12__standard_deviation 12__variance 12__root_mean_square 12__maximum 12__minimum 13__sum_values 13__median 13__mean 13__length 13__standard_deviation 13__variance 13__root_mean_square 13__maximum 13__minimum 14__sum_values 14__median 14__mean 14__length 14__standard_deviation 14__variance 14__root_mean_square 14__maximum 14__minimum 15__sum_values 15__median 15__mean 15__length 15__standard_deviation 15__variance 15__root_mean_square 15__maximum 15__minimum 16__sum_values 16__median 16__mean 16__length 16__standard_deviation 16__variance 16__root_mean_square 16__maximum 16__minimum 17__sum_values 17__median 17__mean 17__length 17__standard_deviation 17__variance 17__root_mean_square 17__maximum 17__minimum 18__sum_values 18__median 18__mean 18__length 18__standard_deviation 18__variance 18__root_mean_square 18__maximum 18__minimum 19__sum_values 19__median 19__mean 19__length 19__standard_deviation 19__variance 19__root_mean_square 19__maximum 19__minimum 20__sum_values 20__median 20__mean 20__length 20__standard_deviation 20__variance 20__root_mean_square 20__maximum 20__minimum 21__sum_values 21__median 21__mean 21__length 21__standard_deviation 21__variance 21__root_mean_square 21__maximum 21__minimum 22__sum_values 22__median 22__mean 22__length 22__standard_deviation 22__variance 22__root_mean_square 22__maximum 22__minimum 23__sum_values 23__median 23__mean 23__length 23__standard_deviation 23__variance 23__root_mean_square 23__maximum 23__minimum target
0 -37.142456 -0.566632 -0.728283 51.0 1.080438 1.167346 1.302975 0.696339 -2.332613 -35.411819 -0.415532 -0.694349 51.0 0.832850 0.693640 1.084325 0.291253 -1.906993 -35.485306 -0.702877 -0.695790 51.0 0.298104 0.088866 0.756961 -0.247774 -1.539848 39.676464 0.573882 0.777970 51.0 1.060847 1.125397 1.315536 2.243961 -0.855261 -41.451077 -0.508144 -0.812766 51.0 0.747256 0.558391 1.104074 0.243118 -1.956784 -19.976217 -0.453625 -0.391691 51.0 0.559977 0.313574 0.683370 0.523402 -1.635486 -37.629429 -0.681118 -0.737832 51.0 0.255562 0.065312 0.780838 -0.348886 -1.181166 -24.176161 -0.583717 -0.474042 51.0 0.296457 0.087887 0.559109 0.081907 -0.771776 -13.816839 -0.244598 -0.270918 51.0 0.166769 0.027812 0.318133 -0.016374 -0.672385 37.760784 0.651040 0.740408 51.0 0.263288 0.069320 0.785827 1.151987 0.373290 -28.283892 -0.656930 -0.554586 51.0 0.266712 0.071135 0.615387 -0.046888 -0.849735 -6.133113 -0.115276 -0.120257 51.0 0.273553 0.074831 0.298819 0.297453 -0.711572 -37.277363 -0.612094 -0.730929 51.0 0.724792 0.525324 1.029359 0.282950 -1.823203 -28.811653 -0.299411 -0.564934 51.0 0.588243 0.346030 0.815586 0.127075 -1.441439 -29.826628 -0.537830 -0.584836 51.0 0.180427 0.032554 0.612035 -0.297570 -1.118365 37.234772 0.619421 0.730094 51.0 0.770851 0.594211 1.061719 1.786640 -0.412325 -36.002819 -0.572617 -0.705938 51.0 0.515526 0.265767 0.874137 0.082940 -1.552879 -16.507471 -0.375326 -0.323676 51.0 0.450168 0.202652 0.554453 0.426705 -1.334043 -38.540119 -0.677258 -0.755689 51.0 0.930965 0.866696 1.199067 0.460875 -2.161744 -33.472477 -0.407427 -0.656323 51.0 0.666127 0.443725 0.935139 0.258667 -1.678376 -32.643517 -0.576838 -0.640069 51.0 0.272025 0.073997 0.695475 -0.152945 -1.433935 39.163143 0.546208 0.767905 51.0 0.896380 0.803498 1.180329 2.017790 -0.761397 -35.701706 -0.425938 -0.700033 51.0 0.673097 0.453059 0.971136 0.155471 -1.725646 -21.955692 -0.472907 -0.430504 51.0 0.485376 0.235590 0.648786 0.418492 -1.392508 5.0
1 -23.586538 -0.459035 -0.462481 51.0 0.009482 0.000090 0.462578 -0.446862 -0.481365 -92.686127 -1.849527 -1.817375 51.0 0.101964 0.010397 1.820233 -1.663032 -1.962149 -41.622047 -0.827207 -0.816119 51.0 0.033863 0.001147 0.816821 -0.747979 -0.858209 63.747234 0.934293 1.249946 51.0 0.673389 0.453453 1.419795 2.189053 0.548686 -58.417156 -1.841674 -1.145434 51.0 1.016232 1.032728 1.531257 0.733217 -2.084998 -24.397539 -0.548217 -0.478383 51.0 0.308897 0.095417 0.569445 -0.000290 -0.809470 -28.876244 -0.562972 -0.566201 51.0 0.008569 0.000073 0.566266 -0.555073 -0.588383 -36.323483 -0.716465 -0.712225 51.0 0.015567 0.000242 0.712395 -0.685397 -0.728811 -7.992872 -0.155516 -0.156723 51.0 0.005660 0.000032 0.156825 -0.143304 -0.168963 39.989666 0.623494 0.784111 51.0 0.238023 0.056655 0.819442 1.174931 0.483369 -26.093328 -0.753153 -0.511634 51.0 0.351613 0.123632 0.620807 0.169596 -0.812728 -7.680929 -0.204852 -0.150606 51.0 0.102779 0.010563 0.182334 -0.008648 -0.263605 -26.193447 -0.509508 -0.513597 51.0 0.013127 0.000172 0.513765 -0.484523 -0.541967 -71.000397 -1.411905 -1.392165 51.0 0.072467 0.005251 1.394050 -1.279870 -1.469527 -28.277258 -0.567105 -0.554456 51.0 0.037604 0.001414 0.555730 -0.492550 -0.598832 56.125183 0.875697 1.100494 51.0 0.484735 0.234968 1.202520 1.779165 0.617105 -46.534298 -1.413166 -0.912437 51.0 0.748352 0.560030 1.180073 0.448841 -1.586794 -17.314447 -0.398915 -0.339499 51.0 0.226818 0.051447 0.408297 -0.015210 -0.585162 -18.311501 -0.351347 -0.359049 51.0 0.018174 0.000330 0.359509 -0.338670 -0.400617 -78.851265 -1.556720 -1.546103 51.0 0.105376 0.011104 1.549690 -1.355958 -1.702347 -39.995407 -0.796421 -0.784224 51.0 0.053275 0.002838 0.786031 -0.682512 -0.850075 57.236649 0.919596 1.122287 51.0 0.674924 0.455523 1.309600 2.135956 0.426736 -49.555946 -1.602230 -0.971685 51.0 0.927211 0.859720 1.343091 0.715503 -1.850632 -25.822395 -0.650457 -0.506321 51.0 0.296268 0.087775 0.586631 0.009632 -0.798197 2.0
2 -27.534769 -0.549152 -0.539897 51.0 0.021874 0.000478 0.540340 -0.503747 -0.575321 -94.657532 -1.904847 -1.856030 51.0 0.081266 0.006604 1.857808 -1.715478 -1.953308 -36.396606 -0.719202 -0.713659 51.0 0.015428 0.000238 0.713826 -0.680681 -0.736228 55.414169 0.777391 1.086552 51.0 0.664497 0.441556 1.273637 2.051978 0.447330 -69.362656 -1.774472 -1.360052 51.0 0.702855 0.494004 1.530930 -0.043852 -1.950569 -24.672823 -0.584322 -0.483781 51.0 0.236525 0.055944 0.538505 -0.081316 -0.720806 -34.442677 -0.691327 -0.675347 51.0 0.028594 0.000818 0.675952 -0.625143 -0.715496 -37.984409 -0.753441 -0.744792 51.0 0.018509 0.000343 0.745022 -0.713884 -0.774510 -11.913812 -0.233479 -0.233604 51.0 0.005520 0.000030 0.233669 -0.224766 -0.243437 42.796070 0.710874 0.839139 51.0 0.202831 0.041140 0.863304 1.145277 0.655254 -29.257515 -0.785101 -0.573677 51.0 0.310883 0.096648 0.652498 0.005091 -0.829290 -2.638177 -0.082883 -0.051729 51.0 0.082314 0.006776 0.097219 0.082908 -0.137571 -32.033615 -0.644218 -0.628110 51.0 0.034258 0.001174 0.629044 -0.571184 -0.666909 -75.444572 -1.515485 -1.479305 51.0 0.057601 0.003318 1.480426 -1.380601 -1.548318 -29.218090 -0.581810 -0.572904 51.0 0.017170 0.000295 0.573161 -0.539507 -0.592614 52.465370 0.762001 1.028733 51.0 0.451642 0.203980 1.123508 1.741365 0.599525 -53.264122 -1.412518 -1.044395 51.0 0.571948 0.327124 1.190749 0.001606 -1.542234 -15.971079 -0.393152 -0.313158 51.0 0.188495 0.035531 0.365512 -0.004376 -0.512214 -36.599499 -0.737050 -0.717637 51.0 0.042227 0.001783 0.718879 -0.645706 -0.769070 -85.183380 -1.703202 -1.670262 51.0 0.064617 0.004175 1.671512 -1.554826 -1.760427 -30.937372 -0.620587 -0.606615 51.0 0.026403 0.000697 0.607189 -0.549836 -0.658139 50.079212 0.589639 0.981945 51.0 0.633433 0.401238 1.168527 1.947102 0.384357 -62.113159 -1.563564 -1.217905 51.0 0.546153 0.298283 1.334757 -0.165008 -1.699278 -23.189987 -0.585661 -0.454706 51.0 0.239105 0.057171 0.513740 -0.076619 -0.706615 3.0
3 -34.523727 -0.611601 -0.676936 51.0 1.118289 1.250571 1.307216 0.960055 -2.449983 -30.783985 -0.095217 -0.603608 51.0 0.967301 0.935672 1.140182 0.656134 -2.015023 -33.377033 -0.564160 -0.654452 51.0 0.500285 0.250285 0.823767 0.059411 -1.797334 35.240353 0.437840 0.690987 51.0 1.138671 1.296571 1.331929 2.536414 -0.825107 -32.934444 -0.278688 -0.645773 51.0 0.943159 0.889549 1.143054 0.827051 -2.039725 -20.456612 -0.444747 -0.401110 51.0 0.505705 0.255738 0.645466 0.381416 -1.547785 -37.177876 -0.791889 -0.728978 51.0 0.392956 0.154415 0.828145 -0.161233 -1.296134 -17.490719 -0.251759 -0.342955 51.0 0.340407 0.115877 0.483213 0.233377 -0.815718 -18.717752 -0.236368 -0.367015 51.0 0.283484 0.080363 0.463749 0.115903 -0.997842 32.120663 0.668862 0.629817 51.0 0.463524 0.214854 0.782000 1.240265 -0.106268 -21.084183 -0.243511 -0.413415 51.0 0.318172 0.101233 0.521676 0.189670 -0.902645 -14.248999 -0.072230 -0.279392 51.0 0.375381 0.140911 0.467943 0.203083 -1.014819 -34.282619 -0.691584 -0.672208 51.0 0.879838 0.774114 1.107239 0.655985 -1.946674 -25.174671 -0.115776 -0.493621 51.0 0.681656 0.464656 0.841616 0.614789 -1.514637 -29.738565 -0.447657 -0.583109 51.0 0.324859 0.105533 0.667495 0.022827 -1.405983 30.816469 0.584257 0.604244 51.0 0.916507 0.839985 1.097769 1.921937 -0.677575 -26.291033 -0.251256 -0.515510 51.0 0.700747 0.491046 0.869941 0.499655 -1.579280 -19.165892 -0.368467 -0.375802 51.0 0.342794 0.117507 0.508659 0.292727 -1.157730 -34.754513 -0.539055 -0.681461 51.0 0.993149 0.986345 1.204464 0.754227 -2.281904 -25.093094 -0.081687 -0.492021 51.0 0.859995 0.739592 0.990796 0.539001 -1.798538 -30.791185 -0.652611 -0.603749 51.0 0.445411 0.198391 0.750269 0.368556 -1.615448 32.154030 0.350904 0.630471 51.0 1.001985 1.003974 1.183836 2.214722 -0.835791 -26.250469 -0.174046 -0.514715 51.0 0.828387 0.686224 0.975272 0.709062 -1.912724 -21.588564 -0.484073 -0.423305 51.0 0.418509 0.175150 0.595262 0.283859 -1.556566 5.0
4 -27.740828 -0.545375 -0.543938 51.0 0.018743 0.000351 0.544261 -0.494518 -0.579461 -90.292770 -1.765763 -1.770447 51.0 0.036722 0.001349 1.770827 -1.706970 -1.853963 -36.805576 -0.719215 -0.721678 51.0 0.014169 0.000201 0.721817 -0.698224 -0.746079 55.411224 0.565932 1.086495 51.0 0.703291 0.494618 1.294252 2.168473 0.435790 -66.905548 -1.832362 -1.311873 51.0 0.788599 0.621889 1.530654 0.271097 -1.874072 -13.485033 -0.417840 -0.264412 51.0 0.234444 0.054964 0.353381 0.158437 -0.510906 -35.591778 -0.699636 -0.697878 51.0 0.007728 0.000060 0.697921 -0.680177 -0.707192 -37.724495 -0.744179 -0.739696 51.0 0.010902 0.000119 0.739776 -0.720091 -0.753452 -13.115386 -0.258923 -0.257164 51.0 0.008701 0.000076 0.257312 -0.240681 -0.273511 38.005325 0.582472 0.745202 51.0 0.226554 0.051327 0.778880 1.119772 0.565721 -32.317341 -0.837423 -0.633673 51.0 0.317354 0.100713 0.708700 -0.001292 -0.881977 3.958976 0.056248 0.077627 51.0 0.059057 0.003488 0.097538 0.185256 0.023052 -34.244289 -0.672723 -0.671457 51.0 0.009922 0.000098 0.671530 -0.650090 -0.691726 -68.404839 -1.351641 -1.341271 51.0 0.028172 0.000794 1.341567 -1.291957 -1.426920 -29.412851 -0.578755 -0.576723 51.0 0.011017 0.000121 0.576828 -0.556926 -0.600077 49.732811 0.580538 0.975153 51.0 0.497556 0.247562 1.094754 1.746756 0.565985 -55.526955 -1.487079 -1.088764 51.0 0.604426 0.365331 1.245286 0.115819 -1.528785 -6.664329 -0.240217 -0.130673 51.0 0.180493 0.032578 0.222830 0.179415 -0.291895 -35.235294 -0.693773 -0.690888 51.0 0.025952 0.000674 0.691375 -0.648388 -0.752783 -77.603714 -1.524844 -1.521641 51.0 0.052388 0.002745 1.522543 -1.397734 -1.647556 -31.526560 -0.623116 -0.618168 51.0 0.042312 0.001790 0.619614 -0.521688 -0.710425 50.543438 0.437051 0.991048 51.0 0.672909 0.452806 1.197907 2.017675 0.407211 -56.079052 -1.548879 -1.099589 51.0 0.741843 0.550331 1.326434 0.359649 -1.701924 -15.354649 -0.491571 -0.301072 51.0 0.273509 0.074807 0.406757 0.197746 -0.517648 2.0
5 -24.641052 -0.505063 -0.483158 51.0 0.042338 0.001792 0.485009 -0.405295 -0.534384 -86.865654 -1.701567 -1.703248 51.0 0.029897 0.000894 1.703511 -1.649558 -1.776053 -22.712065 -0.425890 -0.445335 51.0 0.033334 0.001111 0.446580 -0.408019 -0.500026 55.652981 0.659823 1.091235 51.0 0.685066 0.469316 1.288452 2.044420 0.421733 -53.967831 -1.695504 -1.058193 51.0 0.920417 0.847167 1.402476 0.645616 -1.791308 -32.383308 -0.648966 -0.634967 51.0 0.047389 0.002246 0.636733 -0.509608 -0.720160 -28.113087 -0.570249 -0.551237 51.0 0.051464 0.002649 0.553634 -0.467229 -0.602690 -37.713421 -0.714133 -0.739479 51.0 0.055799 0.003114 0.741581 -0.684414 -0.833970 -1.482825 -0.017677 -0.029075 51.0 0.043634 0.001904 0.052434 0.022231 -0.092699 43.064579 0.721068 0.844404 51.0 0.212935 0.045341 0.870838 1.166963 0.644426 -20.664692 -0.710834 -0.405190 51.0 0.427100 0.182414 0.588722 0.375265 -0.735119 -13.322674 -0.277473 -0.261229 51.0 0.031957 0.001021 0.263176 -0.197522 -0.290647 -29.156836 -0.580230 -0.571703 51.0 0.036643 0.001343 0.572876 -0.510735 -0.617555 -67.319504 -1.317114 -1.319990 51.0 0.037284 0.001390 1.320517 -1.249171 -1.388353 -15.800675 -0.304392 -0.309817 51.0 0.030900 0.000955 0.311354 -0.261847 -0.350759 52.616730 0.736055 1.031701 51.0 0.473487 0.224190 1.135163 1.727030 0.587150 -39.129475 -1.277829 -0.767245 51.0 0.719665 0.517918 1.051942 0.563694 -1.306752 -25.997158 -0.535997 -0.509748 51.0 0.054588 0.002980 0.512663 -0.397202 -0.567835 -20.657892 -0.417811 -0.405057 51.0 0.040592 0.001648 0.407086 -0.334117 -0.452444 -72.182457 -1.411887 -1.415342 51.0 0.041348 0.001710 1.415946 -1.346556 -1.506598 -24.713848 -0.481777 -0.484585 51.0 0.021053 0.000443 0.485042 -0.445826 -0.546492 51.338303 0.642269 1.006633 51.0 0.678483 0.460340 1.213940 2.005553 0.364407 -45.864155 -1.413934 -0.899297 51.0 0.762100 0.580797 1.178784 0.545444 -1.529748 -35.470558 -0.696268 -0.695501 51.0 0.082588 0.006821 0.700388 -0.481607 -0.844821 3.0
6 -24.011181 -0.463308 -0.470807 51.0 0.022327 0.000499 0.471337 -0.430550 -0.519750 -97.602142 -1.932483 -1.913768 51.0 0.065244 0.004257 1.914879 -1.744846 -2.022548 -40.876678 -0.822114 -0.801503 51.0 0.037470 0.001404 0.802379 -0.739014 -0.852205 58.312725 0.890756 1.143387 51.0 0.625533 0.391292 1.303313 2.287177 0.488941 -24.820274 -1.291028 -0.486672 51.0 1.539181 2.369080 1.614289 1.607593 -2.030625 -23.528324 -0.470723 -0.461340 51.0 0.340889 0.116205 0.573620 0.025836 -0.867550 -29.485134 -0.580218 -0.578140 51.0 0.010866 0.000118 0.578242 -0.557524 -0.598073 -39.278442 -0.783769 -0.770166 51.0 0.037736 0.001424 0.771089 -0.710738 -0.828738 -9.966043 -0.219775 -0.195413 51.0 0.053768 0.002891 0.202675 -0.125779 -0.268663 39.935242 0.751462 0.783044 51.0 0.217438 0.047279 0.812673 1.164140 0.542353 -12.488911 -0.582633 -0.244881 51.0 0.651232 0.424103 0.695751 0.718757 -0.883951 -10.751954 -0.203955 -0.210823 51.0 0.109824 0.012061 0.237713 -0.033436 -0.347595 -27.786322 -0.539891 -0.544830 51.0 0.017510 0.000307 0.545111 -0.508702 -0.577425 -75.600090 -1.486838 -1.482355 51.0 0.063190 0.003993 1.483701 -1.327342 -1.596648 -30.532627 -0.613594 -0.598679 51.0 0.045950 0.002111 0.600440 -0.509880 -0.664597 51.931953 0.871081 1.018274 51.0 0.424618 0.180301 1.103260 1.827167 0.569429 -18.751158 -0.944382 -0.367670 51.0 1.195926 1.430238 1.251167 1.347136 -1.549184 -20.509649 -0.400428 -0.402150 51.0 0.233003 0.054291 0.464774 -0.103234 -0.706466 -30.697359 -0.596296 -0.601909 51.0 0.019827 0.000393 0.602235 -0.570799 -0.636124 -87.481331 -1.717072 -1.715320 51.0 0.065076 0.004235 1.716554 -1.576493 -1.851188 -33.553829 -0.659760 -0.657918 51.0 0.072796 0.005299 0.661933 -0.550007 -0.793064 54.696705 0.877398 1.072484 51.0 0.548211 0.300535 1.204474 2.050468 0.381210 -21.277277 -1.030952 -0.417201 51.0 1.346573 1.813258 1.409722 1.466641 -1.913035 -25.165306 -0.649369 -0.493437 51.0 0.331068 0.109606 0.594211 -0.022846 -0.904735 1.0
7 -8.365997 -0.488237 -0.164039 51.0 0.861993 0.743032 0.877463 1.029133 -1.768655 -53.286537 -1.314198 -1.044834 51.0 0.886490 0.785865 1.370235 0.227674 -2.050905 -46.906807 -0.802123 -0.919741 51.0 0.311894 0.097278 0.971186 -0.577902 -1.703846 38.374161 0.568970 0.752435 51.0 0.450099 0.202589 0.876782 1.998679 0.147983 -21.709152 -0.124288 -0.425670 51.0 1.425600 2.032334 1.487793 1.339821 -2.144831 -26.375257 -0.630030 -0.517162 51.0 0.384127 0.147553 0.644212 0.058934 -1.188380 -30.072155 -0.564549 -0.589650 51.0 0.176888 0.031289 0.615611 -0.161023 -0.994883 -35.510662 -0.706239 -0.696288 51.0 0.134033 0.017965 0.709071 -0.343577 -0.890725 -16.280081 -0.202099 -0.319217 51.0 0.198182 0.039276 0.375734 -0.081876 -0.796913 40.591137 0.800127 0.795905 51.0 0.195735 0.038312 0.819620 1.103982 0.528110 -23.000767 -0.717054 -0.450995 51.0 0.448824 0.201443 0.636270 0.546236 -0.909251 -21.802408 -0.330379 -0.427498 51.0 0.248390 0.061698 0.494421 -0.083385 -0.906979 -15.922804 -0.569262 -0.312212 51.0 0.649574 0.421946 0.720709 0.656241 -1.462341 -46.129963 -1.034976 -0.904509 51.0 0.586374 0.343834 1.077947 0.038515 -1.571658 -35.021671 -0.608531 -0.686699 51.0 0.247191 0.061103 0.729835 -0.307963 -1.350471 41.395386 0.644028 0.811674 51.0 0.296061 0.087652 0.863983 1.593879 0.538310 -20.574291 -0.347907 -0.403417 51.0 1.097336 1.204146 1.169141 1.198281 -1.712231 -22.603098 -0.393473 -0.443198 51.0 0.215165 0.046296 0.492667 -0.107243 -0.823980 -10.818039 -0.407149 -0.212118 51.0 0.762371 0.581210 0.791330 0.857516 -1.666694 -48.057308 -1.098741 -0.942300 51.0 0.694110 0.481789 1.170350 0.185651 -1.769540 -46.852596 -0.797816 -0.918678 51.0 0.244485 0.059773 0.950654 -0.604900 -1.462650 37.673004 0.618823 0.738686 51.0 0.405797 0.164671 0.842810 1.877750 0.143511 -22.777447 -0.054079 -0.446617 51.0 1.213053 1.471496 1.292657 1.142601 -1.970851 -24.964903 -0.473136 -0.489508 51.0 0.345590 0.119433 0.599208 0.009404 -1.023302 6.0
8 -27.351284 -0.518949 -0.536300 51.0 0.046865 0.002196 0.538343 -0.462070 -0.607817 -109.678902 -2.180293 -2.150567 51.0 0.151885 0.023069 2.155924 -1.922185 -2.391596 -45.926826 -0.917819 -0.900526 51.0 0.041767 0.001744 0.901494 -0.819673 -0.955554 71.575691 1.572630 1.403445 51.0 0.592642 0.351225 1.523444 2.086033 0.596149 -66.393974 -1.657398 -1.301843 51.0 0.891906 0.795497 1.578066 -0.061573 -2.444070 25.170977 0.447105 0.493549 51.0 0.465884 0.217048 0.678703 1.073184 -0.126587 -33.239853 -0.644438 -0.651762 51.0 0.044559 0.001985 0.653283 -0.584973 -0.715239 -42.224979 -0.818994 -0.827941 51.0 0.035162 0.001236 0.828687 -0.779379 -0.898917 -21.782492 -0.433966 -0.427108 51.0 0.018372 0.000338 0.427503 -0.400342 -0.450000 39.817318 0.777473 0.780732 51.0 0.179042 0.032056 0.800998 1.023270 0.525810 -29.436472 -0.805910 -0.577186 51.0 0.339334 0.115147 0.669545 -0.074147 -0.964736 23.668175 0.518504 0.464082 51.0 0.208413 0.043436 0.508732 0.747857 0.191997 -31.822119 -0.614244 -0.623963 51.0 0.047347 0.002242 0.625757 -0.552890 -0.689216 -81.958847 -1.648392 -1.607036 51.0 0.109433 0.011976 1.610758 -1.441106 -1.777643 -38.864323 -0.771801 -0.762046 51.0 0.028475 0.000811 0.762577 -0.709696 -0.798762 57.814247 1.231724 1.133613 51.0 0.399470 0.159576 1.201937 1.673647 0.584908 -52.746735 -1.405661 -1.034250 51.0 0.730406 0.533492 1.266161 -0.009948 -1.907789 26.469147 0.570275 0.519003 51.0 0.341535 0.116646 0.621297 0.929915 0.086529 -21.595278 -0.415527 -0.423437 51.0 0.042518 0.001808 0.425566 -0.367692 -0.549352 -95.580650 -1.886143 -1.874130 51.0 0.136770 0.018706 1.879115 -1.666203 -2.075106 -44.793419 -0.877613 -0.878302 51.0 0.051411 0.002643 0.879806 -0.787749 -1.004349 68.536438 1.469191 1.343852 51.0 0.552272 0.305005 1.452908 2.016362 0.540264 -63.787148 -1.542168 -1.250728 51.0 0.784288 0.615107 1.476289 -0.189796 -2.381084 23.526495 0.450849 0.461304 51.0 0.418996 0.175557 0.623184 1.018544 -0.144610 3.0
9 -22.383287 -0.433973 -0.438888 51.0 0.030587 0.000936 0.439952 -0.333878 -0.489605 -96.128319 -1.866229 -1.884869 51.0 0.049155 0.002416 1.885510 -1.806382 -1.977565 -34.293411 -0.664501 -0.672420 51.0 0.028777 0.000828 0.673035 -0.629528 -0.722783 61.888138 1.129317 1.213493 51.0 0.685334 0.469682 1.393645 2.095530 0.397101 -52.376316 -1.658472 -1.026987 51.0 0.951461 0.905279 1.399993 0.578646 -1.938946 -19.565296 -0.331182 -0.383633 51.0 0.262853 0.069092 0.465044 -0.002740 -0.745568 -29.206686 -0.577022 -0.572680 51.0 0.023088 0.000533 0.573145 -0.536008 -0.599462 -36.167240 -0.690178 -0.709162 51.0 0.041297 0.001705 0.710363 -0.657463 -0.784010 -6.692489 -0.121380 -0.131225 51.0 0.029391 0.000864 0.134476 -0.089520 -0.178210 43.650726 0.772613 0.855897 51.0 0.234044 0.054777 0.887319 1.177192 0.610031 -17.416252 -0.611470 -0.341495 51.0 0.438621 0.192389 0.555884 0.401384 -0.723907 -1.267462 -0.041259 -0.024852 51.0 0.075804 0.005746 0.079774 0.095014 -0.138149 -28.284584 -0.552181 -0.554600 51.0 0.029693 0.000882 0.555394 -0.506625 -0.593304 -72.344162 -1.405501 -1.418513 51.0 0.034999 0.001225 1.418945 -1.358184 -1.510467 -23.774748 -0.467690 -0.466172 51.0 0.013241 0.000175 0.466359 -0.433828 -0.499162 54.866055 1.048298 1.075805 51.0 0.525492 0.276142 1.197288 1.778087 0.442742 -37.574776 -1.268729 -0.736760 51.0 0.790515 0.624913 1.080615 0.593380 -1.499591 -13.062757 -0.201253 -0.256132 51.0 0.215395 0.046395 0.334662 0.026883 -0.549603 -25.723345 -0.543739 -0.504379 51.0 0.122008 0.014886 0.518926 -0.282899 -0.655812 -83.668297 -1.647325 -1.640555 51.0 0.083061 0.006899 1.642656 -1.450976 -1.808875 -30.147928 -0.542791 -0.591136 51.0 0.099901 0.009980 0.599518 -0.453954 -0.761820 60.452160 0.911910 1.185336 51.0 0.624123 0.389530 1.339609 2.019748 0.524763 -48.657574 -1.482353 -0.954070 51.0 0.788794 0.622196 1.237920 0.443158 -1.727180 -15.993189 -0.312500 -0.313592 51.0 0.200989 0.040396 0.372473 -0.023128 -0.636585 3.0
{% endraw %} {% raw %}
x_cat, x_cont, yb = first(dls.train)
x_cont[:10]
tensor([[ 0.8806,  0.1002,  0.8806,  ...,  1.1443, -0.8758, -0.4822],
        [-2.0681, -2.0730, -2.0681,  ...,  0.1335, -0.6172, -0.6517],
        [ 0.5705,  0.9112,  0.5705,  ...,  0.1432, -1.0031,  0.4127],
        ...,
        [-0.5616, -0.7755, -0.5616,  ...,  0.8445, -1.0365, -0.7131],
        [ 0.2748,  0.5201,  0.2748,  ..., -0.2569, -0.4253,  0.2949],
        [-0.1811,  0.0787, -0.1811,  ..., -0.1807,  0.0275,  0.2089]])
{% endraw %} {% raw %}
from tsai.models.utils import *
from tsai.models.TabModel import *
model = build_tabular_model(TabModel, dls=dls)
learn = Learner(dls, model, metrics=[accuracy, RocAuc()])
learn.fit_one_cycle(5)
epoch train_loss valid_loss accuracy roc_auc_score time
0 1.861978 1.789068 0.266667 0.535370 00:00
1 1.778144 1.679453 0.477778 0.875778 00:00
2 1.637727 1.548165 0.622222 0.923259 00:00
3 1.509121 1.444736 0.672222 0.933259 00:00
4 1.409377 1.394630 0.650000 0.937111 00:00
{% endraw %} {% raw %}
b = first(dls.train)
model(*b[:-1]).shape
torch.Size([64, 6])
{% endraw %}