Exemple #1
0
        void ApplyOnTest(IEnumerable<Image> test, Stopwatch sw, IOracle oracle, string resultFile)
        {
            Console.WriteLine("Begin predicting on TEST ... elapsed time (in s):" + sw.Elapsed.TotalSeconds);
            int nbTest = test.Count();
            List<int> result = new List<int>(nbTest);
            int count = 0;
            foreach (Image t in test)
            {
                int predict = oracle.Predict(t);
                //t.ToImage(count.ToString() + ".bmp");
                //Console.WriteLine(count.ToString() + " = predict => " + predict);

                result.Add(predict);

                count++;
                if (count % 1000 == 0)
                {
                    Console.WriteLine("at count=" + count);
                    Console.WriteLine("elapsed time (in s):" + sw.Elapsed.TotalSeconds);
                }
            }

            using (StreamWriter writer = new StreamWriter(resultFile))
            {
                foreach (int res in result)
                    writer.WriteLine(res);
            }
            Console.WriteLine("elapsed time (in s):" + sw.Elapsed.TotalSeconds);
        }
 public SegmentTreeNaive(int n, IOracle <TMonoid> oracle)
 {
     _n      = n;
     _data   = new TMonoid[n];
     _oracle = oracle;
     _id     = _oracle.MonoidIdentity;
 }
Exemple #3
0
        public Oracle(string serverName)
        {
            var client = new System.Net.Http.HttpClient();

            client.Timeout     = TimeSpan.FromSeconds(5);
            client.BaseAddress = new Uri(serverName);
            _remote            = Refit.RestService.For <IOracle>(client);
        }
Exemple #4
0
 public Team(List <Player> players, string name)
 {
     Captain     = null;
     TeamMembers = players;
     Name        = name;
     Rating      = 0;
     _oracle     = Container.Resolve <IOracle>();
 }
Exemple #5
0
 public GreedyCooperativeSolver(bool[,,] whatToFill, bool[,,] state, IOracle oracle, ICandidatesOrdering candidatesOrdering = null)
 {
     this.whatToFill         = whatToFill;
     this.state              = state;
     this.oracle             = oracle;
     this.candidatesOrdering = candidatesOrdering ?? new BuildAllStayingStill();
     R = whatToFill.GetLength(0);
 }
Exemple #6
0
 public Solver(Phrases phrases, IFinder finder, IOracle oracle, int bestSugessionsCount = 20, double metricEpsilon = 1)
 {
     this.phrases = phrases;
     Finder = finder;
     Oracle = oracle;
     this.bestSugessionsCount = bestSugessionsCount;
     this.metricEpsilon = metricEpsilon;
     Name = oracle.GetType().Name + "-" + finder.GetType().Name;
 }
Exemple #7
0
        static void InfoAboutTrainingSet(List<Person> ps, IOracle oracle = null)
        {
            double nbSurvived = ps.Count(
                p => oracle == null ? p.Survived : oracle.Predict(p)
                );
            double nbTotal = ps.Count();
            double rate = nbSurvived / nbTotal;

            Console.WriteLine("NbSurvived:{0};NbTotal:{1};SurvivalRate:{2}", nbSurvived, nbTotal, rate);
        }
 public GreedyParallel(Matrix whatToFill, Vec pos, IOracle oracle, ICandidatesOrdering candidatesOrdering = null)
 {
     this.whatToFill = whatToFill;
     bots            = new Dictionary <int, BotState>();
     bots[0]         = new BotState {
         Position = pos
     };
     this.oracle             = oracle;
     this.candidatesOrdering = candidatesOrdering ?? new BuildAllStayingStill();
     R             = whatToFill.R;
     filled        = new Matrix(R);
     blockedBefore = new Matrix <int>(R);
 }
        public SegmentTree(IReadOnlyCollection <TMonoid> source, IOracle <TMonoid> oracle) : this(source.Count, oracle)
        {
            var idx = _dataSize;

            foreach (var value in source)
            {
                _data[idx++] = value;
            }
            for (var i = _dataSize - 1; i >= 1; i--)
            {
                Update(i);
            }
        }
 public SegmentTree(int length, IOracle <TMonoid> oracle)
 {
     if (length < 0)
     {
         throw new ArgumentOutOfRangeException(nameof(length));
     }
     Length  = length;
     _oracle = oracle;
     while (1 << _log < Length)
     {
         _log++;
     }
     _dataSize = 1 << _log;
     _data     = new TMonoid[_dataSize << 1];
     Array.Fill(_data, oracle.MonoidIdentity);
 }
