Anomaly Detection and Machine Learning: How AI Learns What Normal Looks Like

The most powerful thing about AI security isn't that it detects threats. It's that it learns what your environment looks like when nothing is wrong.

Miguel Castro
Co-founder, Closely
August 4, 202616 min read
anomaly detection machine learningAI anomaly detectionmachine learning securityphysical security AI
Split diagram with a machine learning model at the center: on the left, cameras showing a warehouse, school corridor and residential lobby marked as learned baseline at 98% normal; on the right, the same kind of feeds flagged as anomalies — a person at 3 AM, a vehicle stopped in a restricted zone, and someone loitering after hours

You can't reliably detect something abnormal without a precise definition of normal. Traditional security systems — motion sensors, fixed thresholds, rule-based triggers — apply static definitions that break down in environments where normal activity is complex and context-dependent. Machine learning anomaly detection replaces those static rules with learned baselines: the system observes each camera location over time, learns what normal looks like at each hour, and flags deviations. That shift from manually-defined rules to continuously-updated baselines is what makes AI anomaly detection dramatically more accurate than rule-based alternatives.

Why "normal" is the most important word in security

Here's something that sounds obvious once you hear it but changes how you think about security systems entirely: you can't reliably detect something abnormal if you don't have a precise definition of normal.

Traditional security systems are built around static definitions of what counts as a problem. A motion sensor fires when anything moves. A door alarm triggers when a contact is broken. A temperature sensor alerts when a reading exceeds a fixed ceiling. These rules work in simple, controlled environments where threats always look the same. They break down quickly in real-world security environments where normal activity is complex, variable, and context-dependent.

A loading dock at a warehouse in Chicago looks completely different at 9am on a Tuesday versus 3am on a Sunday. A school corridor has a very different baseline during lunch hour versus during class time versus during an after-school event. A residential building lobby in Bogotá behaves differently on a weekday morning than on a Saturday evening. A rule that flags "more than five people near the entrance" is useless in an environment where the lobby routinely has fifteen people during peak hours and zero at 2am.

Anomaly detection using machine learning solves this by replacing static rules with learned baselines. Instead of someone manually defining what counts as suspicious, the system observes the environment over time, learns what normal looks like at each location and each time of day, and flags deviations from that learned baseline. The definition of "abnormal" becomes dynamic, contextual, and continuously updated.

How machine learning anomaly detection actually works

Learning the baseline: the foundation of everything

Every machine learning anomaly detection system starts with the same fundamental step: establishing what normal looks like. This is called the baseline, and building it is where machine learning does most of its heavy lifting.

For a security camera system, building the baseline means processing large volumes of historical footage from each camera location — hours, days, weeks of footage — and learning the statistical distribution of everything the camera sees. How many people typically pass through this frame at this time of day? What speeds and directions of movement are typical? What object types are normally present? How does the scene change between day and night, between weekdays and weekends, between high-traffic and low-traffic periods?

The models that do this work — typically convolutional neural networks for visual pattern recognition combined with temporal models for understanding how scenes change over time — build a rich, multidimensional model of normal at each camera location. This isn't a single threshold. It's a complex statistical portrait that varies continuously with time, context, and environmental conditions.

Once the baseline is established, anomaly detection becomes a comparison problem: how does what the camera sees right now compare to what it's learned to expect at this location, at this time, in these conditions? Events within the expected distribution generate no alert. Events that deviate significantly are flagged.

The three-tier detection pipeline

The architectural challenge in AI anomaly detection is balancing accuracy against cost and speed. Running a sophisticated model on every frame of every camera feed continuously would produce the most accurate results — and would also be prohibitively expensive and slow across large camera fleets.

The solution that works in production is a cascaded pipeline where increasingly sophisticated analysis is applied only to events that pass earlier, simpler filters:

Tier 1 — Motion and change detection. Basic computer vision identifies frames where the scene has changed compared to the static background. This filters out the vast majority of footage immediately: if nothing has changed, nothing needs anomaly analysis. Computationally cheap and extremely fast.

