Giter Site home page Giter Site logo

jfkirk / tensorrec Goto Github PK

View Code? Open in Web Editor NEW
1.3K 63.0 223.0 641 KB

A TensorFlow recommendation algorithm and framework in Python.

License: Apache License 2.0

Python 100.00%
machine-learning tensorflow recommendation-system python recommender-system recommendation-algorithm framework

tensorrec's People

Contributors

jcauteru avatar jfkirk avatar makalaia avatar renepickhardt avatar thosegrapefruits avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorrec's Issues

Importing tests.datasets fails

On a fresh install of tensorrec and tf
tensorflow==1.8.0
tensorrec==0.25.1

(prototype) examples❯ python plot_movielens.py tensorrec/git/master

Traceback (most recent call last):
File "plot_movielens.py", line 16, in
from test.datasets import get_movielens_100k
ImportError: No module named datasets

pulled down the entire repo and am in the examples directory

How to setup proper environment

@jfkirk This is a very interesting project. I try to setup my local environment and run some basic example code. I have following installed:

Python 3.5.5 :: Anaconda, Inc.
Tensorflow 1.4.1
CUDA 8.0
cudnn 6.0

However, I got following error:

Traceback (most recent call last):
  File "tensorrec_example.py", line 15, in <module>
    model.fit(interactions, user_features, item_features, epochs=5, verbose=True)
  File "/home/trend/.conda/envs/py_3.5/lib/python3.5/site-packages/tensorrec/tensorrec.py", line 533, in fit
    n_sampled_items=n_sampled_items)
  File "/home/trend/.conda/envs/py_3.5/lib/python3.5/site-packages/tensorrec/tensorrec.py", line 601, in fit_partial
    self._build_tf_graph(n_user_features=n_user_features, n_item_features=n_item_features)
  File "/home/trend/.conda/envs/py_3.5/lib/python3.5/site-packages/tensorrec/tensorrec.py", line 488, in _build_tf_graph
    self._record_graph_hook_names()
  File "/home/trend/.conda/envs/py_3.5/lib/python3.5/site-packages/tensorrec/tensorrec.py", line 171, in _record_graph_hook_names
    output_classes = hook._output_classes
AttributeError: 'Iterator' object has no attribute '_output_classes'

Any ideas? Thank you!

Consume TFRecords or sparse matrices as input

cc @jcauteru

For training systems at scale, TensorRec should be able to consume TFRecord files as user_features, item_features, and interactions. I think the API should accept those args as:

  1. A string path to a directory with many TFRecords.
  2. A string path to a single TFRecord file.
  3. A file hook to a single TFRecord file.
  4. A scipy sparse matrix (the current input).

Refactor graph components to static methods

Many components of the graph can be taken out of the _build_tf_graph() method and moved to static methods containing chunks of logic. These chunks of logic can be more easily unit tested with dummy input.

Example not working: AttributeError: module 'tensorflow' has no attribute 'data'

For reproducability: I have a clean Anaconda installation and successfully installed tensorflow and tensorrec in the following way via python3.6 in jupyter:

!conda install -y -c conda-forge tensorflow 

olving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.10
  latest version: 4.5.4

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: /Users/rpickhardt/anaconda3

  added / updated specs: 
    - tensorflow


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    mock-2.0.0                 |           py36_0         103 KB  conda-forge
    protobuf-3.5.2             |           py36_0         603 KB  conda-forge
    certifi-2018.1.18          |           py36_0         143 KB  conda-forge
    tensorflow-1.1.0           |           py36_0        24.8 MB  conda-forge
    libprotobuf-3.5.2          |                0         3.9 MB  conda-forge
    pbr-4.0.4                  |             py_0          61 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        29.7 MB

The following NEW packages will be INSTALLED:

    libprotobuf: 3.5.2-0          conda-forge
    mock:        2.0.0-py36_0     conda-forge
    pbr:         4.0.4-py_0       conda-forge
    protobuf:    3.5.2-py36_0     conda-forge
    tensorflow:  1.1.0-py36_0     conda-forge

The following packages will be UPDATED:

    certifi:     2018.1.18-py36_0             --> 2018.1.18-py36_0 conda-forge


Downloading and Extracting Packages
mock 2.0.0: ############################################################ | 100% 
protobuf 3.5.2: ######################################################## | 100% 
certifi 2018.1.18: ##################################################### | 100% 
tensorflow 1.1.0: ###################################################### | 100% 
libprotobuf 3.5.2: ##################################################### | 100% 
pbr 4.0.4: ############################################################# | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

