# What is the best machine learning algorithm to select best 3 variable combinations?

I have 10 variables as like below

V1=1, V2=2, V3=3, V4=4, V5=5, V6=6, V7=7, V8=8, V9=9 and V10=10

Note : Each variable can have any value

Now I want to select the best 3 variables combination as like below

V1V3V4 or V10V1V7 or V5V3V9 etc.

The best combination is nothing but the sum of the values of 3 variables in the combination.

Example:

Combination 1(V1V2V3) : 1+2+3=> 6

Combination 2(V8V9V10) : 8+9+10=> 27

In the above example Combination 2(V8V9V10) has the highest sum value. So the Combination 2(V8V9V10) is the best combination here.

Like this if I have large amount of variables means which machine learning algorithm selects the best combination in all the sense.

Suggest me the best machine learning algorithm for selecting the best variable combinations. Thanks in advance.

• Genetic algorithms can be treated as machine learning as well. Before it's possible to do the task, some primitives have to be defined for determine the combination and for adding the values. – Manuel Rodriguez Mar 6 '19 at 14:29
• This is not a machine learning question as it is more of a general computer science algorithms question. – juicedatom Mar 6 '19 at 15:35
• If you exactly know the rule to pick these 3, why using a machine learning approach? You could just find the 3 biggest values. Even if the rule was other one, if you know how to score these, you could just make all the combinations posible (which are 120), and find out the best one – freesoul Mar 6 '19 at 15:58
• Thanks for all your suggestions.. I will follow your suggestions to get the output.. Thanks.. – user1999109 Mar 6 '19 at 16:39

What you have is an instance of a local search or black-box optimization problem.

There are many AI algorithms to do this, though as commenters have noted, with only 10 binary variables, you're happier to just look at all 2^10 of them.

If you had, say, 60, then looking at them all is no longer a good idea (2^60 is very large).

The simplest BBO technique is called hill climbing. It looks like this:

1. Pick a random subset of the variables to be true.
2. For each variable, determine the effect of flipping that variable from true to false in the current assignment.
3. Select the 'flip' that leads to the largest value of your function.
4. If the 'flip' has a larger value of your function than the current assignment, GOTO 2.
5. Otherwise, return the current assignment.

This amounts to: 'Pick an assignment at random, then keep making small changes that improve it until you can't anymore. Claim that this is the best solution.'

Clearly, this algorithm will not recover the globally best solution with certainty, but you could run it many times, and eventually, it will find it with high probability.

A complete algorithm, that will always uncover the global optimum, is simulated annealing. This algorithm has a temperature parameter, usually denoted T, which changes according to a temperature schedule. If you start T large 'enough', and decrease it slowly 'enough', then it will find the global optimum. Unfortunately, 'enough' depends a lot on the shape of the function you are optimizing, which you generally cannot observe. There are some common guesses for T, like multiplying it by, e.g. 0.9999 at each step in the search, that seem to work okay in practice.

Both of these algorithms are widely available in packages.

• Thank you very much John Doucette for your valuable answer.. I will check and update to you.. Thanks.. – user1999109 Mar 14 '19 at 2:13