3
$\begingroup$

I would like to train a machine learning model with several features as input as X[] and with one output as Y. For example Every sample has a Data frame like this: X[0], X[1], X[2], X[3], X[4], Y

Let's say One sample the followings Data is only one value: X[0], X[1], X[2], X[4], Y This is normal machine training problem.

But now, if I would like to set X[3] multiple values for example sample 1 Data is:

X[0] | X[1] | X[2] |         X[3]         | X[4] | Y
 10  |  5   |   6  | [10, 20, 30, 40, 50] |  7   | 90

Data in sample 2 is:

X[0] | X[1] | X[2] |         X[3]         | X[4] | Y
 11  |  7   |   5  | [20, 30, 40, 50, 60] |  3   | 80

Is this possible to follow the normal machine training process and got a model which could calculate a sample with other example with Data like:

X[0]   | X[1] |  X[2]  |         X[3]         | X[4] | Y
 10.5  |  6   |   5.5  | [15, 25, 35, 45, 55] |  5   | ???

If the length for each X[3] is not long, it is possible to divide the X[3] into multiple new features, but if the length of X[3] is very long (len > 1000) with different distribution, making binary is also lead to too many new features. Is there any way to treat the X[3] directly without adding new features?

Really appreciate for your help.

$\endgroup$
5
  • 2
    $\begingroup$ Basically, it looks like you want to encode feature X[3] in some way; i.e. generate some other features based on it. For example - the mean, min and max of values in it (reducing the >1000 to 3). The exact way to do it depends on the nature of X[3]... $\endgroup$ Commented Jul 13, 2020 at 10:38
  • $\begingroup$ Thank you for your answer, just to confirm that your answer means it is not possible to directly use an "multiple value feature". Anyway have to transfer X[3] into multiple features. Am i understand right? $\endgroup$
    – Crazy9
    Commented Jul 14, 2020 at 2:52
  • 1
    $\begingroup$ Yes, in my opinion. $\endgroup$ Commented Jul 14, 2020 at 6:00
  • 2
    $\begingroup$ Does this answer your question? How to deal with categorical feature of very high cardinality? $\endgroup$
    – 10xAI
    Commented Jul 14, 2020 at 7:36
  • 2
    $\begingroup$ @10xAI that question deals with categorical features; OP's question is about a feature that is itself a vector. Can you elaborate on why are the two equivalent? $\endgroup$ Commented Jul 15, 2020 at 6:26

1 Answer 1

1
$\begingroup$

There are many options.

The most common method to handle variable length vectors is to pad the vectors. Add zeros as placeholders to the shorter length vectors until all the vectors are the same length. Then it can be modeled similar to any other feature vector.

Another option is to take the norm of the vector. That would yield a single scalar that could be used in the machine learning model.

Ultimately, the way to handle a feature vector that could be variable lengths depends on what the feature represents.

$\endgroup$

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.