py-v0.3.0
·
15 commits
to feature-dynalyst
since this release
Changes
Support negative down sampling rate with argument
ffm.train method now provides nds_rate argument for negative down sampling.
default nds_rate is 1.0.
Add best_va_loss to field
best_va_loss added to field for hyperparameter tuning.
import ffm
def main():
# Prepare the data. (field, index, value) format
X_train = [[(1, 2, 1), (2, 3, 1), (3, 5, 1)],
[(1, 0, 1), (2, 3, 1), (3, 7, 1)],
[(1, 1, 1), (2, 3, 1), (3, 7, 1), (3, 9, 1)], ]
y_train = [1, 1, 0]
X_valid = [[(1, 2, 1), (2, 3, 1), (3, 5, 1)],
[(1, 0, 1), (2, 3, 1), (3, 7, 1)],
[(1, 1, 1), (2, 3, 1), (3, 7, 1), (3, 9, 1)], ]
y_valid = [1, 0, 0]
train_data = ffm.Dataset(X_train, y_train)
valid_data = ffm.Dataset(X_valid, y_valid)
model = ffm.train(train_data, valid_data, quiet=False, nds_rate=0.5)
va_logloss = model.best_va_loss
with open("./model/prod-cvr.model", 'w') as f:
model.dump_model(f)
if __name__ == '__main__':
main()Installation
from source code
$ pip install numpy Cython==3.0a6
$ pip install "git+https://github.com/CyberAgent/libffm.git@py-v0.3.0"
from sdist (source package)
$ pip install numpy
$ pip install https://github.com/CyberAgent/libffm/releases/download/py-v0.3.0/ffm-0.3.0.tar.gz