A recommender system toolkit with more maths functions. Currently it's only used to learn and improve about this field, but feel free to participate.
You can find a working example here
A simple implementation would be:
```rust // src/s/company.rs
use recrsys::models::{onehot_encode, ItemAdapter, Item};
pub struct Company { pub id: u32, pub ticker: String, pub sector: String, pub industry: String, pub exchange: String, pub country: String, pub adj: String, pub growth: f32, }
impl ItemAdapter for Company {
fn toitem(&self) -> Item {
Item::new(self.id, self.createvalues(), None)
}
fn createvalues(&self) -> Vec
impl Company {
fn getreferencesquery(&self) -> Result
fn encode_sector(&self) -> Vec<f32> {
let sectors = vec![
"Healthcare",
"Unknown",
"Automotive",
"Technology",
"Communication Services",
"Basic Materials",
"Consumer Cyclical",
"Industrials",
"Financial Services",
"Energy",
"Utilities",
"Real Estate",
"Consumer Defensive",
];
match one_hot_encode(§ors).get(&self.sector) {
Some(val) => val.to_vec(),
None => panic!(),
}
}
// rest of methods ...
} ```
```rust // src/recommendations/company.rs use rec_rsys::{algorithms::knn::KNN, models::Item, similarity::SimilarityAlgos}; use super::models::company::Company;
pub struct Recommendation { prod_id: u32, result: f32, }
fn generaterecommendations(id: u32, numrecommendations: u8) -> Vec
fn calculaterecommendations(
item: Item,
references: Vec
```rust // src/main.rs mod models; mod recommendations;
use recommendations::generate_recommendations;
fn main() { let recs = generate_recommendations(1, 5); } ```
1.- Primordial: - [ ] Fix possible errors in formulas - [ ] Add tests for each formula to be sure that it's correct - [ ] Normalize documentation so is the same everywhere - [X] Create two types of docs. One in separated .md file with extense explanation and math examples. And the second one more for "code use" - [ ] Fix typos - [ ] Add benches for the formulas and overall functions
2.- Nice to have: - [ ] Add more docs in .md related - [ ] Add tests in the docs - [ ] Normalize the results. Either 0 or 1 should represent 100% of similarity depending of the formula - [ ] Convert the results into structs with more information - [ ] Improve the code snippets. (The title can be the method's name) - [ ] Make it async
3.- Final steps: - [ ] Accept incoming data - [ ] Convert incoming data into structs? - [ ] Process data and get rankings - [ ] Check ranking accuracy - [ ] Run multiples algorithms at the same time
4.- Future nice to have: - [ ] Save data and results - [ ] Create some sort of "cache" to avoid multiples recalculations - [ ] Use ndarrays of some sort of efficient sci-library - [ ] Compare the performance and results between Generic types, f32 and f64.
rust
/// # [Name of the concept]
/// [Small explanation of the function]
///
/// ## Parameters:
/// *
[Parameter of the function]`: [Small explanation]
///
/// ## Returns:
/// * [What does the function returns]
///
/// ## Examples:
/// [Examples]
///
pub fn example(){}
In the folder docs/ create a new .md file with the mathematical formula, explanation and examples if necessary.
markdown
[Explanation of the mathematical concept]
$$ [Mathematical formula in raw katex format] $$