A west suburban man was caught stalking his ex-girlfriend early Saturday in Riverside, police said.

The 38-year-old woman called for help about 5:30 a.m., saying someone who looked like her ex had tried to get into her home in the 200 block of West Quincy and then ran into a wooded area across the street, according to a statement from Riverside police.

Officers spotted a man walking near the woods about a third of a mile away in the 3300 block of South 1st Avenue, and the victim identified him as 41-year-old Benjamin G. Alvarez, police said.

Alvarez, who was carrying a flashlight, told officers he was walking in the woods for relaxation and “ninja training,” police said. He had removed the woman’s porch lights and tried to disable her home security system before officers arrived, police said.

“I believe that if the victim had not spotted him just prior to him walking on her property and called police immediately, we may have been investigating a more serious incident,” Riverside Police Chief Tom Weitzel said in the statement.

Alvarez, of the 3800 block of Hollywood Avenue in Brookfield, was charged with a felony count of stalking and has been released from jail after posting 10 percent of a $200,000 bond, according to Cook County Circuit Court records. He is due in court again Friday.

Alvarez was charged in 2014 with a felony count of aggravated battery against the woman, who was pregnant, court records show. He later pleaded guilty to a misdemeanor count of domestic battery.