Example: UnsupervisedOrdinalFilter

In this example a data set with 10 observations and 4 classes is filtered.

using System;
using Imsl.Stat;
using Imsl.Math;
using Imsl.DataMining.Neural;

public class UnsupervisedOrdinalFilterEx1
{


   public static void  Main(System.String[] args)
   {
      int nClasses = 4;
      UnsupervisedOrdinalFilter filter = new UnsupervisedOrdinalFilter(nClasses,
         UnsupervisedOrdinalFilter.TransformMethod.AsinSqrt);
      int[] x = new int[]{2, 1, 3, 4, 2, 4, 1, 1, 3, 3};
      int nObs = x.Length;
      int[] xBack;
      double[] z;
      // Ordinal Filtering.
      z = filter.Encode(x);
      // Print result without row/column labels.
      PrintMatrix pm = new PrintMatrix();
      PrintMatrixFormat mf;
      mf = new PrintMatrixFormat();
      mf.SetNoRowLabels();
      mf.SetNoColumnLabels();
      pm.SetTitle("Filtered data");
      pm.Print(mf, z);
      
      // Ordinal Un-filtering.
      pm.SetTitle("Un-filtered data");
      xBack = filter.Decode(z);
      
      // Print results of Un-filtering.
      pm.Print(mf, xBack);
   }
}

Output

    Filtered data
                     
0.785398163397448  
0.579639740363704  
1.10714871779409   
1.5707963267949    
0.785398163397448  
1.5707963267949    
0.579639740363704  
0.579639740363704  
1.10714871779409   
1.10714871779409   

Un-filtered data
     
2  
1  
3  
4  
2  
4  
1  
1  
3  
3  


Link to C# source.