This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRecommendations($array, $person, $type) { | |
$totals = array(); | |
$simSums = array(); | |
$rankings = array(); | |
foreach ($array as $other => $v) { | |
if ($other == $person ){ | |
continue; | |
} elseif($type == 'pearson') { | |
$simulate = sim_pearson($array[$person], $array[$other]); | |
if($simulate <= 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sim_distance($person1, $person2){ | |
$si = array(); | |
foreach ($person1 as $k => $v) { | |
if (array_key_exists($k, $person2)) { | |
$si[$k] = 1; | |
} | |
} | |
if (count($si) == 0) { | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$critics=array('Lisa Rose'=> array('Lady in the Water' =>2.5, 'Snakes on a Plane' =>3.5, | |
'Just My Luck'=> 3.0, 'Superman Returns'=> 3.5, 'You, Me and Dupree'=> 2.5, | |
'The Night Listener'=> 3.0), | |
'Gene Seymour' => array('Lady in the Water'=> 3.0, 'Snakes on a Plane'=> 3.5, | |
'Just My Luck'=> 1.5, 'Superman Returns'=> 5.0, 'The Night Listener'=> 3.0, | |
'You, Me and Dupree'=> 3.5), | |
'Michael Phillips'=> array('Lady in the Water'=> 2.5, 'Snakes on a Plane'=> 3.0, | |
'Superman Returns'=> 3.5, 'The Night Listener'=> 4.0), | |
'Claudia Puig'=> array('Snakes on a Plane'=> 3.5, 'Just My Luck'=> 3.0, | |
'The Night Listener'=> 4.5, 'Superman Returns'=> 4.0, |
NewerOlder