Attachment 'classification.py'
Download 1 import matplotlib.pyplot as plt
2 import numpy as np
3 import random
4
5 # Weights
6 lower = [0.4,0.1,0.1,0.05]
7 upper = [0.7,0.4,0.2,0.3]
8
9 # Weights Exception
10 #lower = [0.,0.,0.,0.05]
11 #upper = [0.7,0.4,0.2,0.9]
12
13 grades = [5, 3, 2, 2]
14 weights = [0,0,0,0]
15
16 idxsort = np.argsort(grades)
17
18 print 'grades', grades
19 print 'idxsort', idxsort
20 weights[idxsort[0]] = lower[idxsort[0]]
21 weights[idxsort[1]] = lower[idxsort[1]]
22 weights[idxsort[3]] = upper[idxsort[3]]
23 weights[idxsort[2]] = 1-weights[idxsort[0]]-weights[idxsort[1]]-weights[idxsort[3]]
24
25 grade = sum(np.multiply(grades,weights))
26 print 'Final grade {:1.2f} +10% {:1.2f} -10% {:1.2f} '.format(grade,1.01*grade,0.9*grade)
27 print 'Weights: ', weights
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.