Ahead of the Shanghai Masters final, Roger Federer believes his losses to Rafael Nadal have made him a better player over the years.

Nadal and Federer have both had career resurgences in 2017 after taking time away to recover from injury, with the duo winning a combined 11 titles so far, including splitting the four Grand Slams between each other.

However, despite the Spaniard boasting a superior 23-14 head-to-head record, Federer has won their last three meetings in 2017.

Their first meeting of the year came in the final of the Australian Open where the Swiss ace triumphed in a five-set thriller to win his first Grand Slam since 2012.

They would meet twice more with Federer beating Nadal in straight sets in Indian Wells and Miami.

However, since his last loss to the 35-year-old, Nadal has been on fire, winning the French Open and US Open as well as titles in Monte Carlo, Barcelona, Madrid and Beijing.

With Nadal also currently on a 15-match winning streak, Federer spoke of how it was nice that they are still meeting in important matches while praising the world number one for helping him improve as a player.

"I don't want to thank him for that, but he made me maybe rework my game and go back to the practice courts and think about what I could change maybe to become a better player," Federer, ranked world number two said, as quoted by Express.

"I think for that I'm happy about the losses I took. Took them on the chin and kept moving forward.

"It's nice at this late stage of the career that we still have these matches going on."

Federer will play Nadal in the Shanghai final on Sunday (October 15) with this likely being the Basel native's last chance to stake a claim for the year-end world number one spot.

Rafael Nadal and Roger Federer
Nadal and Federer have both returned to their best this year Getty