You should be able to set the rating using e.g. this way(thats how we do it internally):
float currentRating = 0.5; // has to be within 0-1 range
bool checkUserRated = true;
TreeProvider.AddRating(DocumentContext.CurrentDocument, currentRating , checkUserRated );