Tier 2 — Object detection and classification. A dedicated computer vision model analyzes the frames that passed tier 1 and determines whether the change involves a relevant object: a person, a vehicle, an object of interest. This filters false positives from environmental changes (lighting shifts, weather, reflections) and irrelevant motion (animals, mechanical movement). Only frames with relevant objects proceed.

Tier 3 — Behavioral reasoning and anomaly scoring. The most sophisticated layer, where contextual reasoning is applied. Given what this camera has learned about its location, given the time of day, given the behavior of the detected object over the last several minutes — is this event anomalous? The model assigns a confidence score, and only events above a defined threshold generate an alert.

This cascaded architecture is what makes AI anomaly detection economically viable at scale. The expensive tier-3 reasoning only processes a small fraction of total footage — the events that already passed two rounds of filtering. Inference costs stay manageable while detection accuracy is maintained.

What makes an event an anomaly

In physical security, the events that get flagged deviate from the learned baseline in meaningful ways. In practice, this includes four categories:

Temporal anomalies — activity at times when it's statistically unexpected. A person in a warehouse at 3am when the building has never had human presence at that hour. A vehicle in a parking structure long after the last authorized exit.

Behavioral anomalies — activity patterns that deviate from expected behavior for that location. A person remaining stationary where people normally move through quickly (loitering). A person moving counter to the established flow for that space.

Frequency anomalies — events occurring more or less often than the baseline predicts. Ten people near a single access point when the normal peak is two or three. Zero people in a space that's normally occupied at this hour.

Object anomalies — object types that aren't normally part of the scene. A package left where objects are never left. A vehicle type that doesn't match the profile for that parking area.

The sophistication of modern systems is that these types are detected simultaneously, contextually, and with probabilistic confidence rather than binary triggers — which is what produces usable alerts rather than alarm floods.

Why machine learning beats rule-based systems

The case for machine learning anomaly detection isn't just about accuracy — it's about operational sustainability.

Rule-based systems require someone to manually define every rule. Security experts need to anticipate every possible threat scenario, translate it into a specific trigger condition, and keep those rules updated as environments change, as threat patterns evolve, and as operational needs shift. In a complex, dynamic environment this is a never-ending and ultimately losing battle. Rules that work today fail when conditions emerge that no one anticipated.

Machine learning systems learn rules from data rather than having them hard-coded. When the environment changes — a new workflow in a warehouse, a new tenant in an office building, a seasonal shift in traffic — the model updates its baseline without manual reconfiguration. When new threat patterns emerge, the model detects deviations from normal even when no specific rule for that threat exists.

This adaptability is what makes AI anomaly detection increasingly essential for complex environments with many cameras, many locations, and dynamic operating conditions — exactly the environments that the largest security operators in the US and Latin America manage today. It's also the mechanism behind reducing false alarm fatigue, which is the single biggest drain on operator attention in most monitoring centers.

According to the 2026 World Security Report, 44% of chief security officers globally classify AI-driven threat detection and risk assessment as crucial for their operations over the next two years — placing it among the top three security technology priorities alongside AI-powered video surveillance and AI-powered intrusion detection. The signal across 2,352 security leaders in 31 countries is consistent: machine learning anomaly detection is no longer a differentiating capability for advanced organizations. It's becoming a baseline expectation.

Where anomaly detection is being applied

Security operations centers

The SOC is where AI anomaly detection has the most immediate operational impact. A mid-sized monitoring center managing 500 cameras across 20 client sites generates an enormous volume of events each day. Without machine learning filtering, operators face an alert stream they can't meaningfully process — and the result is alert fatigue, missed detections, and inconsistent response quality.

Machine learning transforms the SOC workflow. Instead of operators watching raw feeds and making real-time judgments about every motion event, the system pre-filters using learned baselines for each camera. What reaches operators is a curated set of genuine anomalies — events the model determined are meaningfully different from what this specific camera normally sees at this specific time.

