sparse parameter for one hot encoder(a cleaner PR)

i have previously submitted a PR for one hot encoder but it was all messed up.
i have written a fresh PR(with tests added to test_data.py)