Kayıtlar

Mart, 2014 tarihine ait yayınlar gösteriliyor

Similarity Methods (Cosine Similarty, L1 Distance, KullbackLeibler, Simetric KullbackLeibler, JensenShannon) in C#

 public static double CosineSimilarty(double[] q, double[] d)         {             if (d == null || q == null) return 0;             if (q.Length != d.Length) throw new Exception("both vectors must be of similar length");             // Calculate cosine similarity:             double numer = 0;             double denom = 1;             double d1 = 0, d2 = 0;                 for (int m = 0; m < q.Length; m++)             {                 numer += (q[m] * d[m]);                             d1 += (q[m] * q[m]);                 d2 += (d[m] * d[m]);   ...

T-SQL WITH

USE AdventureWorks2012; GO -- Define the CTE expression name and column list. WITH Sales_CTE (SalesPersonID, SalesOrderID, SalesYear) AS -- Define the CTE query. ( SELECT SalesPersonID, SalesOrderID, YEAR(OrderDate) AS SalesYear FROM Sales.SalesOrderHeader WHERE SalesPersonID IS NOT NULL ) -- Define the outer query referencing the CTE name. SELECT SalesPersonID, COUNT(SalesOrderID) AS TotalSales, SalesYear FROM Sales_CTE GROUP BY SalesYear, SalesPersonID ORDER BY SalesPersonID, SalesYear; GO source : http://msdn.microsoft.com/en-us/library/ms175972.aspx