Giter Site home page Giter Site logo

[Expand my own dataset?] about cornac HOT 17 CLOSED

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024
[Expand my own dataset?]

from cornac.

Comments (17)

saghiles avatar saghiles commented on August 19, 2024 2

Hi, you can use Cornac's Reader class to load your data. For instance, to read preference data in the triplet format (User_id, Item_id, Rating) one can proceed as follows:

from cornac.data import Reader
reader = Reader()
data = reader.read(fpath, fmt='UIR', sep='\t')

More details in the documentation.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024 1

Hi @ZuoxiYang,
Can you show all your code here so that we can reproduce the issue?

I guess you might need to change rating_threshold=1.0.
That’s what Cornac uses to identify feedback values as positive or negative ones.

Thanks for for your nice reply, it has worked well now. Thanks a lot.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

Hi, you can use Cornac's Reader class to load your data. For instance, to read preference data in the triplet format (User_id, Item_id, Rating) one can proceed as follows:

from cornac.data import Reader
reader = Reader()
data = reader.read(fpath, fmt='UIR', sep='\t')

More details in the documentation.

Thanks for your reply. And does the cornac only can work on the explicit data? When I make it play on the implicit data, it would console that:

Traceback (most recent call last):
File "baseline-cornac.py", line 29, in
exp.run()
File "/python3.6/site-packages/cornac/experiment/experiment.py", line 89, in run
user_based=self.user_based)
File "
/python3.6/site-packages/cornac/eval_methods/base_method.py", line 477, in evaluate
verbose=self.verbose)
File "***/python3.6/site-packages/cornac/eval_methods/base_method.py", line 169, in ranking_eval
avg_results.append(sum(user_results[i].values()) / len(user_results[i]))
ZeroDivisionError: division by zero

How can it work well on the implicit data(the ratings only 1 and 0)

from cornac.

tqtg avatar tqtg commented on August 19, 2024

Hi @ZuoxiYang,
Can you show all your code here so that we can reproduce the issue?

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

Hi @ZuoxiYang,
Can you show all your code here so that we can reproduce the issue?

import cornac
from cornac.data import Reader
reader = Reader()
data = reader.read("./ratings.txt", fmt='UIR', sep='\t')

from cornac.eval_methods import RatioSplit

ratio_split = RatioSplit(data=data, test_size=0.2, rating_threshold=4.0, seed=123)
from cornac.models import MF, PMF, BPR

mf = MF(k=10, max_iter=25, learning_rate=0.01, lambda_reg=0.02, use_bias=True)
pmf = PMF(k=10, max_iter=100, learning_rate=0.001, lamda=0.001)
bpr = BPR(k=10, max_iter=200, learning_rate=0.001, lambda_reg=0.01)
mae = cornac.metrics.MAE()
rmse = cornac.metrics.RMSE()
rec_20 = cornac.metrics.Recall(k=20)
ndcg_20 = cornac.metrics.NDCG(k=20)
auc = cornac.metrics.AUC()

from cornac import Experiment

exp = Experiment(eval_method=ratio_split,
models=[mf, pmf, bpr],
metrics=[mae, rmse, rec_20, ndcg_20, auc],
user_based=True)
exp.run()

from cornac.

tqtg avatar tqtg commented on August 19, 2024

I guess you might need to change rating_threshold=1.0.
That’s what Cornac uses to identify feedback values as positive or negative ones.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

Hi @ZuoxiYang,
Can you show all your code here so that we can reproduce the issue?

I guess you might need to change rating_threshold=1.0.
That’s what Cornac uses to identify feedback values as positive or negative ones.

Thanks for for your nice reply, it has worked well now. Thanks a lot.

I guess you might need to change rating_threshold=1.0.
That’s what Cornac uses to identify feedback values as positive or negative ones.

I guess you might need to change rating_threshold=1.0.
That’s what Cornac uses to identify feedback values as positive or negative ones.

And when I run the "CDR" code:
cdr = CDR(k=10,max_iter=20,learning_rate=0.001,autoencoder_structure=None),

It will console:

