Skip to content

Commit

Permalink
Discard changes to core/src/test/scala/com/microsoft/azure/synapse/ml…
Browse files Browse the repository at this point in the history
…/recommendation/SARSpec.scala
  • Loading branch information
dciborow authored Sep 7, 2024
1 parent 09557ea commit 11dae03
Showing 1 changed file with 2 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ class SARSpec extends RankingTestBase with EstimatorFuzzing[SAR] {
new TestObject(new SAR()
.setUserCol(recommendationIndexer.getUserOutputCol)
.setItemCol(recommendationIndexer.getItemOutputCol)
.setRatingCol(ratingCol), transformedDf),
new TestObject(new SAR()
.setUserCol(recommendationIndexer.getUserOutputCol)
.setItemCol(recommendationIndexer.getItemOutputCol)
.setRatingCol(ratingCol), transformedDfWithStrings)
.setRatingCol(ratingCol), transformedDf)
)
}

Expand Down Expand Up @@ -66,41 +62,6 @@ class SARSpec extends RankingTestBase with EstimatorFuzzing[SAR] {
assert(recs.count == 2)
}

test("SAR with string userCol and itemCol") {

val algo = sar
.setSupportThreshold(1)
.setSimilarityFunction("jacccard")
.setActivityTimeFormat("EEE MMM dd HH:mm:ss Z yyyy")

val adapter: RankingAdapter = new RankingAdapter()
.setK(5)
.setRecommender(algo)

val recopipeline = new Pipeline()
.setStages(Array(recommendationIndexer, adapter))
.fit(ratingsWithStrings)

val output = recopipeline.transform(ratingsWithStrings)

val evaluator: RankingEvaluator = new RankingEvaluator()
.setK(5)
.setNItems(10)

assert(evaluator.setMetricName("ndcgAt").evaluate(output) === 0.602819875812812)
assert(evaluator.setMetricName("fcp").evaluate(output) === 0.05 ||
evaluator.setMetricName("fcp").evaluate(output) === 0.1)
assert(evaluator.setMetricName("mrr").evaluate(output) === 1.0)

val users: DataFrame = spark
.createDataFrame(Seq(("user0","item0"),("user1","item1")))
.toDF(userColIndex, itemColIndex)

val recs = recopipeline.stages(1).asInstanceOf[RankingAdapterModel].getRecommenderModel
.asInstanceOf[SARModel].recommendForUserSubset(users, 10)
assert(recs.count == 2)
}

lazy val testFile: String = getClass.getResource("/demoUsage.csv.gz").getPath
lazy val simCount1: String = getClass.getResource("/sim_count1.csv.gz").getPath
lazy val simLift1: String = getClass.getResource("/sim_lift1.csv.gz").getPath
Expand Down Expand Up @@ -154,12 +115,7 @@ class SARModelSpec extends RankingTestBase with TransformerFuzzing[SARModel] {
.setUserCol(recommendationIndexer.getUserOutputCol)
.setItemCol(recommendationIndexer.getItemOutputCol)
.setRatingCol(ratingCol)
.fit(transformedDf), transformedDf),
new TestObject(new SAR()
.setUserCol(recommendationIndexer.getUserOutputCol)
.setItemCol(recommendationIndexer.getItemOutputCol)
.setRatingCol(ratingCol)
.fit(transformedDfWithStrings), transformedDfWithStrings)
.fit(transformedDf), transformedDf)
)
}

Expand Down

0 comments on commit 11dae03

Please sign in to comment.