Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
But I think you should modify the definition of $f$ so that it only counts each conjugacy class from $G$ once. So $f(h)$ should be the number of conjugacy classes of $G$ which $\phi$ sends to the conjugacy class of $h$.
This is great! I was thinking that I could get it to work for H abelian, but I did not consider taking inverse images of conjugacy classes instead of conjugacy classes in inverse images. Very nice.