-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreccomendation.ts
More file actions
74 lines (64 loc) · 1.81 KB
/
Copy pathreccomendation.ts
File metadata and controls
74 lines (64 loc) · 1.81 KB
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
import React from "react";
export default function App() {
//Example profile
const userProfile = {
major: "CS",
interests: ["AI", "Startups", "Robotics"],
tags: ["machine learning", "entrepreneurship"]
};
//Example events for different listservs.
const events = [
{
id: 1,
title: "Intro to AI Workshop",
majorTags: ["CS"],
interestTags: ["AI"],
descriptionTags: ["machine learning"]
},
{
id: 2,
title: "Finance Networking Night",
majorTags: ["Econ"],
interestTags: ["Finance"],
descriptionTags: ["investment banking"]
},
{
id: 3,
title: "Startup Hackathon",
majorTags: ["CS", "Business"],
interestTags: ["Startups"],
descriptionTags: ["entrepreneurship"]
}
];
//Reccomendation algorithm will me fine tuned to match database schema decisions.
function recommendEvents(user, events) {
return events
.map(event => {
let score = 0;
if (event.majorTags.includes(user.major)) score += 3;
const interestMatches = event.interestTags.filter(tag =>
user.interests.includes(tag)
).length;
const tagMatches = event.descriptionTags.filter(tag =>
user.tags.includes(tag)
).length;
score += interestMatches * 2;
score += tagMatches * 2;
return { ...event, score };
})
.filter(event => event.score > 0)
.sort((a, b) => b.score - a.score);
}
const recommended = recommendEvents(userProfile, events);
return (
<div style={{ padding: "20px" }}>
<h2>Recommended Events</h2>
{recommended.map(event => (
<div key={event.id} style={{ marginBottom: "10px" }}>
<strong>{event.title}</strong>
<p>Score: {event.score}</p>
</div>
))}
</div>
);
}