Traceback (most recent call last):
File "baseline-cornac-20.py", line 33, in
exp.run()
File "/python3.6/site-packages/cornac/experiment/experiment.py", line 89, in run
user_based=self.user_based)
File "
/python3.6/site-packages/cornac/eval_methods/base_method.py", line 448, in evaluate
model.fit(self.train_set, self.val_set)
File "/python3.6/site-packages/cornac/models/cdr/recom_cdr.py", line 136, in fit
self._fit_cdr()
File "
/python3.6/site-packages/cornac/models/cdr/recom_cdr.py", line 148, in _fit_cdr
text_feature = self.train_set.item_text.batch_bow(np.arange(n_items)) # bag of word feature
AttributeError: 'NoneType' object has no attribute 'batch_bow'

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

I guess you might need to change rating_threshold=1.0.
That’s what Cornac uses to identify feedback values as positive or negative ones.

About the PCRL model, when I run the example code "
pcrl = PCRL(k=100, z_dims=[300], max_iter=300, batch_size=300, learning_rate=0.001, name='pcrl', trainable=True, verbose=False, w_determinist=True, init_params={'G_r': None, 'G_s': None, 'L_r': None, 'L_s': None})", It will console:

self.aux_data = self.train_set.item_graph.matrix[:self.train_set.num_items, :self.train_set.num_items] # item auxiliary information (items'context in the original paper)
AttributeError: 'NoneType' object has no attribute 'matrix'

from cornac.

saghiles avatar saghiles commented on August 19, 2024

Hi @ZuoxiYang, can you share all your code to run either PCRL or CDR ? I suspect this is due to the fact your data doesn't contain any auxiliary information (in addition to the rating data) required for both models, e.g., context information for PCRL, see line 29 in PCRL's example.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

Hi @ZuoxiYang, can you share all your code to run either PCRL or CDR ? I suspect this is due to the fact your data doesn't contain any auxiliary information (in addition to the rating data) required for both models, e.g., context information for PCRL, see line 29 in PCRL's example.

Hi, thanks for your reply. My code is similar to the code I've above(I just add the PCRL code in the previous code). Actually, I do not contain the auxiliary data, is it necessary for the PCRL and CDR? and how to add the auxiliary data, just follow the example https://github.com/PreferredAI/cornac/blob/master/examples/pcrl_example.py? and need I provide the actual auxiliary data?

from cornac.

saghiles avatar saghiles commented on August 19, 2024

PCRL and CDR are designed to work with ratings + some auxiliary information. Therefore if your own dataset doesn't come with the auxiliary information that PCRL and CDR are designed for, you should not consider using these algorithms. In case your data contains the desired auxiliary information then, yes you can just follow PCRL/CDR's examples to incorporate this information.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

PCRL and CDR are designed to work with ratings + some auxiliary information. Therefore if your own dataset doesn't come with the auxiliary information that PCRL and CDR are designed for, you should not consider using these algorithms. In case your data contains the desired auxiliary information then, yes you can just follow PCRL/CDR's examples to incorporate this information.

Thanks a lot. And are there any requirements for the auxiliary information?

from cornac.

saghiles avatar saghiles commented on August 19, 2024

Not sure to understand the question. But if for example we have some dataset with ranting information: (uid, iid, rat) + item graph or network : (iid, iid, 1), then we can use PCRL for example. It really depends on which kind of information our dataset contains.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

Not sure to understand the question. But if for example we have some dataset with ranting information: (uid, iid, rat) + item graph or network : (iid, iid, 1), then we can use PCRL for example. It really depends on which kind of information our dataset contains.

Well, I just want to express: what's format of the auxiliary information? or when I wan to use the auxiliary information, what's format of the auxiliary information should I process for the model?

from cornac.

saghiles avatar saghiles commented on August 19, 2024

That depends on specific models and implementations. The best resources are the models' papers, models' Cornac examples, models' Cornac documentation. For how to work with auxiliary data using Cornac please consider Cornac Modality classes.

from cornac.

ZuoxiYang avatar ZuoxiYang commented on August 19, 2024

That depends on specific models and implementations. The best resources are the models' papers, models' Cornac examples, models' Cornac documentation. For how to work with auxiliary data using Cornac please consider Cornac Modality classes.

Ok, Thanks again.

from cornac.

saghiles avatar saghiles commented on August 19, 2024

Welcome! It seems like the the original issue regarding how one can use his own dataset with Cornac has been solved. Hence, if there is no more question/comment on this specific topic, may I close this issue? Thanks!

from cornac.

Related Issues (20)

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.