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

如何标记正负样本 #22

Open
zscwind opened this issue Mar 20, 2019 · 1 comment
Open

如何标记正负样本 #22

zscwind opened this issue Mar 20, 2019 · 1 comment

Comments

@zscwind
Copy link

zscwind commented Mar 20, 2019

嗨,您好。请问正负样本是如何标记的呢?
    for key in user_map:
    sorted_user_bh = sorted(user_map[key], key=lambda x:x[1])
    for line, t in sorted_user_bh:
        items = line.split("\t")
        asin = items[1]
        j = 0
        while True:
            asin_neg_index = random.randint(0, len(item_list) - 1)
            asin_neg = item_list[asin_neg_index]
            if asin_neg == asin:
                continue 
            items[1] = asin_neg
            print>>fo, "0" + "\t" + "\t".join(items) + "\t" + meta_map[asin_neg]
            j += 1
            if j == 1:             #negative sampling frequency
                break
        if asin in meta_map:
            print>>fo, "1" + "\t" + line + "\t" + meta_map[asin]
        else:
            print>>fo, "1" + "\t" + line + "\t" + "default_cat"

看这段代码,负样本是随机生成的?

@zscwind
Copy link
Author

zscwind commented Mar 20, 2019

@mouna99 可以详解一下样本的构造过程吗?

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

1 participant