예제 #1
0
        public void EstimatePersonLocation_DataFromAyala_ReturnsCorrectFinalQuestion()
        {
            CATParameters       catParameters     = GetDefaultCatParameters();
            LocationEstimator   locationEstimator = new LocationEstimator(_textQuestionLoader, _textAnswerSheetLoader, catParameters);
            List <QuestionInfo> questionHistory   = locationEstimator.EstimatePersonLocation();

            string finalQuestion = questionHistory.Last().Question.QuestionLabel;

            Assert.IsTrue(Convert.ToInt32(finalQuestion) == 205);
        }
예제 #2
0
        public void EstimatePersonLocation_DataFromAyala_ReturnsCorrectFinalInfo()
        {
            CATParameters       catParameters     = GetDefaultCatParameters();
            LocationEstimator   locationEstimator = new LocationEstimator(_textQuestionLoader, _textAnswerSheetLoader, catParameters);
            List <QuestionInfo> questionHistory   = locationEstimator.EstimatePersonLocation();

            double estimatedInformation = (double)questionHistory.Last().Information;

            Assert.IsTrue(Math.Abs(estimatedInformation - .901) < Tolerance);
        }
예제 #3
0
 public LocationEstimator(IQuestionLoader questionLoader, IAnswerSheetLoader answerSheetLoader, CATParameters catParameters)
 {
     _questionLoader    = questionLoader;
     _answerSheetLoader = answerSheetLoader;
     _catParameters     = catParameters;
     _bestThetaEstimator
         = new BestThetaEstimator(
               catParameters.IncreasingZeroVarianceStepSize,
               catParameters.DecreasingZeroVarianceStepSize,
               catParameters.UseDiscriminationParameterForEstimation,
               catParameters.Tolerance);
 }
예제 #4
0
        private CATParameters GetDefaultCatParameters()
        {
            CATParameters catParameters = new CATParameters()
            {
                InformationCutoff        = .9,
                MaximumNumberOfQuestions = Int16.MaxValue,
                MinimumNumberOfQuestions = Int16.MinValue,
                SeeCutoff = Double.NegativeInfinity,
                //IncreasingZeroVarianceStepSize = .3
            };

            return(catParameters);
        }
