コード例 #1
0
        public float[][] GetTrainData()
        {
            //List<Profile> profiles = Profile.GetAll();
            int profileCount  = Profiles.Count();
            int questionCount = Questions.Count();

            //using (SQLiteConnection connection = new SQLiteConnection(App.DatabaseLocation))
            //{
            //    profiles = connection.Table<Profile>().ToList();
            //    Profiles = new ObservableCollection<Profile>(profiles as List<Profile>);
            //}

            //1 sample by candidate
            float[][] ret = new float[profileCount][];
            for (int i = 0; i < profileCount; i++)
            {
                //number of features equal to number of questions
                //+1 for the class attributed to this train sample
                ret[i] = new float[questionCount + 1];
                for (int j = 0; j < questionCount; j++)
                {
                    //get the choice of the i candidate for the j question (+1 as Primary key starts from 1)
                    ret[i][j] = ProfileQuestions.SingleOrDefault(pq => pq.Profile.Id == i + 1 && pq.Question.Id == j + 1).Choice;
                    //ProfileQuestion pq = ProfileQuestion.GetProfileQuestion(i + 1, j + 1);
                    //ret[i][j] = pq.Choice;
                }
                //last column is the attributed class
                ret[i][questionCount] = i;
            }

            return(ret);
        }
コード例 #2
0
 internal bool ContainsImportQuestion(ProfileImportQuestion importQuestion)
 {
     if (ProfileQuestions.Where(x => x.Question == importQuestion.Question).FirstOrDefault() == null)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #3
0
 private void AddQuestionToCollections(ProfileQuestion question)
 {
     ProfileQuestions.Add(question);
     if (question.IsCustomQuestion)
     {
         dictionaryCustomQuestions[question.CustomQuestionID] = question;
     }
     else
     {
         dictionaryDefaultQuestions[question.QuestionDefaultID] = question;
     }
 }
コード例 #4
0
        private int GetMaxQuestionNumber()
        {
            int maxQuestionNumber;

            if (ProfileQuestions.Count() > 0)
            {
                maxQuestionNumber = ProfileQuestions.Max(x => x.SubLabelNumber);
            }
            else
            {
                maxQuestionNumber = 0;
            }
            return(maxQuestionNumber);
        }
コード例 #5
0
 public void RemoveQuestion(ProfileQuestion profileQuestion)
 {
     ProfileQuestions.Remove(profileQuestion);
 }