Пример #1
0
        /// <summary>
        /// Gets the vectors with label identifier as dimension value. If vector is not found in this dictionary, it will set labelID to 0, for incorrect it will set 1 and for correct 2
        /// </summary>
        /// <param name="CompleteDataSet">The complete data set.</param>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public FeatureVectorWithLabelIDSet GetVectorsWithLabelID(List <String> CompleteDataSet, Double criteria = 0.5, List <String> labels = null)
        {
            if (CompleteDataSet == null)
            {
                CompleteDataSet = new List <string>();
            }

            labels = SpaceLabel.SetDefaultLabelList(CompleteDataSet.Any(), labels);

            CompleteDataSet.AddRange(this.Select(x => x.Key));

            //if (labels==null)
            //{

            //    labels = new List<string>();
            //    labels.Add(SpaceLabel.UNKNOWN);
            //    labels.Add(SpaceLabel.INCORRECT);
            //    labels.Add(SpaceLabel.CORRECT);
            //}


            Int32 l_unknown = labels.IndexOf(SpaceLabel.UNKNOWN);

            Int32 l_correct   = labels.IndexOf(SpaceLabel.CORRECT);
            Int32 l_incorrect = labels.IndexOf(SpaceLabel.INCORRECT);

            var output = new FeatureVectorWithLabelIDSet();

            output.DoAutoSetUnknownLabels = false;

            foreach (String id in CompleteDataSet)
            {
                Int32 l = l_unknown;
                FeatureVectorWithLabelID fv_id = null;

                if (ContainsKey(id))
                {
                    if (this[id].dimensions[0] < criteria)
                    {
                        l = l_incorrect;
                    }
                    else
                    {
                        l = l_correct;
                    }
                    fv_id = new FeatureVectorWithLabelID(this[id], l);
                }
                else
                {
                    if (l_unknown > -1)
                    {
                        fv_id = new FeatureVectorWithLabelID(new FeatureVector(id), l);
                    }
                }
                output.Add(fv_id);
            }
            return(output);
        }
Пример #2
0
        /// <summary>
        /// Deploys custom truth table
        /// </summary>
        /// <param name="vectors">The vectors.</param>
        /// <param name="logger">The logger.</param>
        public void Deploy(IEnumerable <FeatureVectorWithLabelID> vectors, ILogBuilder logger, List <String> labels = null)
        {
            label_index = SpaceLabel.SetDefaultLabelList(true, labels);

            labels_without_unknown = SpaceLabel.SetDefaultLabelList(false, labels);


            index_to_label = new Dictionary <int, string>();
            for (int i = 0; i < label_index.Count; i++)
            {
                index_to_label.Add(i, label_index[i]);
            }


            foreach (FeatureVectorWithLabelID vector in vectors)
            {
                siteToLabel.Add(vector.name, index_to_label[vector.labelID]);
            }
        }