Nonparametric regression and classification with joint sparsity constraints