Example #1
0
 //Constructors
 /// <summary>
 /// Creates an initialized instance.
 /// </summary>
 /// <param name="oneTakesAllGroupName">Specifies the membership in "One Takes All" group of the specified name or no membership if NA keyword is used.</param>
 /// <param name="clusterChainCfg">The cluster chain configuration.</param>
 public ClassificationTaskSettings(string oneTakesAllGroupName = DefaultOneTakesAllGroupName,
                                   TNRNetClusterChainSingleBoolSettings clusterChainCfg = null
                                   )
 {
     OneTakesAllGroupName = oneTakesAllGroupName;
     ClusterChainCfg      = clusterChainCfg == null ? null : (TNRNetClusterChainSingleBoolSettings)clusterChainCfg.DeepClone();
     Check();
     return;
 }
Example #2
0
 //Constructors
 /// <summary>
 /// Creates an unitialized instance
 /// </summary>
 /// <param name="classificationClusterChainCfg">Default configuration of the classification cluster chain (can be null)</param>
 /// <param name="forecastClusterChainCfg">Default configuration of the forecast cluster chain (can be null)</param>
 public TaskDefaultsSettings(TNRNetClusterChainSingleBoolSettings classificationClusterChainCfg,
                             TNRNetClusterChainRealSettings forecastClusterChainCfg
                             )
 {
     ClassificationClusterChainCfg = (TNRNetClusterChainSingleBoolSettings)classificationClusterChainCfg?.DeepClone();
     ForecastClusterChainCfg       = (TNRNetClusterChainRealSettings)forecastClusterChainCfg?.DeepClone();
     Check();
     return;
 }
Example #3
0
        /// <summary>
        /// Creates an initialized instance.
        /// </summary>
        /// <param name="elem">A xml element containing the configuration data.</param>
        public ClassificationTaskSettings(XElement elem)
        {
            //Validation
            XElement settingsElem = Validate(elem, XsdTypeName);

            //Parsing
            OneTakesAllGroupName = settingsElem.Attribute("oneTakesAllGroupName").Value;
            //Result
            XElement clusterChainElem = settingsElem.Elements("clusterChain").FirstOrDefault();

            ClusterChainCfg = clusterChainElem == null ? null : new TNRNetClusterChainSingleBoolSettings(clusterChainElem);
            Check();
            return;
        }
Example #4
0
        /// <summary>
        /// Gets the readout unit's specific or default classification cluster chain configuration.
        /// </summary>
        /// <param name="readoutUnitID">The zero-based index of the readout unit.</param>
        /// <returns>The classification cluster chain configuration.</returns>
        public TNRNetClusterChainSingleBoolSettings GetRUnitTaskClassificationClusterChainCfg(int readoutUnitID)
        {
            TNRNetClusterChainSingleBoolSettings resultCfg = ((ClassificationTaskSettings)ReadoutUnitsCfg.ReadoutUnitCfgCollection[readoutUnitID].TaskCfg).ClusterChainCfg;

            if (resultCfg == null)
            {
                //Use task default
                resultCfg = TaskDefaultsCfg.ClassificationClusterChainCfg;
                if (resultCfg == null)
                {
                    //Not defined
                    throw new ArgumentException($"For the readout unit {ReadoutUnitsCfg.ReadoutUnitCfgCollection[readoutUnitID].Name} there is not available the classification cluster chain configuration (specific nor default).", "readoutUnitID");
                }
            }
            return(resultCfg);
        }
Example #5
0
        /// <summary>
        /// Creates the simplified configuration of the readout layer to solve the classification task.
        /// </summary>
        /// <remarks>
        /// Supports the probabilistic output only.
        /// </remarks>
        /// <param name="crossvalidationCfg">The crossvalidation configuration.</param>
        /// <param name="netCfg">The configuration of the FF network to be used in the cluster(s).</param>
        /// <param name="clusterChainLength">The number of chained clusters.</param>
        /// <param name="oneTakesAllGroupName">The name of the "One Takes All" group in case of multiple classes or use the "NA" code when there is only the single class.</param>
        /// <param name="unitName">The readout unit names (the names of the classes).</param>
        public static ReadoutLayerSettings CreateClassificationReadoutCfg(CrossvalidationSettings crossvalidationCfg,
                                                                          FeedForwardNetworkSettings netCfg,
                                                                          int clusterChainLength,
                                                                          string oneTakesAllGroupName,
                                                                          params string[] unitName
                                                                          )
        {
            if (netCfg == null)
            {
                throw new ArgumentNullException("netCfg");
            }
            List <string> readoutUnitNames = new List <string>(unitName.AsEnumerable());

            oneTakesAllGroupName = readoutUnitNames.Count > 1 ? oneTakesAllGroupName : "NA";
            List <ReadoutUnitSettings> unitCfgCollection = new List <ReadoutUnitSettings>();

            foreach (string name in readoutUnitNames)
            {
                unitCfgCollection.Add(new ReadoutUnitSettings(name, new ClassificationTaskSettings(oneTakesAllGroupName)));
            }

            TNRNetClusterSingleBoolNetworksSettings netsCfg              = new TNRNetClusterSingleBoolNetworksSettings(netCfg);
            TNRNetClusterSingleBoolSettings         clusterCfg           = new TNRNetClusterSingleBoolSettings(netsCfg, new TNRNetClusterSingleBoolWeightsSettings());
            List <TNRNetClusterSingleBoolSettings>  clusterCfgCollection = new List <TNRNetClusterSingleBoolSettings>();

            for (int i = 0; i < clusterChainLength; i++)
            {
                clusterCfgCollection.Add(clusterCfg);
            }
            TNRNetClustersSingleBoolSettings     clustersCfg     = new TNRNetClustersSingleBoolSettings(clusterCfgCollection);
            TNRNetClusterChainSingleBoolSettings clusterChainCfg = new TNRNetClusterChainSingleBoolSettings(crossvalidationCfg, clustersCfg);
            TaskDefaultsSettings taskDefaultsCfg = new TaskDefaultsSettings(clusterChainCfg, null);

            return(new ReadoutLayerSettings(taskDefaultsCfg,
                                            new ReadoutUnitsSettings(unitCfgCollection),
                                            readoutUnitNames.Count > 1 ? new OneTakesAllGroupsSettings(new OneTakesAllGroupSettings(oneTakesAllGroupName, new OneTakesAllBasicDecisionSettings())) : null
                                            ));
        }