How to convert 3 numbers (or axes) into one number

257 Views Asked by At

I'm sorry if my explication is not quite the best but I'm not sure how to explain this in mathematical terms.

So I'm working on a Machine Learning project where I'm trying to get the emotions from one text. Each emotion will have a value from 0 to 1, where 0 means that emotion those not exist, and 1 means it's 100% that.

For example, I could have:

positive 0.8466, neutral 0.1458, negative 0.0076

This been my 3 base emotions that I am getting from any text.

Is there any way in which I can convert those numbers into a single one from a spectrum between -1 and 1. That would mean if the number is closer to 0 then the most powerful emotion from that text is negative, if it's closer to 0 then it's neutral, and also if it's closer to 1 that means it's positive.

Those any of you know how can I achieve something like this? I was thinking to consider each of the emotions as an axis into a 3d space, but I'm not sure how could I calculate that point in space.

2

There are 2 best solutions below

1
On BEST ANSWER

Let $u$ be the negative weight, $v$ the neutral weight, and $w$ the positive weight. The score you want is of form $$S = \frac{f(w) - h(u)}{f(w) + g(v) + h(u)}$$ where $f$, $g$, and $h$ are nonnegative weighting functions.

The simplest one is linear: $f(x) = x$, $g(x) = x$, $h(x) = x$, so $$S = \frac{w - u}{w + v + u}$$

Almost as simple is a monomial form of some degree $p$, $f(x) = x^p$, $g(x) = x^p$, $h(x) = x^p$, so $$S = \frac{w^p - u^p}{w^p + v^p + u^p}$$ where $p \gt 0$. Obviously, for $p = 1$ it is the linear above.

0
On

A very natural solution is to weight the values. For example take $f(x)=1 \times$ positive $+ 0 \times $ neutral $ + (-1) \times $ negative. It's easy to show that $f(x) \in [-1,1]$ and why you can ignore neutral.