In this example a data set with 7 observations and 3 classes is filtered.
using System; using Imsl.Stat; using Imsl.Math; using Imsl.DataMining.Neural; public class UnsupervisedNominalFilterEx1 { public static void Main(System.String[] args) { int nClasses = 3; UnsupervisedNominalFilter filter = new UnsupervisedNominalFilter(nClasses); int nObs = 7; int[] x = new int[]{3, 3, 1, 2, 2, 1, 2}; int[] xBack = new int[nObs]; int[,] z; // Perform Binary Filtering. z = filter.Encode(x); PrintMatrix pm = new PrintMatrix(); pm.SetTitle("Filtered x"); pm.Print(z); // Perform Binary Un-filtering. int[] tmp = new int[z.GetLength(1)]; for (int i = 0; i < nObs; i++) { for (int j=0; j< z.GetLength(1); j++) tmp[j] = z[i,j]; xBack[i] = filter.Decode(tmp); } pm.SetTitle("Result of inverse filtering"); pm.Print(xBack); } }
Filtered x 0 1 2 0 0 0 1 1 0 0 1 2 1 0 0 3 0 1 0 4 0 1 0 5 1 0 0 6 0 1 0 Result of inverse filtering 0 0 3 1 3 2 1 3 2 4 2 5 1 6 2Link to C# source.