# Speed comparison between different dataset processing chains

**URL:** <https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807>\
**Category:** Pre-Release Toolbox2 Code Sharing\
**Created:** [March 5, 2021, 7:19pm UTC](https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807 "2021-03-05T19:19:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [March 5, 2021, 7:19pm UTC](https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807/1 "2021-03-05T19:19:19Z")

</div>

As evident by [some recent threads](https://discourse.flucoma.org/t/intelligent-feature-selection-with-svm-or-pca/788), I’ve been trying to optimize the data processing chains to avoid using dimensionality reduction in general. Among other reasons ([I seemed to get worse matching overall](https://discourse.flucoma.org/t/regression-classification-regressification/547/38)), one of the main reasons for this was speed. Although I can’t seem to find examples/discussion on the forum as such, but I remember testing longer processing chains early on and not being very pleased with how long additional processing and dimensionality reduction processes took.

So I finally got around to building a patch that compares the raw speed of three approaches:

1. `fluid.robustscale~` → `fluid.pca~` → `fluid.kdtree~`
2. `fluid.robustscale~` → `fluid.kdtree~`
3. `fluid.robustscale~` → `fluid.normalize~` → `fluid.mlpregressor~` → `fluid.kdtree~`

I have to say that I’m quite pleased with the results!

 ![Screenshot 2021-03-05 at 7.01.27 pm](https://discourse.flucoma.org/uploads/default/original/2X/d/d1efc832680e6ccb6adc89e7b7d21cae5cde7271.png)

The patch (attached below) creates 5000 entry datasets with 100 (randomly generated) data points and then does the associated processing/passing around.

Since the data is random the `fluid.mlpregressor~` didn’t properly converge (I think I stopped training around `5.4xxxxx` or so, but I figure for the purposes of speed, accuracy didn’t matter.

So it seems the PCA-ing step doesn’t add too much time at all, and MLP isn’t far behind either (though I’ve yet to get a dataset to converge using it, but that’s a different story).

Granted, in a realworld scenario there would be 10000 more steps involving individual column/stats scaling and massaging, as well as enough pruning and `fluid.bufcompose~`-ing to make one’s head spin, but the _core_ speed here is pretty comparable.

I’m still a bit terrified of what \*[actually\* processing some analysis stuff entails](https://discourse.flucoma.org/t/example-11-verbose/658) ([a boy can dream](https://discourse.flucoma.org/t/adding-a-symbolic-layer-to-fluid-datasets/799)), but for now:

 ![meme](https://discourse.flucoma.org/uploads/default/original/2X/1/15d232f38ffb3fe15ab0d2e968b6f72cdca68f7c.jpeg)

[speedtest.zip](https://discourse.flucoma.org/uploads/short-url/oEAECLg1RuDNS6IpP2BCCwy7dtj.zip) (144.2 KB)

---

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [March 8, 2021, 12:06am UTC](https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807/2 "2021-03-08T00:06:29Z")

</div>

Well color me interested.

Based on [@weefuzzy’s comments in the LTE thread](https://discourse.flucoma.org/t/lte-an-alternative-to-lpt-for-people-who-dont-care-about-pitch/605/12), I benchmarked UMAP vs PCA and the results are really impressive:

 ![Screenshot 2021-03-08 at 12.02.11 am](https://discourse.flucoma.org/uploads/default/original/2X/4/4d31a2b5f4cfd4e6df371856d5e6a972a426ab1c.png)

And from my understanding, UMAP is “better” than PCA in just about every way (particularly with lumpy(/musical) data)(?).

It definitely takes a bit longer to do the initial `fittransform`, but I’m not bothered by that at all since you only really need to do that once (and it’s nowhere near as long as MLP).

[Archive.zip](https://discourse.flucoma.org/uploads/short-url/cmlCZqEi7vyDdVNFw0uXQOmGLZt.zip) (151.0 KB)

---

<div class="post-metadata">

**Author:** ![tremblap](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tremblap/32/5_2.png) [@tremblap](https://discourse.flucoma.org/u/tremblap)\
**Post date:** [March 8, 2021, 9:29am UTC](https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807/3 "2021-03-08T09:29:24Z")

</div>

in both example there is a logical issue with a chain, namely:  
robustscale normalise mlp

because normalise will take the full range (min/max) and undo the robustscaling.

so you should try  
robustscale mlp  
and play with the IQR values (25/75 are default but 10/90 could be fun too)  
(and you save one (cheap) step)

otherwise this is interesting as an optimiisation thread. Looking forward to see/hear the comparative results

---

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [March 8, 2021, 10:24am UTC](https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807/4 "2021-03-08T10:24:21Z")

</div>

When I built that I was still under the impression that mlp _needed_ the values to be within the range of whatever `@activation` you are using, which @weefuzzy let me know is not the case in another thread.

Either way, it was more about building plausible processing chains to compare “real world” usage.

---

<div class="post-metadata">

**Author:** ![tremblap](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tremblap/32/5_2.png) [@tremblap](https://discourse.flucoma.org/u/tremblap)\
**Post date:** [March 8, 2021, 12:54pm UTC](https://discourse.flucoma.org/t/speed-comparison-between-different-dataset-processing-chains/807/5 "2021-03-08T12:54:59Z")

</div>

> [@rodrigo.constanzo](#):
>
> When I built that I was still under the impression that mlp _needed_ the values to be within the range of whatever `@activation` you are using

it is true that it is optimal but then you can use the neat features of non-linearity of the activation to distort softly these outliers… so most of your data fits within the linear part of the activation, then the distance between the bandits get more ignored as they are getting nearer due to cliping…
