I want to find the price of a new-item based on the average prices of similar items.
The function get-k-similar uses k-Nearest Neighbors but returns me this output
((list rating age price) proximity)
.
For example, 2-similar would be:
(((5.557799748150248 3 117.94262493533647) . 3.6956648993026904)
((3.0921378389849963 7 75.61492560596851) . 5.117886776721699))
I need to find the average PRICE of the similar items. i.e Average of 117 and 75. Is there a better way to iterate? My function looks too ugly.
(define (get-prices new-item)
(define (average-prices a-list)
(/ (cdr
(foldl (λ(x y) (cons (list 0 0 0)
(+ (third (car x)) (third (car y)))))
(cons (list 0 0 0) 0)
a-list))
(length a-list)))
(let ((similar-items (get-k-similar new-item)))
(average-prices similar-items)))