LVQ2C(1)

NAME
lvq2c - create C source code to implement a trained learning vector quantizer classifier

SYNOPSIS
lvq2c -model_file file [ -suffix s ] > file.c

DESCRIPTION
This filter creates source code on the standard output which can be included in a user's program to implement a trained LVQ classifier. An LVQ parameter file is required as an argument to the -model_file command line argument. All normalization, feature selection, and algorithm parameters are set as they were in the trained classifier. A user's program calls the classify() subroutine with a floating vector equal to the raw classifier input and another floating point vector to hold classifier outputs. The classify() program returns an integer (0 to the number of classes minus 1) equal to the classification decision and fills in the output vector. Generated source code contains two subroutines. The classify() subroutine performs classification, and the normalize() subroutine is used by classify() for data normalization. These names can be changed by editing the generated source code or using the -suffix command line flag. The following options are recognized:

-model_file file
    The name of a parameter file containing a trained LVQ classifier. Parameter files are created automatically under LNKnet when an LVQ classifier is trained. The prefix for the parameter file name is the experiment number followed by "lvq" and the suffix is ".param". For example, the name of the parameter file for an experiment named X1 is X1lvq.param.

-suffix string
    String is a suffix that is added onto the classify() and normalize() subroutine names to make that name more unique. The command -suffix X1lvq results in subroutines named classify_X1lvq() and normalize_X1lvq()

-adjust_test_priors, -test_uniform_priors, -test_priors_list
    Because this classifier does not produce scalable continuous outputs, these three flags are ignored.

EXAMPLE OF USER'S CODE
The following program calls the classifier subroutine to generate decision regions.
    main()
    {
      float x,y, xstep, ystep, inputs[2], outputs[2];
      int class;
      /* sample a 50 by 50 grid of patterns between (-1,-1) and (2,2) */
      xstep = ystep = (2.-(-1.))/50.;
      for(x = -1.; x < 2; x += xstep){
        inputs[0] = x;
        for(y = -1.; y < 2; y += ystep){
          	inputs[1] = y;
          	/* find the class for the current pattern */
          	class = classify_lvq(inputs, outputs);
          	/* print out the results */
          	printf("%d", class);
    		}
        printf("\n");
    	}
    }

SEE ALSO
lvq_lnk(1), LNKnet User's Guide

BUGS
There is a fifty character limit on the length of a suffix defined with the -suffix flag.

HISTORY
1-June-93 Original version written by Linda Kukolich.
Modified 23 June 1994, updated suffix flags
Modified 18 April 1995, added priors adjustment flags