Class BehaviorPattern
- Namespace
- Cratis.Chronicle.Concepts.Patterns
- Assembly
- Cratis.Chronicle.dll
Represents a recurring combination of facets that survived the support and confidence thresholds.
public record BehaviorPattern : IEquatable<BehaviorPattern>
- Inheritance
-
BehaviorPattern
- Implements
- Inherited Members
- Extension Methods
Remarks
Only surviving patterns are persisted, so storage scales with distinct recurring behavior rather than with event volume - a store that appends millions of events but sees a few hundred recurring behaviors holds a few hundred rows here.
Constructors
BehaviorPattern(BehaviorPattern)
protected BehaviorPattern(BehaviorPattern original)
Parameters
originalBehaviorPattern
BehaviorPattern(PatternGroupingKey, FacetSet, PatternOccurrences, PatternConfidence, PatternSupport, PatternWeight, DateTimeOffset, DateTimeOffset)
Represents a recurring combination of facets that survived the support and confidence thresholds.
public BehaviorPattern(PatternGroupingKey GroupingKey, FacetSet Facets, PatternOccurrences Occurrences, PatternConfidence Confidence, PatternSupport Support, PatternWeight Weight, DateTimeOffset FirstSeen, DateTimeOffset LastSeen)
Parameters
GroupingKeyPatternGroupingKeyThe scope the pattern belongs to.
FacetsFacetSetThe FacetSet the pattern is expressed in.
OccurrencesPatternOccurrencesHow many times the pattern has been observed.
ConfidencePatternConfidenceHow often the pattern holds when its context is present.
SupportPatternSupportThe share of all observed events the pattern was seen in.
WeightPatternWeightThe recency-weighted strength of the pattern.
FirstSeenDateTimeOffsetWhen the pattern was first observed.
LastSeenDateTimeOffsetWhen the pattern was last observed.
Remarks
Only surviving patterns are persisted, so storage scales with distinct recurring behavior rather than with event volume - a store that appends millions of events but sees a few hundred recurring behaviors holds a few hundred rows here.
Properties
Action
Gets the action the pattern names, or Unspecified when it is pure context.
public FacetValue Action { get; }
Property Value
Confidence
How often the pattern holds when its context is present.
public PatternConfidence Confidence { get; init; }
Property Value
ContextSpecificity
Gets how much of an asked context the pattern's own context uses - the number of context facets it constrains.
public int ContextSpecificity { get; }
Property Value
Remarks
The specificity of an answer, as opposed to Specificity. Two patterns naming the same action differ by how much of the question they were conditioned on, and the action facet they share tells them apart in neither direction.
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
Facets
The FacetSet the pattern is expressed in.
public FacetSet Facets { get; init; }
Property Value
FirstSeen
When the pattern was first observed.
public DateTimeOffset FirstSeen { get; init; }
Property Value
GroupingKey
The scope the pattern belongs to.
public PatternGroupingKey GroupingKey { get; init; }
Property Value
LastSeen
When the pattern was last observed.
public DateTimeOffset LastSeen { get; init; }
Property Value
Occurrences
How many times the pattern has been observed.
public PatternOccurrences Occurrences { get; init; }
Property Value
Specificity
Gets how specific the pattern is - the number of facets it constrains.
public int Specificity { get; }
Property Value
Support
The share of all observed events the pattern was seen in.
public PatternSupport Support { get; init; }
Property Value
Weight
The recency-weighted strength of the pattern.
public PatternWeight Weight { get; init; }
Property Value
Methods
AnswersFor(FacetSet)
Check whether the pattern answers what usually happens in a context.
public bool AnswersFor(FacetSet context)
Parameters
Returns
- bool
True when the pattern names an action and was established in a context the asked one covers, false when not.
Remarks
The action facet is excluded from the comparison on purpose. A caller asking what somebody usually does on a Monday morning cannot name the command in the question - naming it is what they are asking for - so requiring the whole pattern to be a subset of the question excludes exactly the patterns that answer it.
An answer must also use some of the question. A pattern established in no context at all - "half of what this person ever does is post ledger entries" - is a subset of every context there is, so without this it answers every question identically, including questions about moments the scope has never worked. That would make "nothing is established here" unsayable for anyone with a dominant action, which is the one answer this whole surface exists to be able to give honestly. When the caller names nothing, though, the general behavior is precisely what they asked for, and it is returned.
Deconstruct(out PatternGroupingKey, out FacetSet, out PatternOccurrences, out PatternConfidence, out PatternSupport, out PatternWeight, out DateTimeOffset, out DateTimeOffset)
public void Deconstruct(out PatternGroupingKey GroupingKey, out FacetSet Facets, out PatternOccurrences Occurrences, out PatternConfidence Confidence, out PatternSupport Support, out PatternWeight Weight, out DateTimeOffset FirstSeen, out DateTimeOffset LastSeen)
Parameters
GroupingKeyPatternGroupingKeyFacetsFacetSetOccurrencesPatternOccurrencesConfidencePatternConfidenceSupportPatternSupportWeightPatternWeightFirstSeenDateTimeOffsetLastSeenDateTimeOffset
Equals(BehaviorPattern?)
public virtual bool Equals(BehaviorPattern? other)
Parameters
otherBehaviorPattern
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
Matches(FacetSet)
Check whether the pattern applies to a context.
public bool Matches(FacetSet context)
Parameters
contextFacetSetThe FacetSet describing the context, which may constrain more facets than the pattern does.
Returns
- bool
True when every facet the pattern constrains is present with the same value in the context, false when not.
Remarks
This is the question "does this established pattern describe the situation I am in" - the one worth asking about an action that already happened. It can never return a pattern naming an action the caller did not name, because such a pattern is not a subset of what was asked. Use AnswersFor(FacetSet) for the question that has an action as its answer.
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(BehaviorPattern?, BehaviorPattern?)
public static bool operator ==(BehaviorPattern? left, BehaviorPattern? right)
Parameters
leftBehaviorPatternrightBehaviorPattern
Returns
operator !=(BehaviorPattern?, BehaviorPattern?)
public static bool operator !=(BehaviorPattern? left, BehaviorPattern? right)
Parameters
leftBehaviorPatternrightBehaviorPattern