@@ -136,7 +136,7 @@ def test_with_whitelist(self, dataset: Dataset, filter_viewed: bool, expected: p
136136 pd .DataFrame (
137137 {
138138 Columns .TargetItem : [11 , 11 , 12 , 12 ],
139- Columns .Item : [12 , 15 , 11 , 14 ],
139+ Columns .Item : [12 , 14 , 11 , 14 ],
140140 Columns .Rank : [1 , 2 , 1 , 2 ],
141141 }
142142 ),
@@ -154,10 +154,30 @@ def test_with_whitelist(self, dataset: Dataset, filter_viewed: bool, expected: p
154154 ),
155155 ),
156156 )
157- def test_i2i (
158- self , dataset : Dataset , filter_itself : bool , whitelist : tp .Optional [np .ndarray ], expected : pd .DataFrame
159- ) -> None :
157+ def test_i2i (self , filter_itself : bool , whitelist : tp .Optional [np .ndarray ], expected : pd .DataFrame ) -> None :
160158 base_model = TFIDFRecommender (K = 5 , num_threads = 2 )
159+ # Recreate dataset to prevent same co-occurrence count between (11, 14) and (11, 15)
160+ # which leads to different results in the test in Python 3.13
161+ interactions = pd .DataFrame (
162+ [
163+ [10 , 11 ],
164+ [10 , 12 ],
165+ [10 , 14 ],
166+ [20 , 11 ],
167+ [20 , 12 ],
168+ [20 , 13 ],
169+ [30 , 11 ],
170+ [30 , 12 ],
171+ [30 , 14 ],
172+ [40 , 11 ],
173+ [40 , 15 ],
174+ [40 , 17 ],
175+ ],
176+ columns = Columns .UserItem ,
177+ )
178+ interactions [Columns .Weight ] = 1
179+ interactions [Columns .Datetime ] = "2021-09-09"
180+ dataset = Dataset .construct (interactions )
161181 model = ImplicitItemKNNWrapperModel (model = base_model ).fit (dataset )
162182 actual = model .recommend_to_items (
163183 target_items = np .array ([11 , 12 ]),
0 commit comments