LambdaRank Neural Netwrok model using Keras.
Project description
LambdaRankNN
Python library for training pairwise Learning-To-Rank Neural Network models (RankNet NN, LambdaRank NN).
Supported model structure
It supports pairwise Learning-To-Rank (LTR) algorithms such as Ranknet and LambdaRank, where the underlying model (hidden layers) is a neural network (NN) model.
Installation
pip install LambdaRankNN
Example
Example on a LambdaRank NN model.
import numpy as np
from LambdaRankNN import LambdaRankNN
# generate query data
X = np.array([[0.2, 0.3, 0.4],
[0.1, 0.7, 0.4],
[0.3, 0.4, 0.1],
[0.8, 0.4, 0.3],
[0.9, 0.35, 0.25]])
y = np.array([0, 1, 0, 0, 2])
qid = np.array([1, 1, 1, 2, 2])
# train model
ranker = LambdaRankNN(input_size=X.shape[1], hidden_layer_sizes=(16,8,), activation=('relu', 'relu',), solver='adam')
ranker.fit(X, y, qid, epochs=5)
y_pred = ranker.predict(X)
ranker.evaluate(X, y, qid, eval_at=2)
Converting model to pmml
The trained model can be conveniently converted to pmml, with Python library rankerNN2pmml.
from rankerNN2pmml import rankerNN2pmml
params = {
'feature_names': ['Feature1', 'Feature2', 'Feature3'],
'target_name': 'score'
}
rankerNN2pmml(estimator=ranker.model, file='Model_example.xml', **params)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
LambdaRankNN-0.1.0.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for LambdaRankNN-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c9810a716c218a9362c911907a2ddff82c2345f0c0773ad91c0565580ca281 |
|
MD5 | f3040ee6c0556a3a5b6987930169fa94 |
|
BLAKE2b-256 | 3a7face2cfcd5a989daf12624d7382caf55b6cb7b0433f151065be230bc73545 |