Ok... some pseudo code to think about...
Input baseline humidity sensor
Input bathroom sensor.
Input high threshold. (e.g 25%)
Input low threshold (e.g 5%)
If bathroom sensor > (Baseline sensor + high threshold)
Then turn on fan
If bathroom sensor < (baseline sensor + low threshold)
Turn off fan
The fan would turn on once the % above baseline was reached
then turn off again once it went down to baseline or just above (low threshold)