semvec/pypi-packages huggingface dataset:
pandas-explode 0.0.7
Explode utility for Pandas dataframes (similar to UNNEST or explode)
License: MIT

[![Build Status](https://travis-ci.org/orenovadia/pandas_explode.svg?branch=master)](https://travis-ci.org/orenovadia/pandas_explode)

# pandas_explode

author: Oren Ovadia

## Overview

Explode utility for Pandas dataframes (similar to `UNNEST` or `explode`)


## Examples

```python
import pandas as pd 
import pandas_explode 
pandas_explode.patch() # adds a `df.explode` method to all DataFrames 

df = pd.DataFrame({'s': ['a', 'b', 'c'], 'values': [[1, 2], [3, 4, 5], []]})
df
#    s     values
# 0  a     [1, 2]
# 1  b  [3, 4, 5]
# 2  c         []
df.explode('values')
#    s  values
# 0  a       1
# 0  a       2
# 1  b       3
# 1  b       4
# 1  b       5

df = pd.DataFrame({'s': ['a', 'b', 'c'], 'values': [{'col1': 1, 'col2': 2}, {'col1': 10, 'col3': 20}, {'col2': 2}]})
df
#    s                    values
# 0  a    {'col1': 1, 'col2': 2}
# 1  b  {'col1': 10, 'col3': 20}
# 2  c               {'col2': 2}
df.explode('values', axis=1)
#    s  col1  col2  col3
# 0  a   1.0   2.0   NaN
# 1  b  10.0   NaN  20.0
# 2  c   NaN   2.0   NaN
df.explode('values', axis=1, record_prefix=True)
#    s  values.col1  values.col2  values.col3
# 0  a          1.0          2.0          NaN
# 1  b         10.0          NaN         20.0
# 2  c          NaN          2.0          NaN

```


## Installation / Usage

To install use pip:

    $ pip install pandas_explode


Or clone the repo:

    $ git clone https://github.com/orenovadia/pandas_explode.git
    $ python setup.py install
    

## Publishing

    $ ./publish.sh
ixai 0.1.3
Explainable Artificial Intelligence for dynamic and Incremental models.
License: MIT
Requires Python: >=3.8.0
Keywords: python,machine learning,online learning,xai


<p align="center">
  <!-- PyPI Version -->
  <a href="https://pypi.org/project/ixai">
    <img src="https://img.shields.io/pypi/v/ixai.svg?color=blue" alt="PyPi">
  </a>
  <!-- PyPI status -->
  <a href="https://pypi.org/project/ixai">
    <img src="https://img.shields.io/pypi/status/ixai.svg?color=blue" alt="PyPi_status
  </a>
  <!-- License -->
  <a href="https://opensource.org/licenses/MIT">
    <img src="https://img.shields.io/badge/License-MIT-brightgreen.svg" alt="mit_license">
  </a>
</p>

# ixai: Incremental Explainable Artificial Intelligence

This is the first iteration of our incremental explanation package.

Currently, it includes two explanation methods: PFI and SAGE.

Please look at the examples in the `examples` directory.

Please help us in improving our work by contributing or pointing to issues. We will update this iteration soon with further information.

## 🛠 Installation
**ixai** is intended to work with **Python 3.8 and above**. Installation can be done via `pip`:

```sh
pip install ixai
```

## 📊 Quickstart

### Basic Classification
```python
>>> from river.metrics import Accuracy
>>> from river.ensemble import AdaptiveRandomForestClassifier
>>> from river.datasets.synth import Agrawal

>>> from ixai.explainer import IncrementalPFI

>>> stream = Agrawal(classification_function=2)
>>> feature_names = list([x_0 for x_0, _ in stream.take(1)][0].keys())

>>> model = AdaptiveRandomForestClassifier(n_models=10, max_depth=10, leaf_prediction='mc')

>>> incremental_pfi = IncrementalPFI(
...     model_function=model.predict_one,
...     loss_function=Accuracy(),
...     feature_names=feature_names,
...     smoothing_alpha=0.001,
...     n_inner_samples=5
... )

>>> training_metric = Accuracy()
>>> for (n, (x, y)) in enumerate(stream, start=1)
...     y_pred = model.predict_one(x)       # inference
...     training_metric.update(y, y_pred)   # update score
...     incremental_pfi.explain_one(x, y)   # explaining
...     model.learn_one(x, y)               # learning
...     if n % 1000 == 0:
...         print(f"{n}: Accuracy: {training_metric.get():.3f}, PFI: {incremental_pfi.importance_values}")

1000: Accuracy: 0.785, PFI: {'age': 0.22, 'elevel': 0.18, 'zipcode': -0.07, 'salary': 0.04, 'commission': 0.05, 'loan': -0.06, 'car': 0.02, 'hyears': 0.03, 'hvalue': 0.03}
2000: Accuracy: 0.841, PFI: {'age': 0.26, 'elevel': 0.21, 'zipcode': -0.01, 'salary': 0.02, 'commission': 0.03, 'loan': -0.02, 'car': 0.02, 'hyears': 0.04, 'hvalue': 0.02}
3000: Accuracy: 0.921, PFI: {'age': 0.28, 'elevel': 0.24, 'zipcode': -0.00, 'salary': 0.00, 'commission': 0.01, 'loan': -0.01, 'car': 0.01, 'hyears': 0.01, 'hvalue': 0.00}