I'm trying to create a function that will take in a number of examples and some weights (a weight vector) and then return a single example (an x,y point) where y is classified as +1 or -1 based on the weight vector. In this case, "x" should be a dict (keys being a subset of the keys in weight), the values can be anything that has a nonzero "score" (given the weight vector).
I have some set-up that looks like this:
def getDataset(num_examples, weights):
random.seed(50)
def make_an_example():
x = {}
for i in range(weight):
# update here?
#After updating, I know you would set y = +1 or y = -1, "___" is what I'm not sure goes in:
if ______: y = 1
else: y = -1
return (x,y)
return [make_an_example() for _ in range(num_examples)]
I'm not totally sure what goes "in the middle" - I have tried messing with it but can't get something that works. Any suggestions would be very appreciated. Thank you!
Aucun commentaire:
Enregistrer un commentaire