Installing a ceiling fan into a socket with 3 wires jammed into the socket
I have a couple of observations and concerns.  First, it looks like this is a shallow box with conduit or EMT connectors. The looping conductors are usually a sign of continuous run THHN.  I also suspect this could be a 3-way switched circuit or the yellow is being used as grounding/bonding conductor.  However testing must be done to confirm these suspicions.

The other concern I have is the ability of this box to support the weight and torque of a fan. Depending on how strong the mounting is, you may want to consider a weight rated fan mounting box. If the box is not securely mounted, your fan will be unbalanced and wobble, at worse, it will pull the box out of the ceiling and drop. Perhaps they don't show in your pic, but I don't see any screws mounting the box to a framing member. If it is secured in place by the conduit only or a flimsy side ear mount, it will not work well for a fan.  Check it out carefully.  Good Luck.