Skip to content

Commit

Permalink
Add lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amrit110 committed Jan 20, 2025
1 parent 7f75076 commit af16f8a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 77 deletions.
2 changes: 2 additions & 0 deletions cyclops/evaluate/metrics/experimental/utils/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# noqa: A005

"""Utilities for array-API compatibility."""

import builtins
Expand Down
4 changes: 2 additions & 2 deletions cyclops/monitor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ def get_args(obj: Any, kwargs: Dict[str, Any]) -> Dict[str, Any]:
"""
args = {}
for key in kwargs:
for key, value in kwargs.items():
if (inspect.isclass(obj) and key in inspect.signature(obj).parameters) or (
(inspect.ismethod(obj) or inspect.isfunction(obj))
and key in inspect.getfullargspec(obj).args
):
args[key] = kwargs[key]
args[key] = value
return args


Expand Down
2 changes: 2 additions & 0 deletions cyclops/utils/profile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# noqa: A005

"""Useful functions for timing, profiling."""

import logging
Expand Down
15 changes: 5 additions & 10 deletions docs/source/examples/metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Imports.\"\"\"\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"from datasets.arrow_dataset import Dataset\n",
Expand Down Expand Up @@ -57,7 +59,7 @@
"outputs": [],
"source": [
"df = breast_cancer_data.frame\n",
"df.describe().T"
"print(df.describe().T)"
]
},
{
Expand Down Expand Up @@ -222,7 +224,7 @@
"outputs": [],
"source": [
"slice_spec = SliceSpec(spec_list, intersections=2)\n",
"slice_spec"
"print(slice_spec)"
]
},
{
Expand Down Expand Up @@ -316,15 +318,8 @@
" target_columns=\"target\",\n",
" prediction_columns=\"preds_prob\",\n",
")\n",
"fairness_result"
"print(fairness_result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
48 changes: 15 additions & 33 deletions docs/source/examples/report.ipynb
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Report Generation for Heart Failure Prediction\n",
"Here's an example to demonstrate how we can generate a report as we proceed through all the steps to train and evaluate a model. For this purpose, we are going to use Kaggle's heart prediction failure dataset and gradually populate the report with information about dataset, model and results."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Imports.\"\"\"\n",
"\n",
"import copy\n",
"import inspect\n",
"import os\n",
Expand All @@ -23,21 +33,14 @@
"from tqdm import tqdm\n",
"\n",
"from cyclops.data.slicer import SliceSpec\n",
"from cyclops.evaluate import evaluator\n",
"from cyclops.evaluate.metrics import create_metric\n",
"from cyclops.evaluate.metrics.experimental.metric_dict import MetricDict\n",
"from cyclops.report import ModelCardReport\n",
"from cyclops.report.plot.classification import ClassificationPlotter\n",
"from cyclops.report.utils import flatten_results_dict"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Report Generation for Heart Failure Prediction\n",
"Here's an example to demonstrate how we can generate a report as we proceed through all the steps to train and evaluate a model. For this purpose, we are going to use Kaggle's heart prediction failure dataset and gradually populate the report with information about dataset, model and results."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -105,7 +108,7 @@
"metadata": {},
"outputs": [],
"source": [
"df.describe().T"
"print(df.describe().T)"
]
},
{
Expand Down Expand Up @@ -531,9 +534,6 @@
"metadata": {},
"outputs": [],
"source": [
"from cyclops.evaluate import evaluator\n",
"\n",
"\n",
"# Create Dataset object\n",
"heart_failure_data = Dataset.from_pandas(df_test)\n",
"\n",
Expand All @@ -557,24 +557,6 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"result"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"results_flat"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -878,7 +860,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "cyclops",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -892,9 +874,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
11 changes: 0 additions & 11 deletions docs/source/tutorials/diabetes_130/readmission_prediction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,6 @@
"variables = diabetes_130_data[\"variables\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"metadata"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@
"variables = diabetes_130_data[\"variables\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"metadata"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -749,7 +738,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
16 changes: 7 additions & 9 deletions tests/cyclops/evaluate/metrics/experimental/utils/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,17 @@ def test_apply_to_nested_collections(self):
},
}

for k in expected_result:
for k, v in expected_result.items():
assert k in result

if isinstance(expected_result[k], dict):
for kk in expected_result[k]:
if isinstance(v, dict):
for kk in v:
assert kk in result[k]
assert anp.all(expected_result[k][kk] == result[k][kk])
elif isinstance(expected_result[k], (tuple, list)):
assert all(
anp.all(a == b) for a, b in zip(result[k], expected_result[k])
)
assert anp.all(v[kk] == result[k][kk])
elif isinstance(v, (tuple, list)):
assert all(anp.all(a == b) for a, b in zip(result[k], v))
else:
assert anp.all(expected_result[k] == result[k])
assert anp.all(v == result[k])


class TestBincount:
Expand Down

0 comments on commit af16f8a

Please sign in to comment.