No project description provided
Project description
tf2-fm-zoo
Python package for the factorization machine implementations from tensorflow2_model_zoo.
Acknowledgement
The original implementation for the methods in this repo were done by Ren Zhang who kindly granted permission to use his code for the creation of the package.
Installation
pip install tf2_fm_zoo
Basic Example
import tensorflow as tf
import numpy as np
import pandas as pd
from sklearn.preprocessing import KBinsDiscretizer
from sklearn.datasets import load_boston
from fm_zoo.fm import FactorizationMachine
X, y = load_boston(return_X_y=True)
X = X[:,:3]
y = tf.cast(y, dtype=tf.float32)
kbd = KBinsDiscretizer(n_bins=15, encode="ordinal")
nunique_vals = pd.DataFrame(X).nunique()
X = tf.cast(kbd.fit_transform(X), dtype=tf.int64)
fm = FactorizationMachine(
feature_cards=tf.cast(nunique_vals, tf.int32),
factor_dim=3)
fm.compile(loss=tf.keras.losses.mean_squared_error, optimizer="Adam")
hist = fm.fit(
X, y,
validation_split=0.15,
batch_size=16,
epochs=100,
callbacks=[
tf.keras.callbacks.EarlyStopping(patience=10, restore_best_weights=True)
])
pd.DataFrame(hist.history).plot(figsize=(15,10))
Supported Models
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
tf2_fm_zoo-0.1.1.tar.gz
(8.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tf2_fm_zoo-0.1.1.tar.gz.
File metadata
- Download URL: tf2_fm_zoo-0.1.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d0b91380e1f790aa4588e4b1b39f424b6867e0ed6177d9ea7a3e815f6af1292
|
|
| MD5 |
7745f28a0cdad5b6c8fc20eb3aff0171
|
|
| BLAKE2b-256 |
92b05c732453511046532ac6cb5d6784c54737df79c60361cb516dd1f5f704b6
|
File details
Details for the file tf2_fm_zoo-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tf2_fm_zoo-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
599a616a394e2d4bb5adfa0d533e6c0ace94f2e4761be83ac2c3fb022f8cde3c
|
|
| MD5 |
d247d57d3749ed192a9ee7609f246b2d
|
|
| BLAKE2b-256 |
da138221526da16f1f0bf403598603727173544b3d834795d0f3a50f48c1107b
|