Added createSparseWeight function.