Comments (17)
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.
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.
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.
Hi @ZuoxiYang,
Can you show all your code here so that we can reproduce the issue?
from cornac.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
- [FEATURE] Init an evaluation with a predefined global_uid_map and global_iid_map HOT 3
- [FEATURE] Add next-item recommendation models HOT 1
- [FEATURE] There is no model type in table models HOT 2
- [FEATURE] Support for multiple generic FeatureModalities for items HOT 1
- LightGCN/NGCF with cornac.hyperopt HOT 1
- [ASK] Are there any benchmarks considering all models included in cornac? HOT 3
- [ASK] HOT 3
- [FEATURE] Support chronological split for next-basket recommendation HOT 4
- [ASK] Is there a way to find all GPU supported models? HOT 1
- Unable to Install Cornac on Mac HOT 15
- [FEATURE] Allow running evaluation on validation set during training or right after training is done HOT 4
- [BUG] Trirank documentation X&Y HOT 2
- [BUG] Add amazon_digital_music to datasets init HOT 1
- [BUG] Having a failed unit test for SPop
- [BUG] Crash when using cornac with Numpy 2.0 HOT 3
- [BUG] Attribute Error with csr_matrix using Recommender based models HOT 2
- [ASK] Installing Cornac on Mac after Forking the repo lead to ModuleNotFoundError HOT 3
- [ASK] adding user demographics as feature for training HOT 5
- [FEATURE] Categorizing models by supported modalities HOT 2
- [ASK]ModuleNotFoundError: No module named 'cornac.utils.fast_sparse_funcs' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cornac.