The operational result is that operators spend their time on decisions, not on filtering. Response quality improves because attention is directed where it's actually needed. Coverage scales without proportional headcount growth, which is the core constraint behind why security centers struggle to scale.

Industrial and logistics facilities

Large industrial facilities — manufacturing plants, logistics hubs, port facilities — have security environments characterized by complex, variable operational patterns that make rule-based detection nearly useless. The same area with high legitimate traffic during a shift has zero authorized activity between shifts. Loading dock patterns vary by day, by season, by operational schedule.

Machine learning is particularly well-suited here because it learns the specific operational patterns of each facility rather than applying generic rules. An anomaly in a warehouse is defined relative to what that specific warehouse looks like under normal conditions — not relative to generic industry benchmarks.

Residential security and building management

In residential security — especially in LATAM markets where buildings and gated communities rely on security companies for remote monitoring — AI anomaly detection lets centralized SOCs monitor dozens of buildings without per-building staffing.

Each building's cameras develop their own learned baseline: what the lobby looks like at 7am on a weekday, what the parking entry looks like during evening peak, what the perimeter looks like at 2am. Anomalies are detected relative to those building-specific baselines — a person present in the lobby at an unusual hour at one building generates a different alert than the same scene at a building where that pattern is normal.

Retail and commercial properties

Retail benefits from systems that learn the traffic and behavioral patterns of each store. The definition of suspicious behavior is highly location-specific: what's normal at a flagship store in Miami is not normal at a small-format location in Medellín. A crowd near the exit is normal at closing time; the same crowd 30 minutes before opening is not.

The same anomaly detection that catches shoplifting patterns also provides behavioral analytics — traffic flows, dwell times in specific zones, conversion-relevant behaviors — that have value beyond pure security.

How Closely implements anomaly detection

Closely is built around the architecture described above — not as a theoretical framework, but as the operational core of how the platform delivers security intelligence.

Closely's three-layer pipeline — motion trigger, then YOLOv8 computer vision, then Claude Vision reasoning — implements the cascaded architecture that makes AI anomaly detection viable at scale. The reasoning layer evaluates every flagged event against what normal looks like at that specific camera. Detection rules are configured per camera in natural language, so the baseline reflects how each location actually operates rather than a generic template.

Every alert goes to a human operator for validation before dispatch. The output is a pre-scored alert stream where genuine anomalies reach operators with the context needed to decide — not an undifferentiated alert flood.

Every anomaly generates a structured incident record: camera location, timestamp, anomaly type, confidence score, visual evidence, operator response, and outcome. Those records accumulate across an operator's entire camera fleet and create an operational intelligence layer that compounds over time. Individual detections are useful for immediate response. Aggregated data across hundreds of sites over months reveals patterns that inform strategic decisions: which sites have the highest anomaly frequency, which time windows are consistently elevated risk, which detection types are overrepresented at specific client locations.

Closely connects through your existing NVR — Dahua, Hikvision, Milestone, or any RTSP-compatible system — so the anomaly detection layer works on the cameras you already have.

If you run a monitoring center in the US or Latin America and you're evaluating whether AI will make your operation genuinely more effective or just generate a different kind of noise, get in touch.

Frequently Asked Questions

What is anomaly detection in physical security and how does machine learning make it work?

Anomaly detection in security is the process of identifying events or behaviors that deviate significantly from what's expected in a given environment at a given time. Machine learning makes this work by training models on historical camera footage to build a statistical baseline of normal behavior for each location, then comparing real-time events against that baseline. The key advantage over rule-based systems is that the definition of normal is learned from data and updated continuously, rather than manually defined and static.

What's the difference between rule-based security alerts and machine learning anomaly detection?

Rule-based systems use fixed, manually-defined triggers: alert when motion exceeds a threshold, when a door is open more than 60 seconds, when more than N people are in a zone. Machine learning systems learn what normal looks like at each specific location and flag deviations, even when no specific rule for that deviation exists. In practice, rule-based systems generate enormous false positive volumes and miss novel threats, while machine learning systems adapt to variable environments with a much higher signal-to-noise ratio.

