-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestit.py
107 lines (87 loc) · 4.1 KB
/
testit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# test the TopicRecommender
import kiprec.TopicRecommender as tr
meta_categories = ['IT', 'Business', 'Health']
course_data = []
course_data.append({'course_id': 1,
'name': 'Python for Data Science',
'categories': ['data_science_programming'],
'tags': ['Python', 'Data Science'],
'attributes': {'duration': '4 weeks',
'badges': 'yes',
'certificate': 'A',
'price': 'free',
'type': 'mooc_course'
}
})
course_data.append({'course_id': 2,
'name': 'Python for Business',
'categories': ['business_programming'],
'tags': ['Python'],
'attributes': {'duration': '2 months',
'badges': 'no',
'certificate': 'C',
'price': '100 EUR',
'type': 'blended_course'
}
})
course_data.append({'course_id': 3,
'name': 'Python for Health',
'categories': ['it_in_medicine'],
'tags': ['Python'],
'attributes': {'duration': '2 months',
'badges': 'no',
'certificate': 'A',
'price': '50 EUR',
'type': 'blended_course'
}
})
course_data.append({'course_id': 4,
'name': 'Python for Business and Health',
'categories': ['business_programming', 'it_in_medicine'],
'tags': ['Python'],
'attributes': {'duration': '4 weeks',
'badges': 'no',
'certificate': 'A',
'price': 'free',
'type': 'blended_course'
}
})
enrollment_data = []
enrollment_data.append({'student_id': 1,
'enrolments': [{'course_id': 1,
'date': '2021-10-01'},
{'course_id': 2,
'date': '2020-01-01'}
]
})
enrollment_data.append({'student_id': 2,
'enrolments': [{'course_id': 1,
'date': '2018-03-07'},
{'course_id': 3,
'date': '2021-09-30'}
]
})
enrollment_data.append({'student_id': 3,
'enrolments': [{'course_id': 2,
'date': '2021-10-01'},
{'course_id': 3,
'date': '2021-10-01'}
]
})
# create category similarity object
print("TopicRecommender test:")
recommender = tr().train(meta_categories, course_data)
print(recommender.model)
print(recommender.recommend(course_data, {'IT': 0.2, 'Business': 0.6, 'Health': 0.3}))
#--------------------------------------------------------------------------------------------
# test the PreferenceBasedRecommender
print("PreferenceBasedRecommender test:")
import kiprec.PreferenceBasedRecommender as pbr
recommender = pbr().train(meta_categories, course_data, enrollment_data)
print(recommender.model)
filters, features, courses, split_index = recommender.recommend({'IT': 0.2, 'Business': 0.6, 'Health': 0.3},
{'duration': '4 weeks','price': 'free'})
[print(f) for f in filters]
print(features)
[print(c) for c in courses]
print(split_index)