Beispiel #1
0
    public static double TestModel(ModelLR model, DataLR testData)
    {
        double acc = 0;

        try
        {
            acc = (double)PredictiveAccuracy(testData.IndepVar, testData.DepVar, model.Betas) / 100.0; // percent of data cases correctly predicted in the test data set.
        }
        catch (Exception ex)
        {
            Console.WriteLine("Fatal in TestModel: " + ex.Message);
        }

        return(acc);
    }
Beispiel #2
0
    //Le fichier doit contenir pour chaque lignes les valeurs des indépendants suivie de la dépendante
    public static ModelLR ComputeModel(DataLR datas)
    {
        ModelLR model = new ModelLR();

        try
        {
            int    maxIterations = 25;
            double epsilon       = 0.01;                                                                     // stop if all new beta values change less than epsilon (algorithm has converged?)
            double jumpFactor    = 1000.0;                                                                   // stop if any new beta jumps too much (algorithm spinning out of control?)

            model.Betas = ComputeBestBeta(datas.IndepVar, datas.DepVar, maxIterations, epsilon, jumpFactor); // computing the beta parameters is synonymous with 'training'
        }
        catch (Exception ex)
        {
            Console.WriteLine("Fatal in ComputeBestBeta: " + ex.Message);
        }

        return(model);
    }