Bånder

MusicGenreSimilarityCalculator
in package
implements CalculatorInterface

Table of Contents

Interfaces

CalculatorInterface

Properties

$genreHierarchyService  : GenreHierarchyService

Methods

__construct()  : mixed
analyzeRecommendationQuality()  : array<string|int, mixed>
Analyze recommendation quality for debugging
calculate()  : array<string|int, mixed>
Calculate recommendations based on music genre similarity
calculateExpansionScore()  : float
Calculate genre expansion score (how much a genre can expand user's taste)
calculateGenreDiversity()  : float
Calculate genre diversity score for a collection of genres
calculateGenreSimilarity()  : float
Calculate similarity between two genres
clearCache()  : void
Clear all genre relation caches
findGenreBridges()  : array<string|int, mixed>
Find genre bridges between two sets of genres
getRecommendationWeights()  : array<string|int, mixed>
Get genre recommendation weights for content-based filtering
getRelatedGenres()  : array<string|int, mixed>
Get related genres for a given genre with similarity scores
applyFilter()  : void
Apply a filter to the database query
calculateStringSimilarity()  : float
Calculate string-based similarity as fallback
computeGenreSimilarity()  : float
Actual computation of genre similarity (not cached) - SIMPLIFIED
computeRelatedGenres()  : array<string|int, mixed>
Compute related genres using GenreHierarchyService (simplified)
deduplicateRelationships()  : array<string|int, mixed>
Remove duplicate relationships
findIntermediateGenres()  : array<string|int, mixed>
Find intermediate genres that connect two genres
getAllGenresFromDatabase()  : array<string|int, mixed>
Get all genres from database
getCommonGenres()  : array<string|int, mixed>
Get common genres for comparison
getGenreNamesById()  : array<string|int, mixed>
Get genre names by their IDs
getManualGenreRelationships()  : array<string|int, mixed>
Get manual genre relationships
validateConfiguration()  : void
Validate that required configuration parameters are present
validateRecommendationQuality()  : array<string|int, mixed>
Validate recommendation quality

Properties

Methods

analyzeRecommendationQuality()

Analyze recommendation quality for debugging

public analyzeRecommendationQuality(array<string|int, mixed> $recommendations, array<string|int, mixed> $songGenres, array<string|int, mixed> $genreNames) : array<string|int, mixed>
Parameters
$recommendations : array<string|int, mixed>
$songGenres : array<string|int, mixed>
$genreNames : array<string|int, mixed>
Return values
array<string|int, mixed>

calculate()

Calculate recommendations based on music genre similarity

public calculate(mixed $sourceData, array<string|int, mixed> $configuration) : array<string|int, mixed>
Parameters
$sourceData : mixed

Source model(s) to calculate recommendations for

$configuration : array<string|int, mixed>

Configuration parameters for calculation

Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

Array of recommendations [sourceId => [targetId => score]]

calculateExpansionScore()

Calculate genre expansion score (how much a genre can expand user's taste)

public calculateExpansionScore(string $newGenre, array<string|int, mixed> $userGenres) : float
Parameters
$newGenre : string
$userGenres : array<string|int, mixed>
Return values
float

calculateGenreDiversity()

Calculate genre diversity score for a collection of genres

public calculateGenreDiversity(array<string|int, mixed> $genres) : float
Parameters
$genres : array<string|int, mixed>
Return values
float

calculateGenreSimilarity()

Calculate similarity between two genres

public calculateGenreSimilarity(string $genre1, string $genre2) : float
Parameters
$genre1 : string
$genre2 : string
Return values
float

findGenreBridges()

Find genre bridges between two sets of genres

public findGenreBridges(array<string|int, mixed> $sourceGenres, array<string|int, mixed> $targetGenres[, int $limit = 5 ]) : array<string|int, mixed>
Parameters
$sourceGenres : array<string|int, mixed>
$targetGenres : array<string|int, mixed>
$limit : int = 5
Return values
array<string|int, mixed>

getRecommendationWeights()

Get genre recommendation weights for content-based filtering

public getRecommendationWeights(array<string|int, mixed> $userGenres, array<string|int, mixed> $candidateGenres) : array<string|int, mixed>
Parameters
$userGenres : array<string|int, mixed>
$candidateGenres : array<string|int, mixed>
Return values
array<string|int, mixed>

getRelatedGenres()

Get related genres for a given genre with similarity scores

public getRelatedGenres(string $genre[, int $limit = 10 ]) : array<string|int, mixed>
Parameters
$genre : string
$limit : int = 10
Return values
array<string|int, mixed>

applyFilter()

Apply a filter to the database query

private applyFilter(Builder $query, string $field, mixed $filterConfig) : void
Parameters
$query : Builder
$field : string
$filterConfig : mixed

calculateStringSimilarity()

Calculate string-based similarity as fallback

private calculateStringSimilarity(string $genre1, string $genre2) : float
Parameters
$genre1 : string
$genre2 : string
Return values
float

computeGenreSimilarity()

Actual computation of genre similarity (not cached) - SIMPLIFIED

private computeGenreSimilarity(string $genre1, string $genre2) : float
Parameters
$genre1 : string
$genre2 : string
Return values
float

computeRelatedGenres()

Compute related genres using GenreHierarchyService (simplified)

private computeRelatedGenres(string $genre, int $limit) : array<string|int, mixed>
Parameters
$genre : string
$limit : int
Return values
array<string|int, mixed>

deduplicateRelationships()

Remove duplicate relationships

private deduplicateRelationships(array<string|int, mixed> $relationships) : array<string|int, mixed>
Parameters
$relationships : array<string|int, mixed>
Return values
array<string|int, mixed>

findIntermediateGenres()

Find intermediate genres that connect two genres

private findIntermediateGenres(string $sourceGenre, string $targetGenre) : array<string|int, mixed>
Parameters
$sourceGenre : string
$targetGenre : string
Return values
array<string|int, mixed>

getAllGenresFromDatabase()

Get all genres from database

private getAllGenresFromDatabase() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCommonGenres()

Get common genres for comparison

private getCommonGenres() : array<string|int, mixed>
Return values
array<string|int, mixed>

getGenreNamesById()

Get genre names by their IDs

private getGenreNamesById(array<string|int, mixed> $genreIds) : array<string|int, mixed>
Parameters
$genreIds : array<string|int, mixed>
Return values
array<string|int, mixed>

getManualGenreRelationships()

Get manual genre relationships

private getManualGenreRelationships(string $genre) : array<string|int, mixed>
Parameters
$genre : string
Return values
array<string|int, mixed>

validateConfiguration()

Validate that required configuration parameters are present

private validateConfiguration(array<string|int, mixed> $configuration) : void
Parameters
$configuration : array<string|int, mixed>
Tags
throws
InvalidArgumentException

validateRecommendationQuality()

Validate recommendation quality

private validateRecommendationQuality(array<string|int, mixed> $recommendations, array<string|int, mixed> $songGenres) : array<string|int, mixed>
Parameters
$recommendations : array<string|int, mixed>
$songGenres : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results