I have a definition calculation cosine similarity for each combination coming from a matrix. However, I want the definition runs under some certain conditions.
The definition is given below:
def neighbours(signatures: Iterable[Signature], minCosineSimilarity: Double): Iterator[MatrixEntry] = {
signatures.
toSeq.
sortBy(_.index). // sort in order to create an upper triangular matrix
combinations(2)
.map {
case first :: other :: nil =>
if((first.index < 4 && other.index > 3) || (first.index > 3 && other.index < 4)){}
val cosine = Cosine(first.vector, other.vector)
MatrixEntry(first.index, other.index, cosine)
}.
filter(_.value >= minCosineSimilarity)
}
It calculates cosine similarity for a given pair coming from "combinations(2)" line. I have added a line containing if statement. How can I make this if condition valid here?
Aucun commentaire:
Enregistrer un commentaire