SynapseML
SynapseML copied to clipboard
SynapseML docs: Wrong variable referenced in code example in docs in "Interpretability - Explanation Dashboard" wrapper class
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:
- https://github.com/microsoft/SynapseML/blob/3bd5bef91db9339f4b7db6b6a800b08f68ed25e8/website/versioned_docs/version-0.9.5/features/responsible_ai/Interpretability%20-%20Explanation%20Dashboard.md
- https://github.com/microsoft/SynapseML/blob/d38c82455b28585cb35f6f4386a508ff4026f1d3/notebooks/features/responsible_ai/Interpretability%20-%20Explanation%20Dashboard.ipynb
- https://github.com/microsoft/SynapseML/blob/d38c82455b28585cb35f6f4386a508ff4026f1d3/notebooks/features/isolation_forest/IsolationForest%20-%20Multivariate%20Anomaly%20Detection.ipynb
AB#1864607
@glogowski-wojciech great catch. Yes, that needs to be changed to self.model instead of model. I'll send a PR for the fix.
@imatiach-msft I would love to fix that. Can I work on it?