How long does it take for a machine learning system to learn a camera's baseline?

The baseline learning period varies by system and environment complexity, but most platforms require between one and four weeks of observation to build a reliable baseline for a typical camera location. Complex environments with high variability — seasonal patterns, highly variable operating schedules — benefit from longer periods. During the learning phase, systems typically operate in observation mode, logging detections without generating full alerts, until the model has enough data for reliable assessments.

What types of anomalies can machine learning detect?

Modern systems identify temporal anomalies (activity at unexpected times), behavioral anomalies (unusual movement patterns, loitering, counter-flow movement), frequency anomalies (more or fewer people and objects than expected), and object anomalies (unexpected object types or left-behind items). The specific capability depends on the training data and architecture of the model. Mature platforms combine multiple detection types in a unified scoring framework rather than treating each type independently.

How does anomaly detection handle environments where normal changes over time?

Good systems use continuous or periodic baseline updating — the model doesn't fix the baseline at the end of the initial learning period but keeps updating as it observes more data. This means the system adapts when patterns change: a new tenant moves into an office building, a warehouse shifts its operating hours, a seasonal peak changes retail traffic. The adaptation is typically gradual, using time-weighted averaging that favors recent observations while retaining longer-term patterns.

What is the false positive rate in AI anomaly detection, and how is it managed?

False positive rates vary significantly by system architecture and deployment quality. The primary management mechanism is the cascaded pipeline: events must pass motion filtering, object classification, and behavioral reasoning before generating an alert. Confidence scoring at the final tier lets operators tune sensitivity — higher thresholds produce fewer but higher-confidence alerts, lower thresholds catch more events at the cost of more false positives. For most deployments, a threshold generating 10 to 20 alerts per operator per shift is a practical target.

Can machine learning anomaly detection work with different cameras and recording hardware?

Yes. Platforms that connect via standard protocols (RTSP and ONVIF) work with any IP camera that provides a video stream, regardless of manufacturer. Closely connects to Dahua, Hikvision, Milestone, and any RTSP-compatible system. The models operate on the video stream, not on proprietary camera data, so the capability is hardware-agnostic. Camera resolution and frame rate affect detection accuracy — higher is generally better — but the baseline learning framework works across a heterogeneous fleet.

How is machine learning anomaly detection being used in Latin America?

In Latin America, it's primarily deployed by security operators managing residential buildings, commercial properties, and industrial facilities from centralized monitoring centers. The operational challenge — hundreds of cameras across dozens of client sites with limited operator headcount — is exactly what this technology addresses. Adoption is accelerating across Colombia, Mexico, Brazil, and Chile, driven by rising labor costs, expanding camera deployments, and operators seeking to differentiate their service. According to the 2026 World Security Report, LATAM security officers cite AI-driven threat detection as crucial at 46% — above the global average of 44%.

What data does anomaly detection generate, and can it be used beyond immediate response?

Every anomaly generates a structured record: timestamp, camera location, anomaly type, confidence score, visual evidence, and response data. At scale, this data has value beyond immediate response. Aggregated across a camera network, it reveals risk patterns by location, time, and event type that are useful for strategic security deployment, client SLA reporting, and compliance documentation. At larger scale it supports institutional data products such as insurance risk underwriting inputs and logistics safety scoring.

What should I look for when comparing AI security platforms on anomaly detection?

Look past the detection claim itself. Ask three questions: does the platform learn a baseline per camera or apply generic rules across the fleet; does every alert pass through human validation before dispatch; and does it produce structured incident records you can query later. Many platforms focus exclusively on surfacing alerts. The difference that matters operationally is whether detection feeds a workflow — prioritization, human-in-the-loop validation, structured documentation — or just adds another stream for your operators to triage.

Miguel Castro
Co-founder, Closely
Closely · Bogotá, Colombia

Closely

See Closely in action.

Book a demo and see how AI agents transform your security operation — detection, dispatch, and reporting in one platform.

Book demo