next I did

!pip install tensorrec

Collecting tensorrec
  Downloading https://files.pythonhosted.org/packages/a3/f3/ba53a0c6112df91dbe3cdbf5b008269b3e518afb43d29160341e5a883231/tensorrec-0.25.2.tar.gz
Building wheels for collected packages: tensorrec
  Running setup.py bdist_wheel for tensorrec ... done
  Stored in directory: /Users/rpickhardt/Library/Caches/pip/wheels/40/80/bc/97d2d1f08db563cde3166bf322d9e9433f160bf424bbd31773
Successfully built tensorrec
Installing collected packages: tensorrec
Successfully installed tensorrec-0.25.2
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Both seemed to have worked fine. however running the example from git I get the following stack trace:

Generating positive interactions
Generating negative interactions
Generating user features
Generating item features
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-4d84d711fe05> in <module>()
     13 
     14 # Fit the model for 5 epochs
---> 15 model.fit(interactions, user_features, item_features, epochs=5, verbose=True)
     16 
     17 # Predict scores and ranks for all users and all items

~/anaconda3/lib/python3.6/site-packages/tensorrec/tensorrec.py in fit(self, interactions, user_features, item_features, epochs, learning_rate, alpha, verbose, user_batch_size, n_sampled_items)
    531                          verbose=verbose,
    532                          user_batch_size=user_batch_size,
