def _detect(self, score_only):
try:<EOL><INDENT>algorithm = self.algorithm(**self.algorithm_params)<EOL>self.anom_scores = algorithm.run()<EOL><DEDENT>except exceptions.NotEnoughDataPoints:<EOL><INDENT>algorithm = anomaly_detector_algorithms['<STR_LIT>'](self.time_series)<EOL>self.threshold = self.threshold or ANOMALY_THRESHOLD['<STR_LIT>']<EOL>self.anom_scores = algorithm.run()<EOL><DEDENT>if not score_only:<EOL><INDENT>self._detect_anomalies()<EOL><DEDENT>
Detect anomaly periods.
:param bool score_only: if true, only anomaly scores are computed.