I have a python function that has as an input two variables the so-called current_level and current_affect. The function calculates some rules using training data and those rules can calculating decisions using those two variables the current_level and current_affect. The code contained two lists list_A and list_B. The lists contained the following:
list_A = [["'easy'", "'C'", "'4'", '0.714', '\n'],
["'easy'", "'D'", "'5'", '0.778', '\n'],
["'easy'", "'E'", "'5'", '0.500', '\n'],
["'easy'", "'F'", "'6'", '0.750', '\n']]
list_B = [["'easy'", "'B'", "'2'", '1.000', '\n'],
["'easy'", "'C'", "'3'", '1.000', '\n'],
["'easy'", "'D'", "'4'", '1.000', '\n'],
["'easy'", "'E'", "'5'", '0.875', '\n'],
["'easy'", "'F'", "'6'", '1.000', '\n']]
The first element of the lists correspond to the current_level, the second to the current_affect and the third to the variable score. Therefore what I want is by knowing the input of my method for current_affect to find which of the two lists for this specific case has greater score and return a correspondant value 1 in the case of list_A and -1 for the case of list_B or zero in the equality case. Variable current_affect takes values between A-F. Firstly, how can I add the non-existent current_affect values in my lists. For example list_A is missing levels A and B while list_B is missing level A (I want to add the sublists with zeros) and finally, how can I calculate the return value?
My function is the following:
def association_rules_adaptation(level, current_affect):
Then in the code i have zipped the two lists:
res = zip(list_A,list_B)
Withe the zip I want to link together the two lists regarding the current_affect in order to be able to compare which list has greater score for a specific current_affect. The problem is that when the lists doesn not contained the same exactly values of current_affect I link non-similar things:
(["'easy'", "'C'", "'3'", '0.714', '\n'], ["'easy'", "'B'", "'2'", '1.000', '\n'])
(["'easy'", "'D'", "'4'", '0.778', '\n'], ["'easy'", "'C'", "'3'", '1.000', '\n'])
(["'easy'", "'E'", "'5'", '0.500', '\n'], ["'easy'", "'D'", "'4'", '1.000', '\n'])
(["'easy'", "'F'", "'6'", '0.750', '\n'], ["'easy'", "'E'", "'5'", '0.875', '\n'])
So i want to add all the possible values in my lists in order to be able to link them correctly and then to perform my comparisons.
for row in res:
print (row)
print ("Level", level, ": ", row[0][1])
if (row[0][2] > row[1][2]) or (row[0][2] == row[1][2]):
print ("1")
else:
print ("-1")
EDIT: I want to check which lists are missing and the to add them to lists list_A and list_B, like this:
list_A = [["'easy'", "'A'", "'0'", '0', '\n'], //added sublist
["'easy'", "'B'", "'0'", '0', '\n'], //added sublist
["'easy'", "'C'", "'4'", '0.714', '\n'],
["'easy'", "'D'", "'5'", '0.778', '\n'],
["'easy'", "'E'", "'5'", '0.500', '\n'],
["'easy'", "'F'", "'6'", '0.750', '\n']]
list_B = [["'easy'", "'A'", "'0'", '0', '\n'], //added subilst
["'easy'", "'B'", "'2'", '1.000', '\n'],
["'easy'", "'C'", "'3'", '1.000', '\n'],
["'easy'", "'D'", "'4'", '1.000', '\n'],
["'easy'", "'E'", "'5'", '0.875', '\n'],
["'easy'", "'F'", "'6'", '1.000', '\n']]
Then to zip my lists and perform the comparisons.