public async Task <(double[, ] similarityMatrix, int[] ids)> FindSimilarities() { var context = new Database.DatabaseContext(_dbContextOptions); var movies = await context.Movies .Include(m => m.Tags) .Include(m => m.Creators) .ToListAsync(); var movieVectorizer = new MovieVectorizer(Tags, context.Creators); var weights = new MovieVectorizer.Weights { Year = 3.0f, Tags = 2.0f, Rating = 1.0f, Descriptions = 5.0f, Creators = 2.0f }; var vectorizedMovies = await movieVectorizer.Vectorize(movies, weights); var stringifiedMatrix = Matrix.MatrixToString(vectorizedMovies); var similarityMatrix = await PythonMethods.FindSimilarities(stringifiedMatrix); var ids = movies.Select(m => m.Id).ToArray(); return(similarityMatrix, ids); }
public async Task <double[, ]> VectorizeDescriptions(IEnumerable <string> descriptions, float weight = 1.0f) { var vectorizedDescriptions = await PythonMethods.VectorizeDocumentsTFIDF(descriptions); return(FilterVectorizedDescriptions(vectorizedDescriptions, weight, 20)); }