I have a python function that has the so-called current_level and current_affect as input two variables . The function calculates some rules using training data, and these rules can calculate decisions using these two variables: current_level and current_affect . The code contained two lists list_A and list_B . The lists included 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 list corresponds to current_level , the second to current_affect , and the third to the score variable . Therefore, I want to know how to introduce my method for current_affect , to find which of the two lists for this particular case has a higher score and returns the corresponding value 1 in the case of list_A and -1 for the case list_B or zero in case of equality. The variable current_affect takes values between AF. First, how can I add nonexistent current_affect values to my lists. For example, list_A is missing levels A and B, while list_B is missing level A (I want to add sublists with zeros) and finally, how can I calculate the return value?
My function is this:
def association_rules_adaptation(level, current_affect):
:
res = zip(list_A,list_B)
zip. current_affect, , current_affect. , current_affect, :
(["'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'])
, , , .
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: , , list_A list_B, :
list_A = [["'easy'", "'A'", "'0'", '0', '\n'],
["'easy'", "'B'", "'0'", '0', '\n'],
["'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'],
["'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']]
, .