AIMContact::AIMContact( Kopete::Account* account, const QString& name, Kopete::MetaContact* parent, const QString& icon, const Oscar::SSI& ssiItem ) : OscarContact(account, name, parent, icon, ssiItem ) { mProtocol=static_cast<AIMProtocol *>(protocol()); setOnlineStatus( mProtocol->statusOffline ); m_infoDialog = 0L; m_warnUserAction = 0L; mUserProfile=""; m_haveAwayMessage = false; m_mobile = false; // Set the last autoresponse time to the current time yesterday m_lastAutoresponseTime = QDateTime::currentDateTime().addDays(-1); QObject::connect( mAccount->engine(), SIGNAL( receivedUserInfo( const QString&, const UserDetails& ) ), this, SLOT( userInfoUpdated( const QString&, const UserDetails& ) ) ); QObject::connect( mAccount->engine(), SIGNAL( userIsOffline( const QString& ) ), this, SLOT( userOffline( const QString& ) ) ); QObject::connect( mAccount->engine(), SIGNAL( receivedAwayMessage( const QString&, const QString& ) ), this, SLOT( updateAwayMessage( const QString&, const QString& ) ) ); QObject::connect( mAccount->engine(), SIGNAL( receivedProfile( const QString&, const QString& ) ), this, SLOT( updateProfile( const QString&, const QString& ) ) ); QObject::connect( mAccount->engine(), SIGNAL( userWarned( const QString&, Q_UINT16, Q_UINT16 ) ), this, SLOT( gotWarning( const QString&, Q_UINT16, Q_UINT16 ) ) ); QObject::connect( mAccount->engine(), SIGNAL( haveIconForContact( const QString&, QByteArray ) ), this, SLOT( haveIcon( const QString&, QByteArray ) ) ); QObject::connect( mAccount->engine(), SIGNAL( iconServerConnected() ), this, SLOT( requestBuddyIcon() ) ); QObject::connect( this, SIGNAL( featuresUpdated() ), this, SLOT( updateFeatures() ) ); }
bool QgsAtlasComposition::beginRender() { if ( !mCoverageLayer ) { return false; } bool featuresUpdated = updateFeatures(); if ( !featuresUpdated ) { //no matching features found return false; } mRestoreLayer = false; QStringList& layerSet = mComposition->mapRenderer()->layerSet(); if ( mHideCoverage ) { // look for the layer in the renderer's set int removeAt = layerSet.indexOf( mCoverageLayer->id() ); if ( removeAt != -1 ) { mRestoreLayer = true; layerSet.removeAt( removeAt ); } } // special columns for expressions QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) ); QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) ); return true; }
DiscoInfoResponder::DiscoInfoResponder(Swift::IQRouter *router, Config *config) : Swift::GetResponder<DiscoInfo>(router) { m_config = config; m_config->onBackendConfigUpdated.connect(boost::bind(&DiscoInfoResponder::updateFeatures, this)); m_buddyInfo = NULL; m_transportInfo.addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"), CONFIG_STRING(m_config, "identity.category"), CONFIG_STRING(m_config, "identity.type"))); #if HAVE_SWIFTEN_3 crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); #endif updateFeatures(); }
bool QgsLayoutAtlas::beginRender() { if ( !mCoverageLayer ) { return false; } emit renderBegun(); if ( !updateFeatures() ) { //no matching features found return false; } return true; }
bool QgsAtlasComposition::beginRender() { if ( !mCoverageLayer ) { return false; } emit renderBegun(); bool featuresUpdated = updateFeatures(); if ( !featuresUpdated ) { //no matching features found return false; } return true; }
bool QgsAtlasComposition::beginRender() { if ( !mCoverageLayer ) { return false; } bool featuresUpdated = updateFeatures(); if ( !featuresUpdated ) { //no matching features found return false; } // special columns for expressions QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) ); QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) ); return true; }
void AdalineTest::learnTarget(const Vector<double>* targetWeights, Adaline<double>* learner) { int nbUpdate = 0; double threshold = 1e-3; History<double, 5> history; history.fill(threshold); PVector<double> features(targetWeights->dimension()); double target = 0.0f; while (history.getSum() > threshold) { updateFeatures(&features); target = targetWeights->dot(&features); double error = learner->predict(&features) - target; Boundedness::checkValue(error); history.add(std::fabs(error)); learner->learn(&features, target); ++nbUpdate; Assert::assertPasses(nbUpdate < 100000); } Assert::assertPasses(nbUpdate > 30); Assert::assertObjectEquals(target, learner->predict(&features), threshold * 10); }
void DataModel::updateAll() { updateComponents(); updateFeatures(); updateOrthogonalTable(); }
int main(){ // Load Movie data loadMovieData(); // printf("test %f %f %f %f\n", userOffset[5], userOffset[num_users - 1], movieOffset[5], movieOffset[num_movies - 1]); // Set up offsets and implicit data userOffset = calloc(num_users, sizeof(float)); movieOffset = calloc(num_movies, sizeof(float)); userImplicitData = calloc(num_users*2, sizeof(float)); if (userOffset == NULL || movieOffset == NULL || userImplicitData == NULL) { printf("Malloc failed\n"); return -1; } loadData("../stats/user_offset_reg2.dta", userOffset); loadData("../stats/movie_offset_reg.dta", movieOffset); loadUserImplicit("../stats/user_implicit_2.dta", userImplicitData); // Initialize features // Initialize random seed srand (time(NULL)); initializeUserFeatures(); initializeMovieFeatures(); initializeImplicitMovies("../../implicit/user_implicit_movies.dta"); //printf("test %f\n", userImplicitMovies[num_users - 1][2]); initializeImplicitFeatures(); printf("\n--------------Training --------------\n"); int user, movie, line_number; float rating, predict, err; float total_err; for (int i = 1; i <= epochs; i++) { total_err = 0; for (int j = 0; j < num_lines; j++) { line_number = j * 3; user = movie_data[line_number]; movie = movie_data[line_number + 1]; rating = (float)movie_data[line_number + 2]; // printf("User %d Movie %d Rating %d Baseling %f\n", user, movie, rating, baseline); getImplicitC(user); predict = predictRating(user, movie); err = rating - predict; total_err += err * err; updateFeatures(user, movie, err); updateBaseline(user, movie, err); updateImplicitFeatures(user, err); } // Update gammas by factor gamma1 *= gamma_step; gamma2 *= gamma_step; printf("Epoch %d RMSE: %f\n", i, sqrt(total_err / num_lines)); } printf("-----------Saving features-----------\n"); saveOffsets(); saveUserFeatures("f010_e020/user_features.dta"); saveMovieFeatures("f010_e020/movie_features.dta"); saveImplicitFeatures("f010_e020/implicit_features.dta"); free(userOffset); free(movieOffset); free(movie_data); return 0; }
int main(){ // Load Movie data loadMovieData(); // printf("test %f %f %f %f\n", userOffset[5], userOffset[num_users - 1], movieOffset[5], movieOffset[num_movies - 1]); // Set up offsets and implicit data userOffset = calloc(num_users, sizeof(float)); movieOffset = calloc(num_movies, sizeof(float)); userImplicitData = calloc(num_users*2, sizeof(float)); if (userOffset == NULL || movieOffset == NULL || userImplicitData == NULL) { printf("Malloc failed\n"); return -1; } //loadData("../stats/user_offset_reg2.dta", userOffset); //loadData("../stats/movie_offset_reg.dta", movieOffset); loadUserImplicit("../stats/user_implicit_2.dta", userImplicitData); // Initialize features // Initialize random seed srand (time(NULL)); initializeUserFeatures(); initializeMovieFeatures(); initializeImplicitMovies("../../implicit/user_implicit_movies.dta"); //printf("test %f\n", userImplicitMovies[num_users - 1][2]); initializeImplicitFeatures(); printf("\n--------------Training --------------\n"); unsigned int user, movie, rating, line_number; unsigned int temp = 0; float err, feature_c; float train_err, val_err; train_errs = calloc(epochs, sizeof(float)); float n = userImplicitData[1*2 + 1]; // get n for first user float GLOBAL_AVG = 3.609516; for (unsigned int i = 1; i <= epochs; i++) { train_err = 0; val_err = 0; for (unsigned int j = 0; j < num_lines; j++) { line_number = j * 3; user = movie_data[line_number]; movie = movie_data[line_number + 1]; rating = movie_data[line_number + 2]; // Get rating from raw data if we have a new user if (temp != user) { // update implict feature for previous user if (temp > 0) { updateImplicitFeatures(temp, n); } n = userImplicitData[user*2 + 1]; getImplicitC(user, n); //baseline_c = userOffset[user] + movieOffset[movie]; temp = user; // if (user == 34821) { // printf("user %d err %f n %f implicitC %f tempC %f\n", user, total_err, n, implicitC[0], tempImplicitC[0]); // printf("base %f\n", baseline_c); // } } feature_c = 0; for (unsigned int i = 0; i < num_features; i++) { feature_c += (userFeatures[user][i] + tempImplicitC[i])* movieFeatures[movie][i]; } err = (float) rating - (GLOBAL_AVG + userOffset[user] + movieOffset[movie] + feature_c); //printf("err %f rating %d predict %f baseline_c %f feature_c %f\n", err, rating, GLOBAL_AVG + baseline_c + feature_c, baseline_c, feature_c); // if (idx[j] == 4) { // val_err += err * err; // } train_err += err * err; updateFeatures(user, movie, err, n); updateBaseline(user, movie, err); } // update last user updateImplicitFeatures(user, n); // Update gammas by factor gamma1 *= gamma_step; gamma2 *= gamma_step; train_errs[i-1] = sqrt(train_err / num_lines); printf("Epoch %d Train RMSE: %f\n", i, train_errs[i-1]); } printf("-----------Saving features-----------\n"); saveOffsets(); saveUserFeatures("features/f220_e050/user_features.dta"); saveMovieFeatures("features/f220_e050/movie_features.dta"); saveImplicitFeatures("features/f220_e050/implicit_features.dta"); saveErrors("features/f220_e050/error.dta"); free(userOffset); free(movieOffset); free(movie_data); return 0; }
void OpenNIUser::update() { if (trackingEnabled) { updateFeatures(); } }