Skip to content

Instantly share code, notes, and snippets.

View reachsumit's full-sized avatar
😃

Sumit Kumar reachsumit

😃
View GitHub Profile
@reachsumit
reachsumit / field_aware_factorization_machine.ipynb
Created November 7, 2022 01:24
Field-Aware Factorization Machines
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reachsumit
reachsumit / factorization_machine.ipynb
Created November 7, 2022 01:20
Factorization Machine
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import pandas as pd
from numpy import bincount, log, log1p
from scipy.sparse import coo_matrix, linalg
class ImplicitCF:
def __init__(self):
self.df = pd.read_csv("lastfm-dataset-360K/usersha1-artmbid-artname-plays.tsv", sep='\t', header=None, names=['user', 'artist', 'plays'], usecols=[0,2,3])
self.df['user'] = self.df['user'].astype("category")
import numpy as np
import pandas as pd
from numpy import bincount, log, log1p
from scipy.sparse import coo_matrix, linalg
class ExplicitCF:
def __init__(self):
self.df = pd.read_csv("ml-100k/u.data", sep='\t', header=None, names=['user', 'item', 'rating'], usecols=range(3))
self.df['user'] = self.df['user'].astype("category")
@reachsumit
reachsumit / fasttext_trained.py
Last active July 19, 2020 06:03
fasttext based spell-checker trained on Peter Norvig's "big.txt" training data
import io
import fasttext
def load_vectors(fname):
fin = io.open(fname, 'r', encoding='utf-8', newline='\n', errors='ignore')
n, d = map(int, fin.readline().split())
data = {}
for line in fin:
tokens = line.rstrip().split(' ')
data[tokens[0]] = map(float, tokens[1:])
@reachsumit
reachsumit / fasttext_pretrained.py
Created July 19, 2020 03:54
spell-check Norvig's test sets using pretrained FastText embeddings
import io
import fasttext
def load_vectors(fname):
fin = io.open(fname, 'r', encoding='utf-8', newline='\n', errors='ignore')
n, d = map(int, fin.readline().split())
data = {}
for line in fin:
tokens = line.rstrip().split(' ')
data[tokens[0]] = map(float, tokens[1:])
@reachsumit
reachsumit / Audio Steganography_ultrasound - receiver.ny
Created June 14, 2018 14:57
This code contains a demo for Audio Steganography. It is to be used by the receiver end, to extract the secret audio embedded within the public audio file.
;; replace the below frequency number with the original frequency used to embed the secret
(mult *track* (hzosc 17500.0))
@reachsumit
reachsumit / Audio Steganography_ultrasound - sender.ny
Last active March 25, 2024 16:06
This code was shared by Audacity user edgar-rft (https://forum.audacityteam.org/memberlist.php?mode=viewprofile&u=5642) to generate silent subliminals and is an implementation of Oliver M. Lowery's 1989 patent (https://patents.google.com/patent/US5159703A/en).
;nyquist plug-in
;version 1
;type process
;name "Subliminal..."
;action "Subliminal..."
;control carrier "Carrier" real "Hz" 17500 14000 20000
(setf carrier (max 14000 (min carrier 20000)))
;; We have two Nyquist frequencies, carrier/2 and *sound-srate*/2.
@reachsumit
reachsumit / Audio Steganography - receiver.py
Created June 14, 2018 14:43
This code contains a demo for Audio Steganography. It is to be used by the receiver end, to extract the secret text embedded in the audio file.
# Use wave package (native to Python) for reading the received audio file
import wave
song = wave.open("song_embedded.wav", mode='rb')
# Convert audio to byte array
frame_bytes = bytearray(list(song.readframes(song.getnframes())))
# Extract the LSB of each byte
extracted = [frame_bytes[i] & 1 for i in range(len(frame_bytes))]
# Convert byte array back to string
string = "".join(chr(int("".join(map(str,extracted[i:i+8])),2)) for i in range(0,len(extracted),8))
@reachsumit
reachsumit / Audio Steganography - sender.py
Last active June 14, 2023 06:33
This code contains a demo for Audio Steganography. It is to be used by sender end to embed text mentioned in string variable to the audio file.
# We will use wave package available in native Python installation to read and write .wav audio file
import wave
# read wave audio file
song = wave.open("song.wav", mode='rb')
# Read frames and convert to byte array
frame_bytes = bytearray(list(song.readframes(song.getnframes())))
# The "secret" text message
string='Peter Parker is the Spiderman!'
# Append dummy data to fill out rest of the bytes. Receiver shall detect and remove these characters.