Beispiel #1
0
        public static LinearModel[] GetAllExhaustiveModels(string distribution, string dimension,
            TrainingSet.Trajectory track, int iter, bool extended, PreferenceSet.Ranking rank, bool timedependent,
            DirectoryInfo dataDir, string stepwiseBias)
        {
            string pat = String.Format("exhaust.{0}.{1}.{2}.{3}.{4}.weights.{5}.csv",
                distribution, dimension, (char) rank, Trajectory2String(track, iter, extended),
                stepwiseBias, timedependent ? "timedependent" : "timeindependent");

            DirectoryInfo dir = new DirectoryInfo(String.Format(@"{0}\PREF\weights", dataDir.FullName));
            Regex reg = new Regex(pat);
            var files = dir.GetFiles("*.csv").Where(path => reg.IsMatch(path.ToString())).ToList();

            return files.Count < 1 ? null : ReadLoggedLinearWeights(files[0], distribution, dimension, Model.PREF);
        }
Beispiel #2
0
        public static LinearModel[] GetAllVaryLmaxModels(string distribution, string dimension,
            TrainingSet.Trajectory track, int iter, bool extended, PreferenceSet.Ranking rank, bool timedependent,
            DirectoryInfo dataDir, string stepwiseBias)
        {
            string pat = String.Format("full.{0}.{1}.{2}.{3}.{4}.weights.{5}_lmax[0-9]+.csv",
                distribution, dimension, (char) rank, Trajectory2String(track, iter, extended),
                stepwiseBias, timedependent ? "timedependent" : "timeindependent");

            DirectoryInfo dir = new DirectoryInfo(String.Format(@"{0}\PREF\weights", dataDir.FullName));
            Regex reg = new Regex(pat);
            var files = dir.GetFiles("*.csv").Where(path => reg.IsMatch(path.ToString())).ToList();
            if (files.Count < 1) return null;

            LinearModel[] models = new LinearModel[0];
            foreach (
                var model in
                    files.Select(file => ReadLoggedLinearWeights(file, distribution, dimension, Model.PREF))
                        .Where(model => model != null))
            {
                Array.Resize(ref models, models.Length + model.Length);
                Array.Copy(model, 0, models, models.Length - model.Length, model.Length);
            }
            return models;
        }
Beispiel #3
0
        public LinearModel(string distribution, string dimension, TrainingSet.Trajectory track, bool extended,
            PreferenceSet.Ranking rank, bool timedependent, DirectoryInfo dataDir,
            int numFeatures, int modelID, string stepwiseBias, int iter = -1, Features.Mode featMode = Features.Mode.Local)
            : this(null, featMode, numFeatures, modelID, !timedependent, distribution, dimension, Model.PREF)
        {
            switch (track)
            {
                case TrainingSet.Trajectory.ILFIXSUP:
                case TrainingSet.Trajectory.ILUNSUP:
                case TrainingSet.Trajectory.ILSUP:
                    LinearModel model;
                    Iteration = GetImitationLearningFile(out model, distribution, dimension, track, extended,
                        numFeatures, modelID, dataDir.FullName, stepwiseBias, timedependent, iter);
                    FileInfo = model.FileInfo;
                    LocalWeights = model.LocalWeights;
                    return;
                default:
                    string pat = String.Format("\\b(exhaust|full)\\.{0}.{1}.{2}.{3}{4}.{5}.{6}weights.{7}.csv",
                        distribution, dimension, (char) rank,
                        track, extended ? "EXT" : "", stepwiseBias,
                        FeatureMode == Features.Mode.Global ? "(Global|SDR)" : "",
                        timedependent ? "timedependent" : "timeindependent");

                    DirectoryInfo dir = new DirectoryInfo(String.Format(@"{0}\PREF\weights", dataDir.FullName));
                    Regex reg = new Regex(pat);
                    var files = dir.GetFiles("*.csv").Where(path => reg.IsMatch(path.ToString())).ToList();

                    if (files.Count <= 0)
                        throw new Exception(String.Format("Cannot find any weights belonging to {0}!", pat));

                    foreach (var file in files)
                    {
                        LinearModel[] logWeights = ReadLoggedLinearWeights(file, distribution, dimension, Model.PREF);
                        FileInfo = file;

                        foreach (
                            var w in logWeights.Where(w => w._numFeatures == _numFeatures && w._modelID == _modelID))
                        {
                            LocalWeights = w.LocalWeights;
                            GlobalWeights = w.GlobalWeights;
                            return;
                        }
                    }
                    throw new Exception(String.Format("Cannot find weights {0} to user requirements from {1}!", Name,
                        files[0].Name));
            }
        }