2
$\begingroup$

If there is a regression problem with data $(x,t)$ with the target values t being between [0, 1], I know we can solve this using one of regression method by minimizing the squared error. But if we had to predict $t$ with one resolution of $0.1$ e.g., it does not matter whether you predict 0.72 or 0.79; predicting 0.7 would be enough, how can I describe a way such that this problem can be formulated as a multi-class classification problem?

$\endgroup$

2 Answers 2

2
$\begingroup$

You can do it like so:

  1. Map every $t$ in your training set as follows: $\hat{t} = f(t)= \left \lfloor \frac{t}{r} \right \rfloor$, where $\left \lfloor \cdot \right \rfloor$ denotes a flooring operation, and $r$ is the resolution, set to 0.1 in your case. The resulting response variable $\hat{t} \in \{0,1,2,3,4,5,6,7,8,9\}$.
  2. Encode the numbers $\{0,...,9\}$ into 10 different output classes, e.g. using one-hot encoding. Let's say we use $y$ to denote encoded $\hat{t}$.
  3. Train your classification model using $(x,y)$ as training data.

Here is some python code to play with these steps:

import numpy as np
t = np.random.rand(20,) # Generate 20 random values
r = 0.1  # Set resolution to 0.1
t_hat = np.floor( t/r )  # Quantize the values
t_hat = t_hat.astype(np.int)  # Convert to integer for better encoding. compatibility
$\endgroup$
0
$\begingroup$

Bin $t$ into ten groups: $0 \leq t_1 \leq 10, 10 < t_2 \leq 20, ...$ (IE if a value is between 0 and 10 inclusive, it gets labeled "1") and predict via a classifier.

$\endgroup$
2
  • $\begingroup$ bin? could you elaborate a bit more? $\endgroup$ Commented Apr 19, 2020 at 3:07
  • $\begingroup$ Make sense? Just group the values. $\endgroup$
    – Chris
    Commented Apr 19, 2020 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.