In 1948 , the British-ruled territories on the Malay Peninsula formed the Federation of Malaya , which became independent in 1957 .