コード例 #1
0
        private void DetectBotsAndSave(UserProfileGathering gath, Dictionary <long, double[]> groupmapping, XGBClassifier xgbc, List <UserGet> users)
        {
            var vectors = users.Select(z => z.ToVector(groupmapping)).ToArray();
            var preds   = xgbc.Predict(vectors);

            _log.Information("Thread {GathId} intended to save {NoBotsUserCount}/{UserCount} accounts", gath.Id, preds.Count(z => z == 0), users.Count);

            var tmp   = new List <UserGet>();
            var isbot = new List <Tuple <int, bool> >();

            for (int usr = 0; usr < users.Count; usr++)
            {
                isbot.Add(new Tuple <int, bool>(users[usr].id, preds[usr] == 1));
                if (preds[usr] == 0)
                {
                    tmp.Add(users[usr]);
                }
            }

            if (isbot.Any())
            {
                _antiBotRepository.SaveUsers(isbot);
            }

            if (tmp.Any())
            {
                _repo.SaveUsers(tmp, DateTime.Now);
            }
        }