예제 #5
0
        public void EstimatePersonLocation_CompletesAnswerSheet2()
        {
            try
            {
                CATParameters       catParameters     = GetDefaultCatParameters();
                LocationEstimator   locationEstimator = new LocationEstimator(_textQuestionLoader, _textAnswerSheetLoader2, catParameters);
                List <QuestionInfo> questionHistory   = locationEstimator.EstimatePersonLocation();

                Assert.IsTrue(true);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
        }
예제 #6
0
        public static CATParameters Load(string fileLocation)
        {
            CATParameters parameters = new CATParameters();

            using (var reader = new StreamReader(fileLocation))
            {
                parameters.MinimumNumberOfQuestions = Convert.ToInt32(reader.ReadLine());
                parameters.MaximumNumberOfQuestions = Convert.ToInt32(reader.ReadLine());
                parameters.SeeCutoff         = Convert.ToDouble(reader.ReadLine());
                parameters.InformationCutoff = Convert.ToDouble(reader.ReadLine());
                parameters.IncreasingZeroVarianceStepSize = Convert.ToDouble(reader.ReadLine());
            }

            return(parameters);
        }
        private static CATParameters ConvertToCatParameters(SettingsInput settingsInput)
        {
            CATParameters catParameters = new CATParameters()
            {
                DecreasingZeroVarianceStepSize = settingsInput.DecreasingZeroVarianceStepsize,
                IncreasingZeroVarianceStepSize = settingsInput.IncreasingZeroVarianceStepsize,
                InformationCutoff        = settingsInput.InformationCutoff,
                MaximumNumberOfQuestions = settingsInput.MaximumNumberOfQuestions,
                MinimumNumberOfQuestions = settingsInput.MinimumNumberOfQuestions,
                SeeCutoff = settingsInput.SeeCutoff,
                UseDiscriminationParameterForEstimation = settingsInput.UseDiscriminationParamForEstimation,
                MistakeProbability          = settingsInput.MistakeProbability,
                NumQuestionsBeforeCatBegins = settingsInput.NumQuestionsBeforeCatBegins,
                Tolerance = settingsInput.Tolerance
            };

            return(catParameters);
        }
        static void Main(string[] args)
        {
            string      excelLocationString = GetExcelFileLocationFromUser();
            ExcelClient excelClient         = new ExcelClient();
            Workbook    workbook            = GetWb(excelLocationString, excelClient);

            SettingsInput          settingsInput       = GetSettingsInput(workbook);
            List <ItemInformation> itemInformationList = GetItemInformation(workbook);
            List <UserAnswers>     answersInput        = GetAnswersInput(workbook);

            workbook.Close();

            CATParameters catParameters = ConvertToCatParameters(settingsInput);

            List <string> scaleNames  = itemInformationList.Select(x => x.ScaleName).Distinct().ToList();
            List <string> personNames = answersInput.Select(x => x.PersonName).Distinct().ToList();

            var scoringOutput = GetScores(scaleNames, itemInformationList, personNames, answersInput, catParameters);

            WriteOutput(excelLocationString, scoringOutput, excelClient.GetApplication());
        }
        private static ScoringOutput GetScores(List <string> scaleNames, List <ItemInformation> itemInformationList, List <string> personNames, List <UserAnswers> answersInput,
                                               CATParameters catParameters)
        {
            List <ScoreDetails>         scores           = new List <ScoreDetails>();
            List <List <QuestionInfo> > questionInfoList = new List <List <QuestionInfo> >();

            foreach (var scaleName in scaleNames)
            {
                List <ItemInformation> itemInfoForScale = itemInformationList.Where(x => x.ScaleName.Equals(scaleName)).ToList();
                IQuestionLoader        questionLoader   = new ExcelQuestionLoader(itemInfoForScale, catParameters.MistakeProbability);
                foreach (var personName in personNames)
                {
                    UserAnswers        personAnswers     = answersInput.Single(x => x.PersonName.Equals(personName));
                    ScaleAnswers       answers           = personAnswers.ScaleAnswers.Single(x => x.ScaleName.Equals(scaleName));
                    IAnswerSheetLoader answerSheetLoader = new ExcelAnswerSheetLoader(answers);

                    LocationEstimator   locationEstimator = new LocationEstimator(questionLoader, answerSheetLoader, catParameters);
                    List <QuestionInfo> output            = locationEstimator.EstimatePersonLocation();
                    questionInfoList.Add(output);

                    ScoreDetails scoreDetails = new ScoreDetails()
                    {
                        PersonName = personName,
                        ScaleName  = scaleName,
                        Score      = (double)output.Last().ThetaEstimate
                    };
                    scores.Add(scoreDetails);
                }
            }

            ScoringOutput scoringOutput = new ScoringOutput()
            {
                FirstPersonQuestionInfo = questionInfoList.First(),
                ScoreDetails            = scores
            };

            return(scoringOutput);
        }
예제 #10
0
 public void EstimatePersonLocation_BisectionSolverFailing()
 {
     CATParameters       catParameters     = GetDefaultCatParameters();
     LocationEstimator   locationEstimator = new LocationEstimator(_textQuestionLoader2, _textAnswerSheetLoader4, catParameters);
     List <QuestionInfo> x = locationEstimator.EstimatePersonLocation();
 }
예제 #11
0
 public void EstimatePersonLocation_CompletesAnswerSheet3()
 {
     CATParameters       catParameters     = GetDefaultCatParameters();
     LocationEstimator   locationEstimator = new LocationEstimator(_textQuestionLoader, _textAnswerSheetLoader, catParameters);
     List <QuestionInfo> questionHistory   = locationEstimator.EstimatePersonLocation();
 }