Skip to content

Commit

Permalink
Merge pull request #1691 from microsoft/andreas/exp_var
Browse files Browse the repository at this point in the history
Use numpy divide in explained variance
  • Loading branch information
miguelgfierro authored Mar 31, 2022
2 parents 7721857 + 75485fe commit f52cef2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# What's New

## Update March 31, 2022
## Update April 1, 2022

We have a new release [Recommenders 1.1.0](https://github.com/microsoft/recommenders/releases/tag/1.1.0)!
We have introduced the SASRec and SSEPT algorithms that are based on transformers.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Documentation Status](https://readthedocs.org/projects/microsoft-recommenders/badge/?version=latest)](https://microsoft-recommenders.readthedocs.io/en/latest/?badge=latest)

## What's New (March 31, 2022)
## What's New (April 1, 2022)

We have a new release [Recommenders 1.1.0](https://github.com/microsoft/recommenders/releases/tag/1.1.0)!
We have introduced the SASRec and SSEPT algorithms that are based on transformers.
Expand Down
4 changes: 3 additions & 1 deletion recommenders/evaluation/spark_evaluation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import numpy as np
try:
from pyspark.mllib.evaluation import RegressionMetrics, RankingMetrics
from pyspark.sql import Window, DataFrame
Expand Down Expand Up @@ -158,7 +159,8 @@ def exp_var(self):
0
]
var2 = self.y_pred_true.selectExpr("variance(label)").collect()[0][0]
return 1 - var1 / var2
# numpy divide is more tolerant to var2 being zero
return 1 - np.divide(var1, var2)


class SparkRankingEvaluation:
Expand Down

0 comments on commit f52cef2

Please sign in to comment.