Skip to content

Commit

Permalink
remove telemetry (#347)
Browse files Browse the repository at this point in the history
* removing telemetry

* remoes telemetry

* update

* update

* test

* update
  • Loading branch information
edublancas authored Sep 18, 2024
1 parent 96456ee commit 804da4c
Show file tree
Hide file tree
Showing 32 changed files with 9 additions and 451 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ jobs:
unit:
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
python-version: ['3.10', '3.11']
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
uses: actions/setup-python@v5
with:
miniconda-version: latest
activate-environment: conda-env
channels: conda-forge, defaults
python-version: ${{ matrix.python-version }}

- name: Lint
shell: bash -l {0}
run: |
eval "$(conda shell.bash hook)"
pip install pkgmt
pkgmt lint
Expand All @@ -32,7 +28,6 @@ jobs:
PYTHON_VERSION: ${{ matrix.python-version }}
shell: bash -l {0}
run: |
eval "$(conda shell.bash hook)"
# if we remove the --editable flag pytest throws an error, because there
# are two copies of the pkg (src/ and site-packages/), this is a quick
# way to fix it
Expand All @@ -48,9 +43,9 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 0.12.2dev

- [Feature] Removes telemetry

## 0.12.1 (2024-02-07)

- [Feature] Adds `ploomber-extension` as dependency
Expand Down
3 changes: 0 additions & 3 deletions doc/reference/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@

[See here](https://docs.ploomber.io/en/latest/community/coc.html)

## Telemetry

[See here](https://docs.ploomber.io/en/latest/community/user-stats.html)
50 changes: 0 additions & 50 deletions doc/reference/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,53 +403,3 @@ See the [`roc`](https://github.com/ploomber/sklearn-evaluation/blob/8056bc31ec5e
The `ax` object must be returned at the end of the function.

See the [`roc`](https://github.com/ploomber/sklearn-evaluation/blob/8056bc31ec5e372102d0ee5ada988e380b077c4b/src/sklearn_evaluation/plot/roc.py#L45) function for an example.

## Telemetry

Monitoring the state of `sklearn-evaluation`

Use [`SKLearnEvaluationLogger`](https://github.com/ploomber/sklearn-evaluation/blob/f32c15a43f4a9b4c2e588b3c0f71ba6dc5a71a7e/src/sklearn_evaluation/telemetry.py#L19) decorator to generate logs

Example:

```python
@SKLearnEvaluationLogger.log(feature='plot')
def confusion_matrix(
y_true,
y_pred,
target_names=None,
normalize=False,
cmap=None,
ax=None,
**kwargs):
pass
```

this will generate the following log:

```json
{
"metadata": {
"action": "confusion_matrix"
"feature": "plot",
"args": {
"target_names": "None",
"normalize": "False",
"cmap": "None",
"ax": "None"
}
}
}
```

\*\* since `y_true` and `y_pred` are positional arguments without default values it won't log them

### Queries

1. Run queries and filter out `sklearn-evaluation` events by the event name: `sklearn-evaluation`
2. Break these events by feature ('plot', 'report', 'SQLiteTracker', 'NotebookCollection')
3. Break events by actions/func name (i.e: 'confusion_matrix', 'roc', etc...)

### Errors

Failing runnings will be named: `sklearn-evaluation-error`
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"jupytext",
"ploomber-engine",
"ipykernel",
"pytest",
"pytest<8",
# need to pin this version because pytest 4 breaks matplotlib image
# comparison tests
"pytest-cov",
Expand Down
3 changes: 0 additions & 3 deletions src/sklearn_evaluation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from sklearn_evaluation.nb.NotebookCollection import NotebookCollection
from sklearn_evaluation.nb.NotebookDatabase import NotebookDatabase
from sklearn_evaluation.tracker import SQLiteTracker
from sklearn_evaluation.telemetry import telemetry

__all__ = [
"ClassifierEvaluator",
Expand All @@ -14,5 +13,3 @@
"NotebookCollection",
"NotebookDatabase",
]

telemetry.log_api("imported")
2 changes: 0 additions & 2 deletions src/sklearn_evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from sklearn_evaluation.report.report import Report
from sklearn_evaluation.util import estimator_type, class_name
from sklearn_evaluation import plot
from sklearn_evaluation.telemetry import SKLearnEvaluationLogger


class ClassifierEvaluator(object):
Expand Down Expand Up @@ -153,7 +152,6 @@ def html_serializable(self):
"""
return EvaluatorHTMLSerializer(self)

@SKLearnEvaluationLogger.log(feature="report")
def make_report(self, template=None):
"""
Make HTML report
Expand Down
8 changes: 0 additions & 8 deletions src/sklearn_evaluation/grid/random_forest_classifier_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from sklearn_evaluation.grid.classifier_grid import AbstractClassifierGrid, GridTypes
from sklearn.utils.validation import check_consistent_length
import warnings
from sklearn_evaluation.telemetry import SKLearnEvaluationLogger


class RandomForestClassifierGrid(AbstractClassifierGrid):
Expand Down Expand Up @@ -49,7 +48,6 @@ class RandomForestClassifierGrid(AbstractClassifierGrid):
}
)

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-init")
def __init__(self, grid, cv=3, verbose=0):
"""
A random forest classifier grid.
Expand Down Expand Up @@ -96,7 +94,6 @@ def __init__(self, grid, cv=3, verbose=0):
verbose=verbose,
)

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-fit")
def fit(self, X, y):
"""
Fit estimator.
Expand All @@ -121,7 +118,6 @@ def fit(self, X, y):
self.grid_search_cv_.fit(X, y, sample_weight=None)
return self

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-set-test-data")
def set_test_data(self, X_test, y_test) -> None:
"""
Set the test data
Expand All @@ -140,7 +136,6 @@ def set_test_data(self, X_test, y_test) -> None:
self.X_test = X_test
self.y_test = y_test

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-confusion-matrix")
def confusion_matrix(self):
"""
Plots a confusion matrix based on `GridSearchCV.best_estimator_`.
Expand All @@ -160,7 +155,6 @@ def confusion_matrix(self):
y_pred = self.grid_search_cv_.best_estimator_.predict(X_test)
return plot.confusion_matrix(y_test, y_pred)

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-roc")
def roc(self):
"""
Plots an ROC based on `GridSearchCV.best_estimator_`.
Expand All @@ -185,7 +179,6 @@ def roc(self):

return plot.roc(y_test, y_pred)

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-feature-importances")
def feature_importances(self):
"""
Plots feature importances based on `GridSearchCV.best_estimator_`.
Expand All @@ -203,7 +196,6 @@ def feature_importances(self):
feature_importances = self.grid_search_cv_.best_estimator_.feature_importances_
return plot.feature_importances(feature_importances)

@SKLearnEvaluationLogger.log("RandomForestClassifierGrid-grid-search-results")
def grid_search_results(self, change="n_estimators", kind="line"):
"""
Plots grid search results based on `GridSearchCV.best_estimator_`.
Expand Down
4 changes: 0 additions & 4 deletions src/sklearn_evaluation/nb/NotebookCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from sklearn_evaluation.nb.NotebookIntrospector import NotebookIntrospector
from sklearn_evaluation.nb.sets import differences
from sklearn_evaluation.table import Table
from sklearn_evaluation.telemetry import SKLearnEvaluationLogger

_env = Environment(loader=PackageLoader("sklearn_evaluation", "assets/nb"))
_fm = black.FileMode(string_normalization=False, line_length=40)
Expand All @@ -41,9 +40,6 @@ class NotebookCollection(Mapping):
as identifier (ignores extension)
""" # noqa

@SKLearnEvaluationLogger.log(
feature="NotebookCollection", action="init-NotebookCollection"
)
def __init__(self, paths, ids=None, scores=False):
if ids is None:
ids = paths
Expand Down
4 changes: 0 additions & 4 deletions src/sklearn_evaluation/plot/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from sklearn_evaluation import __version__
from sklearn_evaluation.util import isiterofiter
from ploomber_core.exceptions import modify_exceptions
from sklearn_evaluation.telemetry import SKLearnEvaluationLogger
from sklearn_evaluation.plot.plot import AbstractComposedPlot, AbstractPlot
from sklearn_evaluation.plot.style import apply_theme, get_color_palette

Expand Down Expand Up @@ -147,7 +146,6 @@ class CalibrationCurve(AbstractPlot):
"""

@modify_exceptions
@SKLearnEvaluationLogger.log(feature="plot", action="calibration-curve-init")
def __init__(
self,
mean_predicted_value,
Expand Down Expand Up @@ -304,7 +302,6 @@ def _get_data(self):

class CalibrationCurveAdd(AbstractComposedPlot):
@modify_exceptions
@SKLearnEvaluationLogger.log(feature="plot", action="calibration-curve-add-init")
def __init__(
self,
mean_predicted_value_list,
Expand Down Expand Up @@ -360,7 +357,6 @@ def plot(self, ax=None):


@modify_exceptions
@SKLearnEvaluationLogger.log(feature="plot")
def calibration_curve(
y_true, probabilities, clf_names=None, n_bins=10, cmap="nipy_spectral", ax=None
):
Expand Down
7 changes: 0 additions & 7 deletions src/sklearn_evaluation/plot/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from sklearn.metrics import confusion_matrix as sk_confusion_matrix

from sklearn_evaluation import __version__
from sklearn_evaluation.telemetry import SKLearnEvaluationLogger
from sklearn_evaluation.plot.matplotlib import bar
from sklearn_evaluation.metrics import precision_at
from sklearn_evaluation import compute
Expand Down Expand Up @@ -93,7 +92,6 @@ class ConfusionMatrix(AbstractPlot):
Added ``cmap`` argument
"""

@SKLearnEvaluationLogger.log(feature="plot", action="confusion-matrix-init")
@modify_exceptions
def __init__(self, cm, *, target_names=None, normalize=False, cmap=None):
self.cm = cm
Expand All @@ -112,14 +110,12 @@ def plot(self, ax=None):

return self

@SKLearnEvaluationLogger.log(feature="plot", action="confusion-matrix-sub")
def __sub__(self, other):
cm = self.cm - other.cm
obj = ConfusionMatrixSub(cm, self.target_names)
obj.plot()
return obj

@SKLearnEvaluationLogger.log(feature="plot", action="confusion-matrix-add")
def __add__(self, other):
obj = ConfusionMatrixAdd(self.cm, other.cm, self.target_names)
obj.plot()
Expand Down Expand Up @@ -178,7 +174,6 @@ def _confusion_matrix(y_true, y_pred, normalize):
return cm


@SKLearnEvaluationLogger.log(feature="plot")
@modify_exceptions
def confusion_matrix(
y_true, y_pred, target_names=None, normalize=False, cmap=None, ax=None
Expand Down Expand Up @@ -314,7 +309,6 @@ def _plot_cm(cm, cmap, ax, target_names, normalize):


# http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html
@SKLearnEvaluationLogger.log(feature="plot")
@modify_exceptions
def feature_importances(
data, top_n=None, feature_names=None, orientation="horizontal", ax=None
Expand Down Expand Up @@ -371,7 +365,6 @@ def feature_importances(
return ax


@SKLearnEvaluationLogger.log(feature="plot")
@modify_exceptions
def precision_at_proportions(y_true, y_score, ax=None):
"""
Expand Down
4 changes: 0 additions & 4 deletions src/sklearn_evaluation/plot/classification_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import classification_report as sk_classification_report
from sklearn_evaluation.telemetry import SKLearnEvaluationLogger

from sklearn_evaluation.plot.classification import _add_values_to_matrix
from sklearn_evaluation.plot.plot import AbstractPlot, AbstractComposedPlot
Expand Down Expand Up @@ -85,7 +84,6 @@ class ClassificationReport(AbstractPlot):
"""

@SKLearnEvaluationLogger.log(feature="plot", action="classification-report-init")
def __init__(
self,
matrix,
Expand All @@ -109,13 +107,11 @@ def plot(self, ax=None):

return self

@SKLearnEvaluationLogger.log(feature="plot", action="classification-report-sub")
def __sub__(self, other):
return ClassificationReportSub(
self.matrix, other.matrix, self.keys, target_names=self.target_names
).plot()

@SKLearnEvaluationLogger.log(feature="plot", action="classification-report-add")
def __add__(self, other):
return ClassificationReportAdd(
self.matrix, other.matrix, keys=self.keys, target_names=self.target_names
Expand Down
Loading

0 comments on commit 804da4c

Please sign in to comment.