Exemple #11
0
            public SegmentTree(IEnumerable <TMonoid> data, IOracle <TMonoid> oracle)
            {
                var d = data.ToArray();

                _length   = d.Length;
                _oracle   = oracle;
                _monoidId = oracle.MonoidIdentity;
                while (1 << _log < _length)
                {
                    _log++;
                }
                _size = 1 << _log;
                _data = new TMonoid[_size << 1];
                Array.Fill(_data, _monoidId);
                d.CopyTo(_data, _size);
                for (var i = _size - 1; i >= 1; i--)
                {
                    Update(i);
                }
            }
Exemple #12
0
 void ApplyOnValidation(IEnumerable<Image> validation, Stopwatch sw, IOracle oracle)
 {
     int nbTotal = 0;
     int nbCorrect = 0;
     Console.WriteLine("Begin predicting ...Elapsed time (in s):" + sw.Elapsed.TotalSeconds);
     Console.WriteLine();
     foreach (Image v in validation)
     {
         nbTotal++;
         if (nbTotal % 50 == 0)
         {
             Console.WriteLine("at nbTotal=" + nbTotal + ". Elapsed time (in s):" + sw.Elapsed.TotalSeconds);
         }
         int predict = oracle.Predict(v);
         if (predict == v.Label)
             nbCorrect++;
     }
     Console.WriteLine("nbTotal:" + nbTotal);
     Console.WriteLine("nbCorrect:" + nbCorrect);
     Console.WriteLine("elapsed time (in s):" + sw.Elapsed.TotalSeconds);
 }
Exemple #13
0
 public SegmentTree(int length, IOracle <TMonoid> oracle)
     : this(Enumerable.Repeat(oracle.MonoidIdentity, length), oracle)
 {
 }
Exemple #14
0
        static void WriteToTestResult(IOracle forest)
        {
            List<Person> test = ImportFromCsv.GetDataSet(__dataFolder + "originalTest.csv", train: false);

            using (StreamReader reader = new StreamReader(__dataFolder + "originalTest.csv")) // Just to take the csv header ...
            using (StreamWriter writer = new StreamWriter(__dataFolder + "/result.csv"))
            {
                writer.Write("survived,");
                writer.WriteLine(reader.ReadLine());

                foreach (var p in test)
                {
                    bool predict = forest.Predict(p);
                    writer.Write(predict ? "1," : "0,");
                    writer.WriteLine(reader.ReadLine());
                }
            }
        }
Exemple #15
0
 static double MesureModelOnValidation(List<Person> valid, IOracle oracle)
 {
     // Mesrue forest's Performance on Validation
     int nbErrorOnValidation = 0;
     foreach (var v in valid)
     {
         bool predict = oracle.Predict(v);
         if (predict != v.Survived)
             nbErrorOnValidation++;
     }
     double percent = (nbErrorOnValidation + 0.00) / valid.Count * 100;
     return percent;
 }
Exemple #16
0
 private Solver BuildSolver(IOracle mephalaOracle)
 {
     return new Solver(phrases, finder, mephalaOracle);
 }
Exemple #17
0
 public void ChangeOracle(IOracle oracle)
 {
     _oracle = oracle;
 }
 public Paginaweb(IBasededatos factory)
 {
     Ioracle     = factory.GetOracle();
     Iseversql   = factory.GetSqlServer();
     Ipostgresql = factory.GetPostgreSQL();
 }
Exemple #19
0
 private double Score(IEnumerable<Image> valid, IOracle oracle)
 {
     double nbImage = 0;
     double correct = 0;
     foreach (Image image in valid)
     {
         nbImage++;
         int predict = oracle.Predict(image);
         if (predict == image.Label)
         {
             correct++;
         }
     }
     return correct / nbImage;
 }
 public GreedyFill(DeluxeState state, Bot bot, IOracle oracle, ICandidatesOrdering candidatesOrdering = null)
     : base(state, bot)
 {
     this.oracle             = oracle;
     this.candidatesOrdering = candidatesOrdering ?? new BuildAllStayingStill();
 }
 public GreedyPartialSolver(Matrix targetMatrix, IOracle oracle, ICandidatesOrdering candidatesOrdering = null)
     : this(targetMatrix.Voxels, new bool[targetMatrix.R, targetMatrix.R, targetMatrix.R], Vec.Zero, oracle, candidatesOrdering)
 {
 }
Exemple #22
0
 public void AddChild(object modality, IOracle dn)
 {
     _children.Add(modality, dn);
 }
 public GreedyPartialSolver(Matrix targetMatrix, Matrix sourceMatrix, IOracle oracle, ICandidatesOrdering candidatesOrdering = null)
     : this(targetMatrix.Voxels, sourceMatrix.Voxels, Vec.Zero, oracle, candidatesOrdering)
 {
 }