I am commenting in this thread years later, because it is the first result that pops-up when doing a Google search. @ptrblk has a much better answer and example in another post here which worked wonders for me!
Do not use the class index weights directly, you have to transform them to samples weights!