Researchers have developed a new algorithm that can identify individuals who may be headed for self-harm before obvious warning signs appear.