Skip to content

Instantly share code, notes, and snippets.

View louislung's full-sized avatar
🖐️
Data Scientist based in Hong Kong

Louis louislung

🖐️
Data Scientist based in Hong Kong
View GitHub Profile
@louislung
louislung / 0_Readme.md
Last active September 30, 2021 11:59
Implement LambdaRank using tensorflow 2.0
@louislung
louislung / 0_Readme.md
Last active June 30, 2022 00:55
Implement Factorised RankNet (speedup version of RankNet) using tensorflow 2.0

Factorised RankNet TensorFlow Implementation

For details please check this blog post

keywords: learning to rank | tensorflow | keras | custom training loop | ranknet | lambdaRank | recommendation

@louislung
louislung / 0_Readme.md
Last active February 8, 2021 08:33
Implement RankNet using tensorflow 2.0 custom training loop

This code is the implementation of RankNet using TensorFlow 2 custom training loop

For details please check this blog post

keywords: learning to rank | tensorflow | keras | custom training loop | ranknet | lambdaRank

@louislung
louislung / 0_readme.md
Last active January 29, 2024 10:37
Keras implementation of RankNet

This gist is the implementation of RankNet using Keras Functional Api

For details please check this blog post.

keywords: learning to rank | tensorflow | keras | custom training loop | ranknet | lambdaRank

from sklearn.feature_extraction.text import CountVectorizer
count_vectorizer = CountVectorizer(min_df=0, max_df=0.99, max_features=10000)
X_train = count_vectorizer.fit_transform(article_contents.main_content.iloc[0:train_row])
X_train = count_vectorizer.inverse_transform(X_train)
with open("uci_train_starspace_formatted.txt", 'w+') as file:
for i in range(train_row):
file.write(' '.join(X_train[i]) + ' ' + label_prefix + Y_train.iloc[i])
file.write('\n')
file.close()