Code Monkey home page Code Monkey logo

all2vec's People

Stargazers

 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

all2vec's Issues

can't pickle AnnoyIndex objects

In Python 3.6 this throws an error "TypeError: can't pickle AnnoyIndex objects":

from all2vec import EntitySet
t = EntitySet(2)
t.create_entity_type(entity_type_id=0, entity_type='test', ntrees=1)
t.add_item(0, 0, [0,0])
t.build()
t.save('test_all2vec_model')

The error is thrown at line 254:

252         pickle_filepath = os.path.join(folder, 'object.pickle')
253         with open(pickle_filepath, 'wb') as handle:
254             dill.dump(self, handle)
255         files.append(pickle_filepath)
256 

I have these versions installed:

all2vec==0.6.0
annoy==1.8.3

sorting

Any reason why get_similar_vector sorts by score prior to returning the list while get_scores_vector doesn't?

Error when requesting a very large number of responses

get_similar('user', user, 'product', 100000000)
returns

all2vec/__init__.py in get_similar(self, entity_type, entity_id, match_type, num_similar, oversample, normalize)
    168         match_vector = self.get_vector(entity_type, entity_id)
    169         return self.get_similar_vector(
--> 170             match_vector, match_type, num_similar, oversample, normalize)
    171
    172     def get_scores_vector(self, vector, match_type, match_id_array, normalize):

all2vec/__init__.py in get_similar_vector(self, match_vector, match_type, num_similar, oversample, normalize)
    156
    157         similar_items = self._annoy_objects[match_type].get_nns_by_vector(
--> 158             match_vector, num_similar, search_k)
    159         # compute inner products, and sort
    160         scores = self.get_scores_vector(

all2vec/__init__.py in get_nns_by_vector(self, vec, n, search_k)
     67         """Get nearest neighbors from an input vector."""
     68         nns = self._ann_obj.get_nns_by_vector(vec, n, search_k)
---> 69         return [self._ann_map_inv[x] for x in nns]
     70
     71     def get_item_vector(self, entity_id):

TypeError: 'NoneType' object is not iterable

Digging deeper, it looks like all2vec is not properly capturing this ANNOY error

> u.get_nns_by_vector([1] * num_dimensions, 100000000, search_k = 100000000 * 100)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
OverflowError: signed integer is greater than maximum

This error will come up whenever n or search_k is larger than the maximum integer.

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.