--> 533                          n_sampled_items=n_sampled_items)
    534 
    535     def fit_partial(self, interactions, user_features, item_features, epochs=1, learning_rate=0.1,

~/anaconda3/lib/python3.6/site-packages/tensorrec/tensorrec.py in fit_partial(self, interactions, user_features, item_features, epochs, learning_rate, alpha, verbose, user_batch_size, n_sampled_items)
    578         # Check if the iterators have been constructed. If not, build them.
    579         if self.tf_interaction_iterator is None:
--> 580             self._build_input_iterators()
    581 
    582         if verbose:

~/anaconda3/lib/python3.6/site-packages/tensorrec/tensorrec.py in _build_input_iterators(self)
    260 
    261     def _build_input_iterators(self):
--> 262         self.tf_user_feature_iterator = create_tensorrec_iterator(name='tf_user_feature_iterator')
    263         self.tf_item_feature_iterator = create_tensorrec_iterator(name='tf_item_feature_iterator')
    264         self.tf_interaction_iterator = create_tensorrec_iterator(name='tf_interaction_iterator')

~/anaconda3/lib/python3.6/site-packages/tensorrec/input_utils.py in create_tensorrec_iterator(name)
     13     :return: tf.data.Iterator
     14     """
---> 15     return tf.data.Iterator.from_structure(
     16             output_types=(tf.int64, tf.int64, tf.float32, tf.int64, tf.int64),
     17             output_shapes=([None], [None], [None], [], []),

AttributeError: module 'tensorflow' has no attribute 'data'

This is strange because according to the tensorflow doc this should work (c.f.: https://www.tensorflow.org/api_docs/python/tf/data/Iterator ) However I double checked at least the python object does indeed not have the field:

import tensorflow as tf
for k in tf.__dict__.keys():
    print(k)

__name__
__doc__
__package__
__loader__
__spec__
__path__
__file__
__cached__
__builtins__
AggregationMethod
Assert
AttrValue
COMPILER_VERSION
ConditionalAccumulator
ConditionalAccumulatorBase
ConfigProto
DType
DeviceSpec
Dimension
Event
FIFOQueue
FixedLenFeature
FixedLenSequenceFeature
FixedLengthRecordReader
GIT_VERSION
GPUOptions
GRAPH_DEF_VERSION
GRAPH_DEF_VERSION_MIN_CONSUMER
GRAPH_DEF_VERSION_MIN_PRODUCER
Graph
GraphDef
GraphKeys
GraphOptions
HistogramProto
IdentityReader
IndexedSlices
InteractiveSession
LogMessage
NameAttrList
NoGradient
NodeDef
NotDifferentiable
OpError
Operation
OptimizerOptions
PaddingFIFOQueue
Print
PriorityQueue
QUANTIZED_DTYPES
QueueBase
RandomShuffleQueue
ReaderBase
RegisterGradient
RunMetadata
RunOptions
Session
SessionLog
SparseConditionalAccumulator
SparseFeature
SparseTensor
SparseTensorValue
Summary
TFRecordReader
Tensor
TensorArray
TensorInfo
TensorShape
TextLineReader
VERSION
VarLenFeature
Variable
VariableScope
WholeFileReader
__compiler_version__
__git_version__
__version__
abs
accumulate_n
acos
add
add_check_numerics_ops
add_n
add_to_collection
all_variables
app
arg_max
arg_min
argmax
argmin
as_dtype
as_string
asin
assert_equal
assert_greater
assert_greater_equal
assert_integer
assert_less
assert_less_equal
assert_negative
assert_non_negative
assert_non_positive
assert_none_equal
assert_positive
assert_proper_iterable
assert_rank
assert_rank_at_least
assert_type
assert_variables_initialized
assign
assign_add
assign_sub
atan
batch_to_space
batch_to_space_nd
betainc
bfloat16
bincount
bitcast
bool
boolean_mask
broadcast_dynamic_shape
broadcast_static_shape
case
cast
ceil
check_numerics
cholesky
cholesky_solve
clip_by_average_norm
clip_by_global_norm
clip_by_norm
clip_by_value
compat
complex
complex128
complex64
concat
cond
confusion_matrix
conj
constant
constant_initializer
container
control_dependencies
convert_to_tensor
convert_to_tensor_or_indexed_slices
convert_to_tensor_or_sparse_tensor
cos
count_nonzero
count_up_to
create_partitioned_variables
cross
cumprod
cumsum
decode_base64
decode_csv
decode_json_example
decode_raw
delete_session_tensor
depth_to_space
dequantize
deserialize_many_sparse
device
diag
diag_part
digamma
div
divide
double
dynamic_partition
dynamic_stitch
edit_distance
einsum
encode_base64
equal
erf
erfc
errors
estimator
exp
expand_dims
expm1
extract_image_patches
eye
fake_quant_with_min_max_args
fake_quant_with_min_max_args_gradient
fake_quant_with_min_max_vars
fake_quant_with_min_max_vars_gradient
fake_quant_with_min_max_vars_per_channel
fake_quant_with_min_max_vars_per_channel_gradient
fft
fft2d
fft3d
fill
fixed_size_partitioner
flags
float16
float32
float64
floor
floor_div
floordiv
floormod
foldl
foldr
gather
gather_nd
get_collection
get_collection_ref
get_default_graph
get_default_session
get_local_variable
get_seed
get_session_handle
get_session_tensor
get_variable
get_variable_scope
gfile
global_norm
global_variables
global_variables_initializer
gradients
graph_util
greater
greater_equal
group
half
hessians
histogram_fixed_width
identity
ifft
ifft2d
ifft3d
igamma
igammac
imag
image
import_graph_def
initialize_all_tables
initialize_all_variables
initialize_local_variables
initialize_variables
int16
int32
int64
int8
invert_permutation
is_finite
is_inf
is_nan
is_non_decreasing
is_numeric_tensor
is_strictly_increasing
is_variable_initialized
layers
lbeta
less
less_equal
lgamma
lin_space
linspace
load_file_system_library
load_op_library
local_variables
local_variables_initializer
log
log1p
logging
logical_and
logical_not
logical_or
logical_xor
losses
make_template
map_fn
matching_files
matmul
matrix_band_part
matrix_determinant
matrix_diag
matrix_diag_part
matrix_inverse
matrix_set_diag
matrix_solve
matrix_solve_ls
matrix_transpose
matrix_triangular_solve
maximum
meshgrid
metrics
min_max_variable_partitioner
minimum
mod
model_variables
moving_average_variables
multinomial
multiply
name_scope
negative
newaxis
nn
no_op
no_regularizer
norm
not_equal
one_hot
ones
ones_initializer
ones_like
op_scope
orthogonal_initializer
pad
parallel_stack
parse_example
parse_single_example
parse_single_sequence_example
parse_tensor
placeholder
placeholder_with_default
polygamma
pow
py_func
python_io
pywrap_tensorflow
qint16
qint32
qint8
qr
quantize_v2
quantized_concat
quint16
quint8
random_crop
random_gamma
random_normal
random_normal_initializer
random_poisson
random_shuffle
random_uniform
random_uniform_initializer
range
rank
read_file
real
realdiv
reciprocal
reduce_all
reduce_any
reduce_join
reduce_logsumexp
reduce_max
reduce_mean
reduce_min
reduce_prod
reduce_sum
register_tensor_conversion_function
report_uninitialized_variables
required_space_to_batch_paddings
reset_default_graph
reshape
resource
resource_loader
reverse
reverse_sequence
reverse_v2
rint
round
rsqrt
saturate_cast
saved_model
scalar_mul
scan
scatter_add
scatter_div
scatter_mul
scatter_nd
scatter_nd_add
scatter_nd_sub
scatter_nd_update
scatter_sub
scatter_update
sdca
segment_max
segment_mean
segment_min
segment_prod
segment_sum
self_adjoint_eig
self_adjoint_eigvals
sequence_mask
serialize_many_sparse
serialize_sparse
set_random_seed
setdiff1d
sets
shape
shape_n
sigmoid
sign
sin
size
slice
space_to_batch
space_to_batch_nd
space_to_depth
sparse_add
sparse_concat
sparse_fill_empty_rows
sparse_mask
sparse_matmul
sparse_maximum
sparse_merge
sparse_minimum
sparse_placeholder
sparse_reduce_sum
sparse_reduce_sum_sparse
sparse_reorder
sparse_reset_shape
sparse_reshape
sparse_retain
sparse_segment_mean
sparse_segment_sqrt_n
sparse_segment_sum
sparse_softmax
sparse_split
sparse_tensor_dense_matmul
sparse_tensor_to_dense
sparse_to_dense
sparse_to_indicator
sparse_transpose
spectral
split
sqrt
square
squared_difference
squeeze
stack
stop_gradient
strided_slice
string
string_join
string_split
string_to_hash_bucket
string_to_hash_bucket_fast
string_to_hash_bucket_strong
string_to_number
substr
subtract
summary
svd
sysconfig
tables_initializer
tan
tanh
tensordot
test
tile
to_bfloat16
to_double
to_float
to_int32
to_int64
trace
train
trainable_variables
transpose
truediv
truncated_normal
truncated_normal_initializer
truncatediv
truncatemod
tuple
uint16
uint8
uniform_unit_scaling_initializer
unique
unique_with_counts
unsorted_segment_max
unsorted_segment_sum
unstack
user_ops
variable_axis_size_partitioner
variable_op_scope
variable_scope
variables_initializer
verify_tensor_all_finite
where
while_loop
write_file
zeros
zeros_initializer
zeros_like
zeta
_LazyContribLoader
contrib

in tensorflow issue tracker in issue 2879 one finds that tf.data has been introduced in tf 1.4 and was named tf.contrib.data before so apparently my tensorflow installation is too old.

indeed prints the same as anaconda installation.

print(tf.__version__)
1.1.0

I will attach a patch of your software in a sec so that it will checked that the proper TensorFlow version is installed.

as a side note upgrading to version 1.4 is not enough because then we get: AttributeError: 'Iterator' object has no attribute '_output_classes' as in #66 where it is stated that tensorflow version 1.7 is mandatory.
actually using tensorflow 1.8. also seems to work just fine.

For anaconda users the following line will fix the issue (for some reason tf 1.7 is not within the conda-froge):

!conda install -y -c conda-forge tensorflow=1.8.0

Item similarity should use the prediction graph

Right now it is implemented as cosine similarity, regardless of the prediction function. Cosine similarity is still meaningful in a dot-product system, but would be meaningless in a euclidian system.

AttributeError: 'Iterator' object has no attribute '_output_classes'

dyld: warning, LC_RPATH $ORIGIN/../../_solib_darwin_x86_64/_U_S_Stensorflow_Spython_C_Upywrap_Utensorflow_Uinternal.so___Utensorflow in /Users/jguajardo/Library/Python/2.7/lib/python/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so being ignored in restricted program because it is a relative path
Generating positive interactions
Generating negative interactions
Generating user features
Generating item features
2018-05-21 20:52:17.596472: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
/Users/jguajardo/Library/Python/2.7/lib/python/site-packages/tensorflow/python/ops/gradients_impl.py:96: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Traceback (most recent call last):
  File "rec.py", line 15, in <module>
    model.fit(interactions, user_features, item_features, epochs=5, verbose=True)
  File "/Users/jguajardo/Library/Python/2.7/lib/python/site-packages/tensorrec/tensorrec.py", line 533, in fit
    n_sampled_items=n_sampled_items)
  File "/Users/jguajardo/Library/Python/2.7/lib/python/site-packages/tensorrec/tensorrec.py", line 601, in fit_partial
    self._build_tf_graph(n_user_features=n_user_features, n_item_features=n_item_features)
  File "/Users/jguajardo/Library/Python/2.7/lib/python/site-packages/tensorrec/tensorrec.py", line 488, in _build_tf_graph
    self._record_graph_hook_names()
  File "/Users/jguajardo/Library/Python/2.7/lib/python/site-packages/tensorrec/tensorrec.py", line 171, in _record_graph_hook_names
    output_classes = hook._output_classes
AttributeError: 'Iterator' object has no attribute '_output_classes'

Is this some weirdness happening because I'm running this on Python 2.7.10?

how to export the model?

Hey James,

It is cool. One quick question, How do we export the model and query it on runtime? Because the best of using user and product feature is that when there is a new user who is not part of training set should also have product scored.

Thanks

Documentation: give more info on the input/output

Hello,

This library seems interesting, however I have a hard time actually using it. I am not quite sure of what the input/output are supposed to be and what is needed to have it working.

For instance I currently have user and items representations, which are both matrices of features. When I run Tensorrec, even with a large number of epoch (ex: 2000) and after training it with interactions between 1 and -1 I get predictions like -2500and 850. In addition, for every given user the predictions of items seems to always be in the same order, even though they have different values (ex: for 3 items and user the prediction could be [[10, 15, 9], [20, 25, 19], [-10, -5, -19]] which seems unlikely to have with a big dataset of user/items/interactions).

I have tried looking at the code but TBH it is not super easy as a first approach of a library to check the code to understand how you are supposed to use it.

I think it would be nice to clarify those points:

  • What is the expected input: should features only be booleans 1/0 or can they be numbers
  • What is the expected output: is it the expected behavior that you can get 1000000?
  • How the application works in general: how can the representation "learn" from its mistakes for instance? My problem right now seems to be that the representation of my users are way too similar (when I use predict_user_representation and reduce n_components to 3 I have the same representation for all users even if their features are very different ) but I don't really have an idea of why and things actually evolve through epochs.

big data out of memory

The model is so easy to get out of memory error if the training data is big. Any suggestion to get around with it? Thanks!

Add shuffle_batch fit arg

Came up in #31

It would be nice to have an arg to re-order the batches every epoch while fitting.

  • Add shuffle_batches arg to fit() and fit_partial() that shuffles the batch order every epoch if True
  • Add tests for the arg

load_model() raising ValueError

Via e-mail from Lukas Brandt Brune:

Now I've been encountered another problem which I hope you could help me with. The problem lies within loading a saved model on another execution. From what I've gathered, tf.train.Saver() needs to be run inside a session and it looks to me that it's not (?). Upon calling load_model from another script I get ValueError: No variables to save.
I've tried calling it as:
TensorRec.load_model(dir_path)
and
model = TensorRec()
model.load_model(dir_path)
Either way, it's the the row 'saver = tf.train.Saver()' which fails every time. 
Would be really thankful if you could give me any pointer in how to proceed from here.

Btw, load_model is kinda the first that's happening in my script, maybe I'm mising to initialize something before?

Implement WARP and BPR losses

Hi,

Extremely thankful to you to implement LightFM on tensorflow. I was wondering if you have any plans to implement WARP and/or BPR losses anytime soon?

Modify WMRB to work on serial predictions

🤦‍♂️

The whole point of WMRB is that it works on a subsample but I went ahead and implemented it by sampling dense predictions, costing huge computation overhead.

Oops.

Equal recommendations for same user features with different actions

I think that with the described architecture a user with the same features but different actions will receive the same recommendations, is this correct?

I understand that there is a use case for this, but I just want to get things clear in my understanding.

The only possibility I see is creating a model per user using his/her specific actions.

Have you think about how to overcome this?

getting error while running test_movielens.py

I am not able to execute test_movielens.py as I am getting below error:
Error
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/Users/sujitmishra/tensorrec/test/test_movielens.py", line 26, in test_movie_lens_fit
epochs=5)
File "/Users/sujitmishra/tensorrec/tensorrec/tensorrec.py", line 533, in fit
n_sampled_items=n_sampled_items)
File "/Users/sujitmishra/tensorrec/tensorrec/tensorrec.py", line 601, in fit_partial
self._build_tf_graph(n_user_features=n_user_features, n_item_features=n_item_features)
File "/Users/sujitmishra/tensorrec/tensorrec/tensorrec.py", line 488, in _build_tf_graph
self._record_graph_hook_names()
File "/Users/sujitmishra/tensorrec/tensorrec/tensorrec.py", line 171, in _record_graph_hook_names
output_classes = hook._output_classes
AttributeError: 'Iterator' object has no attribute '_output_classes'

Help me in fixing this.

How do I save/restore model?

Hello, I'm pretty new to using both python and tensorflow.

From my basic understanding, there should be a way to serialize the trained model and bring it back to train more later.

As I read through tf's session doc, that might be a way to do it. However, I've looked through session_management.py but got no vision of how to achieve this.

Is this possible already? Or, maybe, I missed something?

Values in interaction matrix

Hi jfkirk, thanks for the hard work!

The values in the interaction matrix have to be in (-1, 0, 1) or they can be any integer numbers?

Create Identity Representation Function

For some applications, users or items are already fully embedded and only one side of the representation needs to be learned. An "identity" representation function would be useful in these cases.

Clean up requirements

Requirements should be broken out between main reqs, testing/validation reqs, and reqs for examples.

API for losses, reprs, and predictions should be the same

Loss graph, repr graph, and prediction graph args to TensorRec() should be of the same format.

They should all an instance of their respective abstract superclass. This is because, for some custom graph functions, they may be configurable.

No

Thanks

Add API to retrieve projected user/item biases

Could be useful to examine item biases, for example.

  • Add predict_user_bias and predict_item_bias API method to TensorRec
  • Add hooks to projected_user_biases and projected_item_biases in TensorRec that can be used by the new API and for saving/loading
  • Add tests for the new prediction methods

Add alignment prediction

Alignment would be a special case of dense prediction using normalized vectors. It is equivalent to cosine distance between user and item reprs.

get_book_crossing crashes

I believe all relevant packages are up to date running on python 3.6.5


TypeError Traceback (most recent call last)
in ()
29 train_interactions, test_interactions, user_features, item_features, _ = get_book_crossing(user_indicators=False,
30 item_indicators=True,
---> 31 cold_start_users=True)
32
33 # Establish baseline metrics with random ranks for warm and cold start users

in get_book_crossing(min_positive_score, min_interactions_per_book, user_indicators, item_indicators, cold_start_users, cold_start_items)

/usr/local/lib/python3.6/site-packages/sklearn/pipeline.py in fit_transform(self, X, y, **fit_params)
737 delayed(_fit_transform_one)(trans, weight, X, y,
738 **fit_params)
--> 739 for name, trans, weight in self._iter())
740
741 if not result:

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in call(self, iterable)
777 # was dispatched. In particular this covers the edge
778 # case of Parallel used with an exhausted iterator.
--> 779 while self.dispatch_one_batch(iterator):
780 self._iterating = True
781 else:

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in dispatch_one_batch(self, iterator)
623 return False
624 else:
--> 625 self._dispatch(tasks)
626 return True
627

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in _dispatch(self, batch)
586 dispatch_timestamp = time.time()
587 cb = BatchCompletionCallBack(dispatch_timestamp, len(batch), self)
--> 588 job = self._backend.apply_async(batch, callback=cb)
589 self._jobs.append(job)
590

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/_parallel_backends.py in apply_async(self, func, callback)
109 def apply_async(self, func, callback=None):
110 """Schedule a func to be run"""
--> 111 result = ImmediateResult(func)
112 if callback:
113 callback(result)

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/_parallel_backends.py in init(self, batch)
330 # Don't delay the application, to avoid keeping the input
331 # arguments in memory
--> 332 self.results = batch()
333
334 def get(self):

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in call(self)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
132
133 def len(self):

/usr/local/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in (.0)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
132
133 def len(self):

/usr/local/lib/python3.6/site-packages/sklearn/pipeline.py in _fit_transform_one(transformer, weight, X, y, **fit_params)
579 **fit_params):
580 if hasattr(transformer, 'fit_transform'):
--> 581 res = transformer.fit_transform(X, y, **fit_params)
582 else:
583 res = transformer.fit(X, y, **fit_params).transform(X)

/usr/local/lib/python3.6/site-packages/sklearn/pipeline.py in fit_transform(self, X, y, **fit_params)
281 Xt, fit_params = self._fit(X, y, **fit_params)
282 if hasattr(last_step, 'fit_transform'):
--> 283 return last_step.fit_transform(Xt, y, **fit_params)
284 elif last_step is None:
285 return Xt

TypeError: fit_transform() takes 2 positional arguments but 3 were given

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.