4
$\begingroup$

I am trying to "grow" my own SubsetQ function using Machine Learning methods. My cSubsetQ when given two lists (listA and listB) as Inputs should return True if listA is a subset of listB and False if not.

The plan is to give it enough examples of inputs and outputs to train it on.

Here is my failed attempt:

cSubsetQ = Classify[
{
 {{}, {a, b, c, d, e}} -> True, 
 {{a}, {a, b, c, d, e}} -> True, 
 {{b}, {a, b, c, d, e}} -> True, 
 {{c}, {a, b, c, d, e}} -> True,
 {{d}, {a, b, c, d, e}} -> True, 
 {{e}, {a, b, c, d, e}} -> True, 
 {{a, b}, {a, b, c, d, e}} -> True, 
 {{a, c}, {a, b, c, d, e}} -> True, 
 {{a, d}, {a, b, c, d, e}} -> True, 
 {{a, e}, {a, b, c, d, e}} -> True, 
 {{b, c}, {a, b, c, d, e}} -> True, 
 {{b, d}, {a, b, c, d, e}} -> True, 
 {{b, e}, {a, b, c, d, e}} -> True, 
 {{c, d}, {a, b, c, d, e}} -> True, 
 {{c, e}, {a, b, c, d, e}} -> True, 
 {{d, e}, {a, b, c, d, e}} -> True, 
 {{a, b, c}, {a, b, c, d, e}} -> True, 
 {{a, b, d}, {a, b, c, d, e}} -> True, 
 {{a, b, e}, {a, b, c, d, e}} -> True, 
 {{a, c, d}, {a, b, c, d, e}} -> True, 
 {{a, c, e}, {a, b, c, d, e}} -> True, 
 {{a, d, e}, {a, b, c, d, e}} -> True, 
 {{b, c, d}, {a, b, c, d, e}} -> True, 
 {{b, c, e}, {a, b, c, d, e}} -> True, 
 {{b, d, e}, {a, b, c, d, e}} -> True, 
 {{c, d, e}, {a, b, c, d, e}} -> True, 
 {{a, b, c, d}, {a, b, c, d, e}} -> True, 
 {{a, b, c, e}, {a, b, c, d, e}} -> True, 
 {{a, b, d, e}, {a, b, c, d, e}} -> True, 
 {{a, c, d, e}, {a, b, c, d, e}} -> True, 
 {{b, c, d, e}, {a, b, c, d, e}} -> True, 
 {{a, b, c, d, e}, {a, b, c, d, e}} -> True,
 {{a, b, c, d, e}, {}} -> False,
 {{a, b, c, d, e}, {a}} -> False, 
 {{a, b, c, d, e}, {b}} -> False, 
 {{a, b, c, d, e}, {c}} -> False, 
 {{a, b, c, d, e}, {d}} -> False,    
 {{a, b, c, d, e}, {e}} -> False, 
 {{a, b, c, d, e}, {a, b}} -> False,
 {{a, b, c, d, e}, {a, c}} -> False,
 {{a, b, c, d, e}, {a, d}} -> False, 
 {{a, b, c, d, e}, {a, e}} -> False, 
 {{a, b, c, d, e}, {b, c}} -> False, 
 {{a, b, c, d, e}, {b, d}} -> False,
 {{a, b, c, d, e}, {b, e}} -> False,
 {{a, b, c, d, e}, {c, d}} -> False,
 {{a, b, c, d, e}, {c, e}} -> False, 
 {{a, b, c, d, e}, {d, e}} -> False,
 {{a, b, c, d, e}, {a, b, c}} -> False,
 {{a, b, c, d, e}, {a, b, d}} -> False,
 {{a, b, c, d, e}, {a, b, e}} -> False,
 {{a, b, c, d, e}, {a, c, d}} -> False,
 {{a, b, c, d, e}, {a, c, e}} -> False,
 {{a, b, c, d, e}, {a, d, e}} -> False, 
 {{a, b, c, d, e}, {b, c, d}} -> False, 
 {{a, b, c, d, e}, {b, c, e}} -> False, 
 {{a, b, c, d, e}, {b, d, e}} -> False, 
 {{a, b, c, d, e}, {c, d, e}} -> False, 
 {{a, b, c, d, e}, {a, b, c, d}} -> False, 
 {{a, b, c, d, e}, {a, b, c, e}} -> False, 
 {{a, b, c, d, e}, {a, b, d, e}} -> False, 
 {{a, b, c, d, e}, {a, c, d, e}} -> False, 
 {{a, b, c, d, e}, {b, c, d, e}} -> False
}]

The Classify command fails to generalize from my training set.

How would I make a good enough training set to make this work? What would the training set look like?

How can I represent a list and a subset more generally?

I would be grateful for some pointers or advice. Feel free to edit this. Guidance on how to approach this or pose the question better would be nice:)

–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Note: My attempt replicates this example of Classify in the documentation:

c = Classify[{
              {1.5, Blue}  -> "A", 
              {3.2, Blue}  -> "A", 
              {4.1, Red}   -> "B", 
              {5.3, Red}   -> "B",
              {10., Green} -> "C", 
              {12.4, Red}  -> "C"
             }]

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ First thing to note is that you get three classes instead of two (eg. true, false), because a comma is missing in your list of examples. $\endgroup$
    – gwr
    Jan 30, 2016 at 17:51
  • $\begingroup$ I don't even know if classifying symbols is that great of an idea. I am unsure as how mathematica will handle it. More examples always helps with classification so you can use SubsetQ on randomly generalized sequences and feed it to Classify $\endgroup$ Aug 25, 2016 at 18:37

0

Your Answer

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