public Update(string tableName, T values) { _tableName = tableName; _values = ConvertToDictionary.ConvertTo <T>(values); _criterions = new List <Criterion>(); _excludeField = new List <ExcludeField>(); }
public static void Run(double threshhold, int targetUser, IDistance iDistance, Dictionary <int, double[, ]> dataSet, int K) { neighbors = new Dictionary <int, double>(); var userRatings = dataSet[targetUser]; Dictionary <int, List <Tuple <int, double> > > convertedDataSet = ConvertToDictionary.ConvertData(dataSet); foreach (var userID in dataSet.Keys) { if (userID != targetUser) { double similarity = iDistance.ComputeDistance(userRatings, dataSet[userID]); if (similarity > threshhold) { if (hasMoreProductRated(targetUser, userID, convertedDataSet)) { neighbors.Add(userID, similarity); } } } } var sorted = neighbors.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value).Take(K); // var sorted = from pair in neighbors // orderby pair.Value descending // select pair; foreach (var neighbor in sorted) { Console.WriteLine("Neighbor id:" + neighbor.Key + ", similarity " + neighbor.Value); } }
private IList <ExcludeField> _excludeField; //不需要更新的字段 public Update(string tableName, T values, IList <Criterion> criterions, SqlOperator sqlOperator, IList <ExcludeField> excludeField) { _tableName = tableName; _values = ConvertToDictionary.ConvertTo <T>(values); _criterions = criterions; _sqlOperator = sqlOperator; _excludeField = excludeField; }
public void AddValues(T values) { _values = ConvertToDictionary.ConvertTo <T>(values); }
public Insert(string tableName, T values) { _tableName = tableName; _values = ConvertToDictionary.ConvertTo <T>(values); _excludeField = new List <ExcludeField>(); }