Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SynapseML docs: Wrong variable referenced in code example in docs in "Interpretability - Explanation Dashboard" wrapper class #1555

Open
glogowski-wojciech opened this issue Jul 7, 2022 · 2 comments

Comments

@glogowski-wojciech
Copy link

glogowski-wojciech commented Jul 7, 2022

Wrong variable referenced in code example in docs in "Interpretability - Explanation Dashboard" wrapper class
In https://microsoft.github.io/SynapseML/docs/features/responsible_ai/Interpretability%20-%20Explanation%20Dashboard/ in the class wrapper there is:

class wrapper(object):
  [...]
  def predict(self, data):
    [...]
    return model.transform(sparkdata).select('prediction').toPandas().values.flatten().tolist()
  
  def predict_proba(self, data):
    [...]
    prediction = model.transform(sparkdata).select('probability').toPandas().values.flatten().tolist()
    [...]

which I believe should refer to self.model instead of just model:

class wrapper(object):
  [...]
  def predict(self, data):
    [...]
    return self.model.transform(sparkdata).select('prediction').toPandas().values.flatten().tolist()
  
  def predict_proba(self, data):
    [...]
    prediction = self.model.transform(sparkdata).select('probability').toPandas().values.flatten().tolist()
    [...]

Full body of the snippet for context:

class wrapper(object):
  def __init__(self, model):
    self.model = model

  def predict(self, data):
    sparkdata = spark.createDataFrame(data)
    return model.transform(sparkdata).select('prediction').toPandas().values.flatten().tolist()

  def predict_proba(self, data):
    sparkdata = spark.createDataFrame(data)
    prediction = model.transform(sparkdata).select('probability').toPandas().values.flatten().tolist()
    proba_list = [vector.values.tolist() for vector in prediction]
    return proba_list

I found the same issue in wrapper classes in the following files:

AB#1864607

@imatiach-msft
Copy link
Contributor

@glogowski-wojciech great catch. Yes, that needs to be changed to self.model instead of model. I'll send a PR for the fix.

@adityakode
Copy link
Contributor

@imatiach-msft I would love to fix that.
Can I work on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants