Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR replaces deprecated SLIM models with SLIM, LightFM, and HybridSlimFM, adds Self return type annotations for method chaining, refines type hints in utilities, and tightens numeric conversion in pandas utilities.
- Refactored model selections in experiments and updated
run_experimentsignature - Updated
fit/bulk_fitmethods across models to returnSelfand added@overridedecorators - Improved type hints (
Optional[List[int]], removed generics forIndexedSet, stricterto_numericbehavior)
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| rtrec/utils/pandas.py | Changed to_numeric to raise on error for stricter validation |
| rtrec/utils/lru.py | Added @override, renamed parameters and updated signatures |
| rtrec/utils/interactions.py | Made select_users/select_items parameters truly optional |
| rtrec/utils/features.py | Removed generic arguments from IndexedSet declarations and fixed type hint on build_item_features_matrix |
| rtrec/tools/kinesis_consumer.py | Swapped out deprecated Fast_SLIM_MSE import for SLIM |
| rtrec/models/slim.py | Added Self return to fit methods for chaining |
| rtrec/models/lightfm.py | Added Self return to bulk_fit and _fit_recorded, silenced type errors on .shape |
| rtrec/models/internal/slim_elastic.py | Tightened return type on .shape properties |
| rtrec/models/hybrid.py | Added Self return to bulk_fit |
| rtrec/experiments/experiments.py | Replaced old model names with new ones and updated fit call |
Comments suppressed due to low confidence (2)
rtrec/utils/lru.py:25
- The parameter name in the docstring (
key) no longer matches the method signature (value). Update the docblock to refer tovaluefor consistency.
key (Any): The key to add or update.
rtrec/experiments/experiments.py:53
- The call to
fitno longer passesepochsorrandom_seed. Verify thatRecommender.fitsignature has been updated accordingly or document this breaking change.
recommender.fit(train_data, batch_size=batch_size)
- Add type hints and annotations across the codebase - Fix return type annotations in the SLIM model - Add proper type handling for matrix operations - Fix dimension checks in matrix operations - Handle potential None values in LightFM wrapper - Improve handling of cold-start users in recommendation pipeline - Add proper error checking for feature vector operations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several updates, including the addition of new models, type annotations, and method return type changes across multiple files. It also includes refactoring for consistency and improved functionality in matrix operations, feature handling, and interaction processing. Below is a summary of the most important changes grouped by theme:
Model Enhancements and Refactoring:
Fast_SLIM_MSEandSLIM_MSEwithSLIM,LightFM, andHybridSlimFMmodels inrtrec/experiments/experiments.py, updating therun_experimentfunction to support these new models. [1] [2]SLIMmodel instead ofFast_SLIM_MSEfor training.Type Annotations and Method Return Types:
Selftype annotation in models (rtrec/models/hybrid.py,rtrec/models/lightfm.py, andrtrec/models/slim.py) and updated methods likebulk_fit,fit, and_fit_recordedto returnselffor method chaining. [1] [2] [3]shapeproperties and feature-building methods, ensuring stricter type definitions. [1] [2]Interaction and Feature Handling:
to_csr,to_csc, andto_coomethods inrtrec/utils/interactions.pyto useOptional[List[int]]for optional parameters, enhancing flexibility and readability. [1] [2] [3]FeatureStoreto remove explicit string type forIndexedSetattributes, allowing for broader use cases.Code Consistency and Cleanup:
@overridedecorators to methods inrtrec/utils/lru.pyto indicate overridden methods from parent classes, improving code clarity. [1] [2]convert_dtypesfunction inrtrec/utils/pandas.pyto raise errors during numeric conversion for stricter data handling.Miscellaneous:
rtrec/experiments/datasets.pyfor better code hygiene.