本文整理汇总了C++中DataBase::totalMovies方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBase::totalMovies方法的具体用法?C++ DataBase::totalMovies怎么用?C++ DataBase::totalMovies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::totalMovies方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: user
void Test::user()
{
DataBase db;
QVERIFY(db.load());
QFETCH(int, user);
QFETCH(int, id);
QList<int> movies;
QList<int> votes;
Movie m_movie(&db);
for (int i = 0; i < db.totalMovies(); ++i) {
m_movie.setId(i + 1);
int x = m_movie.findVote(user);
if (x >= 0) {
movies.append(i + 1);
votes.append(m_movie.score(x));
}
}
User userObject(&db, user);
QCOMPARE(userObject.id(), id);
QCOMPARE(userObject.votes(), votes.count());
userObject.setId(id);
QCOMPARE(userObject.votes(), votes.count());
for (int i = 0; i < votes.count(); ++i) {
int movie = userObject.movie(i);
QVERIFY((bool)(movies.contains(movie)));
int score = userObject.score(i);
QCOMPARE(votes[movies.indexOf(movie)], score);
}
}
示例2: main
int main(int argc, char **argv)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
DataBase db;
db.load();
QFile file("../../download/test.txt");
if (!file.open(QFile::ReadOnly)) {
qWarning() << "Unable to open test file";
return 1;
}
//Probe probe(&db);
Svd *svd = new Svd(&db);
svd->calculateFeatures();
QFile result("../../results.txt");
if (!result.open(QFile::WriteOnly)) {
qWarning() << "can't write";
return 1;
}
QTextStream out(&result);
QTextStream stream(&file);
while (!stream.atEnd()) {
QString line = stream.readLine();
int userid = line.toInt();
User user(&db, userid);
QList<RowAndCount> list;
for (int i = 0; i < db.totalMovies(); ++i) {
//Movie movie(&db, i);
svd->setMovie(i);
double guess = 1.0;
if (/*movie.findVote(userid) != -1) {//*/user.seenMovie(i) == -1) {
guess = svd->determine(userid);
//qDebug() << userid << i << guess;
}
list.append(RowAndCount(i, guess));
}
qSort(list);
list = list.mid(0, 10);
QStringList top10;
foreach(RowAndCount rowAndCount, list) {
int sourceRow = rowAndCount.row;
top10.append(QString("%1").arg(sourceRow));
Q_ASSERT(rowAndCount.count >= 1 && rowAndCount.count <= 5);
//qDebug() << rowAndCount.count;
}
out << /*list[0].count << ":" <<*/ userid << ":" << top10.join(",") << endl;
}
示例3: dataBase
void Test::dataBase()
{
DataBase db;
QCOMPARE(db.rootPath(), QLatin1String("../"));
QCOMPARE(db.isLoaded(), false);
QVERIFY(db.totalVotes() == 0);
QCOMPARE(db.load(), true);
QCOMPARE(db.isLoaded(), true);
QVERIFY(db.totalMovies() > 0);
QVERIFY(db.totalVotes() > 0);
}
示例4: quickdatabase
void Test::quickdatabase()
{
DataBase db;
QVERIFY(db.load());
QuickDatabase iv(&db);
// Quick check a int overflow case
iv.has(479906, 252);
User user(&db, 6);
for (int i = 0; i < db.totalUsers(); i += db.totalUsers() / 10) {
int userNumber = db.mapUser(user.id());
for (int j = 0; j < db.totalMovies(); ++j) {
int m = user.seenMovie(j);
QVERIFY(iv.has(userNumber, j) == (m != -1));
}
user.next();
}
}
示例5: in
void SvdOrder :: loadFeatures(QString filename)
{
QFile in(filename);
in.open(QFile :: ReadOnly);
for (int i = 0; i < currDb->totalMovies(); i++)
{
for (unsigned int j = 0; j < NUM_FEATURES; j++)
{
in.read((char*)&movieFeatures[i][j], sizeof(float));
}
}
for (int i = 0; i < currDb->totalUsers(); i++)
{
for (unsigned int j = 0; j < NUM_FEATURES; j++)
{
in.read((char*)&userFeatures[i][j], sizeof(float));
}
}
}
示例6: out
void SvdOrder :: saveFeatures(QString filename)
{
QFile out(filename);
out.open(QFile :: WriteOnly);
for (int i = 0; i < currDb->totalMovies(); i++)
{
for (unsigned int j = 0; j < NUM_FEATURES; j++)
{
out.write((char*)&movieFeatures[i][j], sizeof(float));
}
}
for (int i = 0; i < currDb->totalUsers(); i++)
{
for (unsigned int j = 0; j < NUM_FEATURES; j++)
{
out.write((char*)&userFeatures[i][j], sizeof(float));
}
}
}
示例7: main
int main(int argc, char *argv[]){
script_timer("Total", false);
if(argv[1] && strstr(argv[1],"deb")!=NULL) debug = true; // Set debug to true if argv[1] contains "deb"
if(debug) fprintf(stderr, "Debug mode on.\n");
if(argv[1] && strstr(argv[1],"off")!=NULL) full_output = false; // Disable full RMSE output if argv[1] contains "off"
DataBase db;
db.load();
if(db.checkDB()) fprintf(stderr, "checkDB OK\n");
else fprintf(stderr, "DB Corrupt.\n");
db.setTitles();
Movie movies(&db);
User users(&db);
movies.setId(1);
users.setId(6);
fprintf(stderr, "db.totalUsers()=%d\n", db.totalUsers());
fprintf(stderr, "db.totalMovies()=%d\n", db.totalMovies());
fprintf(stderr, "db.totalVotes()=%d\n", db.totalVotes());
/*
db.loadPreProcessor("data/somemodel"); // Load a preprocessor built using Algorithm::buildPreProcessor("data/somemodel")
*/
Average avg(&db);
//avg.runProbe();
//avg.runQualifying("none", true);
avg.buildPreProcessor("data_average");
/*
Globals globals(&db);
globals.setAverages(10);
globals.setVariances();
globals.setThetas();
globals.runProbe();
//globals.runQualifying("none", true);
*/
#define TRAIN_SIMU true
Matrix_Factorization *mf = new Matrix_Factorization(&db);
mf->training();
// mf->cache("data_mf_simu");
//mf->runProbe();
//mf->runQualifying("none", true);
mf->buildPreProcessor("data_mf");
// User_KNN * uknn = new User_KNN(&db);
// uknn->setup();
// uknn->loadUserFeatures("data_mf_simu.users.cache");
//uknn->runProbe();
//uknn->runQualifying("none", true);
// uknn->buildPreProcessor("data_uknn");
Blend blend(&db);
// blend.setUp(3, "data_average", "data_mf_simu", "data_uknn");
blend.setUp(2, "data_average", "data_mf");
blend.runProbe();
//blend.runQualifying("none", true);
/*
Blend_Partial blendpartial(&db);
blendpartial.setUp(3, "data/average", "data/mf_simu", "data/uknn");
blendpartial.runProbe_partial();
blendpartial.runQualifying("none", true);
*/
/*
KNN knn(&db);
knn.setup();
knn.runProbe();
E
E
E
knn.runQualifying("none", true);
*/
script_timer("Total", true);
fprintf(stderr, "\n");
print_timer_summary_map();
}