Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature elements/vectors should only be accessed via iteratiors #3785

Open
karlnapf opened this issue Apr 24, 2017 · 5 comments
Open

Feature elements/vectors should only be accessed via iteratiors #3785

karlnapf opened this issue Apr 24, 2017 · 5 comments

Comments

@karlnapf
Copy link
Member

Algorithm code should never explicitly touch feature vectors/strings etc. Instead it should use an API for doing operation on iterators (that support various ways of accessing data)

The main idea is that rather than doing

for i in 1....
  vec = features->get_feature_vector(...)
  a+=dot(vec, w)

we do

auto iterator = f->get_dot_iterator();
while (not stopped and iterator.has_more())
    a+=iterator.dot(w);  

See https://gist.github.com/lisitsyn/a6d8ff6e8690431f967c5318c3750919 for more details.

This task is to

  • Add a reasonable feature iterator interface to features. Start with one class and one algorithm.
  • Extend from here
  • Eventually, features should never be accessed via get_feature_vector(index_t) or otherwise

Make sure to extensively talk to @lisitsyn when doing this

@bhavukkalra
Copy link
Contributor

@lisitsyn @karlnapf is this fixed?
could you guide me to the code files that the above reference txt file is referencing to i.e
https://gist.github.com/lisitsyn/a6d8ff6e8690431f967c5318c3750919
also is that the case with each algorithm implemented or could you guide me to specific one's..
would be really helpful.
Thanks.

@vigsterkr
Copy link
Member

@bhavukkalra it's not fixed in the whole codebase. you can git grep DotIterator and see how it is used in some parts of the code.

@bhavukkalra
Copy link
Contributor

Yup, I found them.
could you please guide me to the API that you were suggesting @vigsterkr .
also just for clarification about the problem statement
We need to store the iterator variable in a temporary variable and iterate through it in the algorithm code(not touching the features) , just iterating.

@vigsterkr
Copy link
Member

i'm not so sure what you are looking for. there's an api description of DotIterator as well as if you have found where it is being used you'll see how that api is actually being used in a working code

@bhavukkalra
Copy link
Contributor

bhavukkalra commented Mar 15, 2020

shogun/src/shogun/features/iterators/DotIterator.h
shogun/src/shogun/features/iterators/DotIterator.cpp
these ones?
Sorry, My bad,got confused with the term API above thought there might a query that could be made to get iterator features.
got it now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants