0
$\begingroup$

I just started with ML, so this could potentially be a pretty stupid question, plz forgive me.

Here's the gist of the problem:

I have a list in json format like this:

[
  {
    // Final rank of the team after all the matches are done
    "rank": 7,
    // List of team members
    "characters": [
      { "char_id": "my_char_1", "level": 2, "item_ids": [1, 2, 3] }
      ...
    ]
  }
]

I want to predict the rank for a given "team" of characters without looking at the competitors. Basically, I want to go from this:

[
  { "char_id": "my_char_1", "level": 2, "item_ids": [1, 2, 3]  }
  ...
]

to a single output neuron with a value from 1 to 100.

I parsed the source data into the first json structure, but I'm currently stuck at trying to give Tensorflow pairs of data (team + past rank), ideally in the form of two arrays where elements at a given index belong together.

TLDR:

Assuming this is possible at all (and not a lack of information or something), how do I feed Tensorflow this example data (list of team members -> past rank) properly to predict the future rank of a completely new team?


I've found this question which is somewhat similar: Predicting outcome of MOBA team games

Based on this answer, I'm assuming I'll have to normalize the data, so instead of an array I would need a map like this:

{
  "my_char_1": null,
  "my_char_2": {
    "level": 2,
    "item_ids": {
      "1": true,
      "2": false,
      "3": true
      ...
    }
  },
  ...
}

However, I struggle with the act of passing the data itself, not so much how to prepare the json structure. Basically, take whatever json structure would be optimal and assume it already exists.

$\endgroup$
4
  • $\begingroup$ How many 'observations' do you have? To 'train' a model to predict this kind of thing you will need a have a fair bit of data that's reasonably balanced. $\endgroup$
    – ralph
    Dec 27 '20 at 5:38
  • $\begingroup$ How many of such data points do I need realistically? The output actually only goes from 1-10 (not 1-100) and I can easily get 1000s if not 10000s of team->rank data points. The number of unique characters is ~70. Level goes from 1-5, around ~50 items. Items aren't randomly distributed, items are better/worse depending on the character they're equipped to. $\endgroup$ Dec 27 '20 at 14:28
  • $\begingroup$ Oh and one more thing: Level is currently a number from 1-5, but in reality a level 5 is much stronger than 5 level 1 versions. Should I normalize this data into a new "strength" value that calculates the actual strength? $\endgroup$ Dec 27 '20 at 14:36
  • $\begingroup$ It's hard to say exactly how much data you'll need. The more data the better - get as much as you possibly can. You don't have to normalise the 'level' variable either. Just treat it as a categorical variable first, then use it as a numeric variable; see which gives the best out of sample performance. Based on what you're tying to achieve I think you should consider an ordered logistic regression model. $\endgroup$
    – ralph
    Dec 27 '20 at 19:45
1
$\begingroup$

This sounds like an interesting problem. Based on what you're trying to achieve, I think you should consider a more classical approach first, rather than diving straight into a neural network. I would consider something like an ordered logistic regression model. This is an extension of logistic regression, handling two or more ordered outcomes.

Since you have your data in a json file, I'd first convert this to a csv. Then load the csv into Python to estimate/train any models. You can then use the data to estimate an ordered logistic regression model. See the Python documentation here.

Your response will be rank (1-10). You can use the characters and items used as predictors. You could also look at interaction terms between the characters and predictors - this is because certain item and character combinations impact the outcome differently. One concern is that this model might become quickly over parameterised. Next you could consider a neural network.

In the neural network, your input nodes will be the characters and items. You'll need to perform a one hot encoding on the rank before you can use it to train the network. Note that you should use a cross entropy loss function, with a softmax activation function on the output layer. It's important to note that this doesn't achieve exactly the same thing as an ordered logistic regression (we're ignoring the fact the outcome is ordered). See this question about setting up a neural network mimic an ordered logistic regression.

$\endgroup$
2
  • $\begingroup$ Thanks a lot for your detailed answer! Interesting that other models aside from machine learning exist. Since I wanted to use this as a means to learn about ML though, I'll try that first. What do I do with duplicate characters though? I can't get it into a consistent shape. However, normalizing the level + duplicates into a new calculated number could work since in the game you're allowed to merge multiple level 1 characters into a "bigger" level 2 one representing them. $\endgroup$ Dec 30 '20 at 20:53
  • $\begingroup$ One approach to dealing with multiple characters (and even items) could be to 'count' them. As a simple example, imagine you have 3 unique characters (A, B and C) and two items (P and Q). Say you pick character A twice and C once, plus item Q twice. Then you'd have the input vector $x = (A,B,C,P,Q)=(2,0,1,0,2)$. Also, is the 'normalisation' process you describe done by the game or by you? If this number represents the effectiveness of the character and item combination, this could also work. $\endgroup$
    – ralph
    Dec 31 '20 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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