Skip to content

Commit

Permalink
Update notebooks for categorical features to pass through FeatureMeta…
Browse files Browse the repository at this point in the history
…data (#2011)

* Update responsibleaidashboard-diabetes-decision-making.ipynb

* Update responsibleaidashboard-census-classification-model-debugging.ipynb

* Update responsibleaidashboard-census-classification-model-debugging.ipynb

* Update responsibleaidashboard-diabetes-decision-making.ipynb

* Update responsibleaidashboard-diabetes-decision-making.ipynb

* Update responsibleaidashboard-diabetes-regression-model-debugging.ipynb

* Update responsibleaidashboard-census-classification-model-debugging.ipynb

* Update responsibleaidashboard-diabetes-decision-making.ipynb

* Update responsibleaidashboard-housing-classification-model-debugging.ipynb

* Update responsibleaidashboard-housing-classification-model-debugging.ipynb

* Update responsibleaidashboard-census-classification-model-debugging.ipynb

* Update responsibleaidashboard-diabetes-decision-making.ipynb

* Update responsibleaidashboard-diabetes-regression-model-debugging.ipynb

* Update responsibleaidashboard-housing-decision-making.ipynb

* Update responsibleaidashboard-multiclass-dnn-model-debugging.ipynb

* Update responsibleaidashboard-diabetes-decision-making.ipynb

* Update responsibleaidashboard-diabetes-regression-model-debugging.ipynb

* Update responsibleaidashboard-housing-classification-model-debugging.ipynb

* Update responsibleaidashboard-housing-decision-making.ipynb
  • Loading branch information
tongyu-microsoft committed Mar 17, 2023
1 parent f5496c9 commit 096f4ca
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 16 deletions.
Expand Up @@ -196,7 +196,20 @@
"source": [
"To use Responsible AI Toolbox, initialize a RAIInsights object upon which different components can be loaded.\n",
"\n",
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string, the task type string, and a list of strings of categorical feature names as its arguments."
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string and the task type string as its arguments.",
"\n",
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, specify a list of strings of categorical feature names via the `categorical_features` parameter, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bulgarian-hepatitis",
"metadata": {},
"outputs": [],
"source": [
"from responsibleai.feature_metadata import FeatureMetadata\n",
"feature_metadata = FeatureMetadata(categorical_features=categorical_features, dropped_features=[])\n"
]
},
{
Expand All @@ -207,7 +220,7 @@
"outputs": [],
"source": [
"rai_insights = RAIInsights(model, train_data, test_data_sample, target_feature, 'classification',\n",
" categorical_features=categorical_features)"
" feature_metadata=feature_metadata)"
]
},
{
Expand Down
Expand Up @@ -178,23 +178,32 @@
"source": [
"To use Responsible AI Toolbox, initialize a RAIInsights object upon which different components can be loaded.\n",
"\n",
"RAIInsights accepts the model, the train dataset, the test dataset, the target feature string, the task type string, and a list of strings of categorical feature names as its arguments.\n",
"RAIInsights accepts the model, the train dataset, the test dataset, the target feature string and the task type string as its arguments.\n",
"\n",
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, specify a list of strings of categorical feature names via the `categorical_features` parameter, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d965f769",
"id": "d965f768",
"metadata": {},
"outputs": [],
"source": [
"from responsibleai.feature_metadata import FeatureMetadata\n",
"# Add 's1' as an identity feature, set features_to_drop as dropped features\n",
"feature_metadata = FeatureMetadata(identity_feature_name='s1', dropped_features=features_to_drop)\n",
"feature_metadata = FeatureMetadata(identity_feature_name='s1', categorical_features=[], dropped_features=features_to_drop)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d965f769",
"metadata": {},
"outputs": [],
"source": [
"rai_insights = RAIInsights(model, train_data, test_data, target_feature, 'regression',\n",
" categorical_features=[], feature_metadata=feature_metadata)"
" feature_metadata=feature_metadata)"
]
},
{
Expand Down
Expand Up @@ -143,7 +143,19 @@
"source": [
"To use Responsible AI Toolbox, initialize a RAIInsights object upon which different components can be loaded.\n",
"\n",
"RAIInsights accepts the model, the train dataset, the test dataset, the target feature string, the task type string, and a list of strings of categorical feature names as its arguments."
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string and the task type string as its arguments.",
"\n",
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, specify a list of strings of categorical feature names via the `categorical_features` parameter, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from responsibleai.feature_metadata import FeatureMetadata\n",
"feature_metadata = FeatureMetadata(categorical_features=[], dropped_features=[])\n"
]
},
{
Expand All @@ -153,7 +165,7 @@
"outputs": [],
"source": [
"rai_insights = RAIInsights(model, train_data, test_data, target_feature, 'regression',\n",
" categorical_features=[])"
" feature_metadata=feature_metadata)"
]
},
{
Expand Down
Expand Up @@ -179,7 +179,20 @@
"source": [
"To use Responsible AI Dashboard, initialize a RAIInsights object upon which different components can be loaded.\n",
"\n",
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string, the task type string, and a list of strings of categorical feature names as its arguments."
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string and the task type string as its arguments.",
"\n",
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, specify a list of strings of categorical feature names via the `categorical_features` parameter, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d965f768",
"metadata": {},
"outputs": [],
"source": [
"from responsibleai.feature_metadata import FeatureMetadata\n",
"feature_metadata = FeatureMetadata(categorical_features=categorical_features, dropped_features=[])\n"
]
},
{
Expand All @@ -193,7 +206,7 @@
"\n",
"dashboard_pipeline = Pipeline(steps=[('preprocess', feat_pipe), ('model', model)])\n",
"rai_insights = RAIInsights(dashboard_pipeline, train_data, test_data, target_feature, 'classification',\n",
" categorical_features=categorical_features, \n",
" feature_metadata=feature_metadata, \n",
" classes=['Less than median', 'More than median'])"
]
},
Expand Down
Expand Up @@ -148,9 +148,20 @@
"source": [
"To use Responsible AI Dashboard, initialize a RAIInsights object upon which different components can be loaded.\n",
"\n",
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string, the task type string, and a list of strings of categorical feature names as its arguments.\n",
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string and the task type string as its arguments.",
"\n",
"Here you can pass None as the model object as we only require historic data to make causal decisions."
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, specify a list of strings of categorical feature names via the `categorical_features` parameter, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d965f768",
"metadata": {},
"outputs": [],
"source": [
"from responsibleai.feature_metadata import FeatureMetadata\n",
"feature_metadata = FeatureMetadata(categorical_features=categorical_features, dropped_features=[])\n"
]
},
{
Expand All @@ -161,7 +172,7 @@
"outputs": [],
"source": [
"rai_insights = RAIInsights(None, train_data, test_data, target_feature, 'regression',\n",
" categorical_features=categorical_features, \n",
" feature_metadata=feature_metadata, \n",
" classes=['Less than median', 'More than median'])"
]
},
Expand Down
Expand Up @@ -227,7 +227,20 @@
"source": [
"To use Responsible AI Toolbox, initialize a RAIInsights object upon which different components can be loaded.\n",
"\n",
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string, the task type string, and a list of strings of categorical feature names as its arguments."
"RAIInsights accepts the model, the full dataset, the test dataset, the target feature string and the task type string as its arguments.",
"\n",
"You may also create the `FeatureMetadata` container, identify any feature of your choice as the `identity_feature`, specify a list of strings of categorical feature names via the `categorical_features` parameter, and specify dropped features via the `dropped_features` parameter. The `FeatureMetadata` may also be passed into the `RAIInsights`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bulgarian-hepatitis",
"metadata": {},
"outputs": [],
"source": [
"from responsibleai.feature_metadata import FeatureMetadata\n",
"feature_metadata = FeatureMetadata(categorical_features=[], dropped_features=[])\n"
]
},
{
Expand All @@ -243,7 +256,8 @@
"X_train[target_feature] = y_train\n",
"X_test[target_feature] = y_test\n",
"\n",
"rai_insights = RAIInsights(model, X_train, X_test, target_feature, 'classification')"
"rai_insights = RAIInsights(model, X_train, X_test, target_feature, 'classification',\n",
" feature_metadata=feature_metadata)"
]
},
{
Expand Down

0 comments on commit 096f4ca

Please sign in to comment.