public void Train(IUserItemRelation data) { var deviationsMatrix = data.Secondary.Select(item => CreateVector(item, data)) .CrossPairwise((vector1, vector2) => ComputeDeviations(vector1, vector2)) .ToMatrix(t => t.Item1, t => t.Item2, t => t.Item3); throw new NotImplementedException(); }
private NamedVector <NamedValue> CreateVector(Item item, IUserItemRelation data) { var associated = data.Association .Where(jr => item.Name.Equals(jr.Second.Name)); return(new NamedVector <NamedValue>(item.Name, associated.Select(jr => new NamedValue(jr.First.Name, jr.Value)) .ToList())); }
public Matrix <double> BuildSimilarityMatrix(IUserItemRelation data) { var userAverages = data.Primary.ToDictionary(u => u.Name, u => data.Association.GetRecords(u).Average(jr => jr.Value)); return(data.Secondary.Select(item => CreateVector(item, data)) .CrossPairwise((vector1, vector2) => ComputeSimilarity(vector1, vector2, userAverages)) .ToMatrix()); }
public void Train(IUserItemRelation data) { _correlationLookup = ConvertToVectors(data) .CrossPairwise((vector1, vector2) => _algorithm.ComputeCorrelation(vector1, vector2)) .ToCorrelationLookup(); _bundledItems = data.Primary.Select(u => CreateBundledItem(u, data.Association)) .ToDictionary(b => b.Item.Name); IsTrained = true; }
public void Train(IUserItemRelation data) { _items = data.Secondary.ToDictionary(i => i.Name); _similarityMatrix = _algorithm.BuildSimilarityMatrix(data); IsTrained = true; }