Skip to content

Commit ef9dcb1

Browse files
authored
Merge pull request #75258 from j-martens/master
adding more for mers
2 parents 68175a8 + 899f673 commit ef9dcb1

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

articles/machine-learning/service/machine-learning-interpretability-explainability.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,11 @@ While you can train on the various compute targets supported by Azure Machine Le
217217
print('global importance names: {}'.format(global_importance_names))
218218
```
219219

220-
## Raw Feature Transformations
220+
## Raw reature transformations
221221

222222
Optionally, you can pass your feature transformation pipeline to the explainer to receive explanations in terms of the raw features before the transformation (rather than engineered features). If you skip this, the explainer provides explanations in terms of engineered features.
223223

224-
The format of supported transformations is same as the one described in [sklearn-pandas](https://github.com/scikit-learn-contrib/sklearn-pandas). We currently support these one-to-many or one-to-one transformers:
225-
+ oneBinarizer
226-
+ KBinsDiscretizer
227-
+ KernelCenterer
228-
+ LabelEncoder
229-
+ MaxAbsScaler
230-
+ MinMaxScaler
231-
+ Normalizer
232-
+ OneHotEncoder
233-
+ OrdinalEncoder
234-
+ PowerTransformer
235-
+ QuantileTransformer
236-
+ RobustScaler
237-
+ StandardScaler
238-
239-
In general, any transformations are supported as long as they operate on a single column and are therefore clearly one to many.
224+
The format of supported transformations is same as the one described in [sklearn-pandas](https://github.com/scikit-learn-contrib/sklearn-pandas). In general, any transformations are supported as long as they operate on a single column and are therefore clearly one to many.
240225

241226
```python
242227
from sklearn.pipeline import Pipeline
@@ -251,7 +236,6 @@ numeric_transformations = [([f], Pipeline(steps=[('imputer', SimpleImputer(strat
251236

252237
categorical_transformations = [([f], OneHotEncoder(handle_unknown='ignore', sparse=False)) for f in categorical]
253238

254-
255239
transformations = numeric_transformations + categorical_transformations
256240

257241
# Append model to preprocessing pipeline.
@@ -265,6 +249,26 @@ clf = Pipeline(steps=[('preprocessor', DataFrameMapper(transformations)),
265249
tabular_explainer = TabularExplainer(clf.steps[-1][1], initialization_examples=x_train, features=dataset_feature_names, classes=dataset_classes, transformations=transformations)
266250
```
267251

252+
* Test the deployment
253+
``` python
254+
import requests
255+
256+
# Create data to test service with
257+
x_list = x_test.tolist()
258+
examples = x_list[:4]
259+
input_data = "{\"data\": " + str(examples) + "}"
260+
261+
headers = {'Content-Type':'application/json'}
262+
263+
# send request to service
264+
resp = requests.post(service.scoring_uri, input_data, headers=headers)
265+
266+
print("POST to url", service.scoring_uri)
267+
# can covert back to Python objects from json string if desired
268+
print("prediction:", resp.text)
269+
```
270+
* Clean up by deleting any obsolete deployed web service using `service.delete()`.
271+
268272
## Next Steps
269273

270274
To see a demonstration of interpretability with the Azure Machine Learning SDK, look at the [Interpretability sample notebooks](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/explain-model) on GitHub.

0 commit comments

Comments
 (0)