The $k$ $q$-flats algorithm is a generalization of the popular $k$-means algorithm where $q$ dimensional best fit affine sets replace centroids as the cluster prototypes. In this work, a modification of the $k$ $q$-flats framework for pattern classification is introduced. The basic idea is to replace the original reconstruction only energy, which is optimized to obtain the $k$ affine spaces, by a new energy that incorporates discriminative terms. This way, the actual classification task is introduced as part of the design and optimization. The presentation of the proposed framework is complemented with experimental results, showing that the method is computationally very efficient and gives excellent results on standard supervised learning benchmarks.