private FeatureVector ComputeFeatureVector(L7Conversation l7Conversation, string applicationName) { var featureVector = new FeatureVector { ApplicationProtocolName = l7Conversation.AppTagShort, ApplicationProtocolNameFull = applicationName }; Parallel.ForEach(featureVector.GetType().GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(FeatureStatisticalAttribute))), feature => { feature.SetValue(featureVector, Activator.CreateInstance(feature.PropertyType, l7Conversation)); }); return(featureVector); }
public void Normalize(FeatureVector stat) { var t = stat.GetType(); foreach (var property in t.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(FeatureStatisticalAttribute)))) { var name = property.Name; var feature = property.GetValue(stat, null); var propertyInfo = feature.GetType().GetProperty(nameof(FeatureBase.FeatureValue)); var propertyValue = (double)propertyInfo.GetValue(feature, null); if (!propertyValue.Equals(-1.0)) { propertyInfo.SetValue(feature, Utilities.Z_score((double)propertyInfo.GetValue(feature, null), this.GetPropValue(this.Mean, name), this.GetPropValue(this.StdDev, name)), null); } } }
private FeatureVector constructFeatureVectorFromProperties(List <double> standardizedVectorList) { FeatureVector featureVector = new FeatureVector(); Type type = featureVector.GetType(); PropertyInfo[] properties = type.GetProperties(); /* * The minus 3 is so we skip the last 3 properties * in the feature vector class. Those get assigned * when the user assigns a name to the gesture. */ for (int propertyIndex = 0; propertyIndex < properties.Length - 3; propertyIndex++) { PropertyInfo property = properties[propertyIndex]; property.SetValue(featureVector, standardizedVectorList[propertyIndex], null); } return(featureVector); }