Take into account that the cosine of an angle is given by:
cos B = length of the adjacent side / hypotenuse
in this case, you have:
length of adjacent side to B = BC
hypotenuse = AB
replace the previous values of the parameters into the formula for cos B:
cos B = BC/AB
Moreover, due to BC and AB are similar to EF and DE respectively, you have for cos B:
cos B = EF/DE