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

One problem reveals when I rerun the program #10

Open
tyhmas opened this issue Jun 7, 2019 · 6 comments
Open

One problem reveals when I rerun the program #10

tyhmas opened this issue Jun 7, 2019 · 6 comments

Comments

@tyhmas
Copy link

tyhmas commented Jun 7, 2019

Hi Dawen,

I am writing to ask if you ever had the following error when you implemented your program, which is shown in the snapshot attached with this message. This error came out after I converted your Jupyter notebook file into a python file named old_code.py and tried to run it.

After filtering, there are 9990682 watching events from 136677 users and 20720 movies (sparsity: 0.353%)
0 users sampled
1000 users sampled
2000 users sampled
3000 users sampled
4000 users sampled
5000 users sampled
6000 users sampled
7000 users sampled
8000 users sampled
9000 users sampled
0 users sampled
1000 users sampled
2000 users sampled
3000 users sampled
4000 users sampled
5000 users sampled
6000 users sampled
7000 users sampled
8000 users sampled
9000 users sampled
Traceback (most recent call last):
File "old_code.py", line 250, in
train_data = numerize(train_plays)
File "old_code.py", line 244, in numerize
return pd.DataFrame(data={'uid': uid, 'sid': sid}, columns=['uid', 'sid'])
File "C:\Software\Anaconda\lib\site-packages\pandas\core\frame.py", line 348, in init
mgr = self._init_dict(data, index, columns, dtype=dtype)
File "C:\Software\Anaconda\lib\site-packages\pandas\core\frame.py", line 439, in _init_dict
index = extract_index(arrays[~missing])
File "C:\Software\Anaconda\lib\site-packages\pandas\core\frame.py", line 7349, in extract_index
raw_lengths.append(len(v))
TypeError: object of type 'map' has no len()

Apologize for such inconvenience and thank you for your attention meanwhile! :)

@shrawansapre
Copy link

shrawansapre commented Jun 7, 2019

I got a similar error because I was using Python 3 to execute the code.

To rectify it, I changed the numerize function to:

def numerize(tp):

    uid = [profile2id[x] for x in tp['userId']]

    sid = [show2id[x] for x in tp['movieId']]

    return pd.DataFrame(data={'uid': uid, 'sid': sid}, columns=['uid', 'sid'])

You can try using the above function and let me know if it works for you! All the best!

@tyhmas
Copy link
Author

tyhmas commented Jun 10, 2019

I got a similar error because I was using Python 3 to execute the code.

To rectify it, I changed the numerize function to:

def numerize(tp):

    uid = [profile2id[x] for x in tp['userId']]

    sid = [show2id[x] for x in tp['movieId']]

    return pd.DataFrame(data={'uid': uid, 'sid': sid}, columns=['uid', 'sid'])

You can try using the above function and let me know if it works for you! All the best!

It works my problem fine, there are bugs for me to keep on going though. Thank you!

@shrawansapre
Copy link

There are many changes to make if you are using Python 3. All the best!

@karthikraja95
Copy link

@shrawansapre Do you have the python 3.5+ file for this repo. If so could you share that. I am struggling to make it work on python 3.5+.

Thanks

@LaurynasGiriunas
Copy link

def numerize(tp):
uid = map(lambda x: profile2id[x], tp['userId'])
sid = map(lambda x: show2id[x], tp['movieId'])
return pd.DataFrame(data={'uid': [uid], 'sid': [sid]}, columns=['uid', 'sid'])

This looks to give an error later on

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

No branches or pull requests

5 participants
@shrawansapre @tyhmas @LaurynasGiriunas @karthikraja95 and others