Skip to content

Instantly share code, notes, and snippets.

View arjunprakash027's full-sized avatar
🎯
Focusing

Arjun Prakash arjunprakash027

🎯
Focusing
View GitHub Profile
@arjunprakash027
arjunprakash027 / playing_around_reccomender_systems.ipynb
Created September 23, 2023 07:29
A small book reccomender system using python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arjunprakash027
arjunprakash027 / message_queue_redis.py
Last active September 22, 2023 18:41
A python code to implement producer and consumer in async redis queue
import redis
import sys
import time
import json
import random
redis_conn = redis.Redis(host='localhost', port=6379)
def producer():
for i in range(20):
@arjunprakash027
arjunprakash027 / cosine_similarity.rs
Last active September 21, 2023 19:08
A rust code to find cosine similarity between 2 vectors
#[no_mangle]
pub extern "C" fn cosine_similarity(array1:*const i32,array2:*const i32,len: isize) -> f32{
let mut numerator: i32 = 0;
for i in 0..len {
numerator += unsafe { *array1.offset(i) } * unsafe { *array2.offset(i) };
}
let mut x: i32 = 0;
for i in 0..len{
println!("{}",unsafe { *array1.offset(i) } as f32);
@arjunprakash027
arjunprakash027 / task_queue.py
Last active September 20, 2023 17:24
A SIMPLE BACKGROUND TASK QUEUE IMPLEMENTED IN PYTHON
import multiprocessing
import queue
class TaskManager:
def __init__(self):
self.taskq = multiprocessing.Queue()
self.resultq = multiprocessing.Queue()
def worker(self):
while True:
@arjunprakash027
arjunprakash027 / compare_sentences_cosine.py
Last active September 19, 2023 17:50
Compare similarity between 2 sentences using cosine similarity
from gensim.parsing.preprocessing import STOPWORDS
import re
import numpy as np
from numpy.linalg import norm
def find_similarity(x,y):
#print(STOPWORDS)
token_rules = r'\s+|[,\.]'
@arjunprakash027
arjunprakash027 / cosine_similarity.py
Last active September 18, 2023 16:30
A python code to perform cosine similarity
import numpy as np
from numpy.linalg import norm
import math
vector1 = np.array([1, 2])
vector2 = np.array([4, 5])
cosine_similarity = np.dot(vector1,vector2)/(norm(vector1)*norm(vector2))
print("cosine similarity:",cosine_similarity)