当前位置: 首页>>代码示例>>C++>>正文


C++ DataBase::load方法代码示例

本文整理汇总了C++中DataBase::load方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBase::load方法的具体用法?C++ DataBase::load怎么用?C++ DataBase::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataBase的用法示例。


在下文中一共展示了DataBase::load方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:31,代码来源:autotests.cpp

示例2: main

int main(int numArgs, char ** args)
{
    bool doOrder = true;
    if (numArgs == 2)
    {
        if (!strcmp(args[1], "order"))
            doOrder = true;
        else if (!strcmp(args[1], "rmse"))
            doOrder = false;
        else
        {
            qDebug() << "Argument" << args[1] << "not recognized" << endl;
            qDebug() << "Defaulting to ordering error" << endl;
            doOrder = true;
        } 
    }

    DataBase db;
    db.load();
    Probe probe(&db);
    SvdOrder alg(&db);
    QFile f("Features.dat");

    if (f.exists())
        alg.loadFeatures("Features.dat");
    else
        alg.calculateFeaturesByOrder();

    if (doOrder)
        probe.runProbeOrdering(&alg, "probe");
    else
        probe.runProbe(&alg, "probe");

    alg.saveFeatures("Features.dat");
}
开发者ID:alfador,项目名称:cs156b_team_-,代码行数:35,代码来源:main.cpp

示例3: 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;
    }
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:54,代码来源:main.cpp

示例4: 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);
}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:11,代码来源:autotests.cpp

示例5: userNext

void Test::userNext()
{
    QFETCH(int, start);
    QFETCH(int, next);

    DataBase db;
    QVERIFY(db.load());
    User user(&db, start);
    user.next();
    QCOMPARE(user.id(), next);
}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:11,代码来源:autotests.cpp

示例6: main

int main(int , char **)
{
    DataBase db;
    qDebug() << "Generating data files...";
    db.set_movie_dates = true;
    db.load();
    db.generateMovieDatabase();
//	db.generateProbeDates();
    db.generateQualDates();
    db.setUserDates();
    qDebug() << "Finished generating data files.";
    Dates dates(&db);
    Probe probe(&db);
    qDebug() << "Generating " << QUALIFYINGFILENAME << ".data file...";
    probe.readProbeData(db.rootPath()+"/qualifying.txt");
    return probe.runProbe(&dates);
}
开发者ID:jmgoncalves,项目名称:netflix-pseudonymizer,代码行数:17,代码来源:main.cpp

示例7: movie

void Test::movie()
{
    DataBase db;
    db.load();
    Movie m(&db);
    QFETCH(int, id);
    QFETCH(int, votes);
    QFETCH(int, user);
    QFETCH(int, score);
    m.setId(id);
    QCOMPARE(m.id(), (uint)id);
    QCOMPARE(m.votes(), (uint)votes);
    int voteId = m.findVote(user);
    QVERIFY(voteId != -1);
    QCOMPARE(m.user(voteId), user);
    QCOMPARE(m.score(voteId), score);

}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:18,代码来源:autotests.cpp

示例8: 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();
    }
}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:19,代码来源:autotests.cpp

示例9: 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);
/*
	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->cache_to_text("mf");
	//mf->runProbe();
	//mf->runQualifying("none", true);
	//mf->buildPreProcessor("data/mf_simu");
/*

	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.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();
}
开发者ID:jmgoncalves,项目名称:netflix-pseudonymizer,代码行数:75,代码来源:main_mf.cpp


注:本文中的DataBase::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。