# Class "interpolation" (distance to classes)

**URL:** <https://discourse.flucoma.org/t/class-interpolation-distance-to-classes/1903>\
**Category:** Usage Questions\
**Created:** [May 7, 2023, 12:34pm UTC](https://discourse.flucoma.org/t/class-interpolation-distance-to-classes/1903 "2023-05-07T12:34:08Z")\
**Posts on this page:** 1\
**Showing post:** 25

<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:** [June 6, 2023, 1:44pm UTC](https://discourse.flucoma.org/t/class-interpolation-distance-to-classes/1903/25 "2023-06-06T13:44:17Z")

</div>

> [@tremblap](#):
>
> that’s it! Now I understand how that can be annoying if you want to know always 2 values in the right order…

Yeah, that took me a bit to figure out. I guess it makes sense since more-often-than-not you want the distance to the `knearest`, but in this case I wanted a static ordering. In this case it’s easy enough to `zl rev` it, but I can see this getting much stickier if you want a \> `@numneighbors 2` version as I guess you’d need a `matrix` and some plumbing to reorder the `knearestdist` list based on the `knearest` list.

> [@tremblap](#):
>
> That said, looking at your example, I think your training set is not so good - you should get a lot more difference if you have the right amount of dimensions

For this vid I just used the setup as I had, with data I had pre-analyzed. The tuning is ~20Hz diff (~430 to ~450) so not insignificant. Also using a different physical sensor in a different physical position (3 o’clock in the vid, vs 12 o’clock in the training). But yes, I agree, not great differentiation in that vid.

This is something I tested extensively back in the day (a ton [in this thread](https://discourse.flucoma.org/t/regression-classification-regressification/547/61), more recent [optimization here](https://discourse.flucoma.org/t/optimizing-a-neural-network-classifier-fluid-mlpclassifier/) for optimizing for an mlp regressor.

At the moment I’m using:

```auto
13 mfccs / startcoeff 1
zero padding (256 64 512)
min 200 / max 12000
mean std low high (1 deriv)

```

Which when comparing between center and edge training data gave me **96.9%** accuracy. This was with the original Sensory Percussion hardware, which I’m now testing with a DIY version (much quieter, better dynamic range, wider freq response, etc…). It would be worthwhile revisiting the optimization with that new sensor.

 ![IMG_1272](https://discourse.flucoma.org/uploads/default/original/2X/6/6c83d19a3b2e66c30be876e8d33369082f1c8972.jpeg)

(listen to the diff in these two clips, recorded at the same time with the official hardware first, then my DIY one second)  
[Sensor\_Comparison.mp3.zip](https://discourse.flucoma.org/uploads/short-url/poO0Ofar9SbRFodUlkq4HNscCUI.zip) (708.5 KB)

> [@tremblap](#):
>
> maybe we should look at that together in a session.

Yeah, would love an old-fashioned geek out sesh if you’re down. I’ll be in the UK in a couple weeks and was planning on taking a trip to Hudds for one of the days, so maybe something then?

> [@tremblap](#):
>
> as for converting…

I was having a bit of a brain fart with this. I guess this is what I had in mind:

 ![Screenshot 2023-06-06 at 2.42.17 PM](https://discourse.flucoma.org/uploads/default/original/2X/0/03158981b72d171504e8419357323b184e6128b0.png)

I had to do something similar with an update to my DIY fader thing last year and had forgotten what I had.

> [@tremblap](#):
>
> I would probably scale and cap the distance to a ratio of the distance between the 2 centroids. this is a hunch though. another idea would be to make a ratio of first to (sum of first and second) to know how relatively you are far from each centre (a sort of confidence)

This sounds better though, and hopefully more robust.

---

_[View the full topic](https://discourse.flucoma.org/t/class-interpolation-distance-to-classes/1903)._
