semvec/pypi-packages huggingface dataset:
fwpods-py 0.0.3
A python implementation on the FWPODS algorithm.
Keywords: fwpods, data stream mining, stream mining, frequent weighted pattern data stream, sliding window over data streams


# FWPODS PY



[![github](https://shields.io/badge/github-green?logo=github&color=informational&style=for-the-badge)](https://github.com/fishappy0/FWPODS-Core)



</br><p style="font-size:23px"> A python implementation library based on the paper named "A sliding window-based approach for mining frequent weighted patterns over data streams<p>A



```

H. Bui, T. -A. Nguyen-Hoang, B. Vo, H. Nguyen and T. Le, "A Sliding Window-Based Approach for Mining Frequent Weighted Patterns Over Data Streams," in IEEE Access, vol. 9, pp. 56318-56329, 2021, doi: 10.1109/ACCESS.2021.3070132. keywords: {Data mining;Data models;Databases;Urban areas;Itemsets;Mathematical model;Information technology;Pattern mining;data streams;frequent weighted patterns;sliding window model},

```



# Example usage



Using the existing window manager to add a transaction to the window and start the mining process



```py

from random import randint

from collections import OrderedDict

from fwpods_py.classes import *



FWPs = []

runtimes = []

item_weights = {}



window_size = 45000

min_ws = 0.8

panel_size = 1

twm = weights_manager()



transactions = OrderedDict()

count = 0

# This sample dataset can be found on the SPMF website at https://www.philippe-fournier-viger.com/spmf/index.php?link=datasets.php

ds_name = "retail"

with open(f"./datasets/{ds_name}.txt", "r") as f:

    t_id = "1"

    for line in f:

        if count == window_size + 50:

            break

        transactions[t_id] = line.strip().split()

        for item in line.strip().split():

            if item in item_weights:

                continue

            else:

                item_weights[item] = randint(1, 10)

        t_id = str(int(t_id) + 1)

        count += 1



win_man = window_manager(None, window_size, panel_size, min_ws)

win_man.new_weights(item_weights)



# Simulate a data stream

for t_id, t_items in transactions.items():

    win_man.add_transaction(t_id, t_items)



res_location = f"./results/{ds_name}/"

with open(f"{ds_name}_runtime_total.txt", "w") as f:

    for ttr in win_man.total_runtime:

        f.write(f"{ttr.total_seconds()}\n")



with open(f"{ds_name}_runtime_algo.txt", "w") as f:

    for art in win_man.algo_runtime:

        f.write(f"{art.total_seconds()}\n")



with open(f"{ds_name}_runtime_tree.txt", "w") as f:

    for tr in win_man.tree_build_time:

        f.write(f"{tr.total_seconds()}\n")

```
fh-matplotlib 0.0.4
Make is easy to use matplotlib in FastHTML

### fh-matplotlib

Making it easier to show matplotlib charts in FastHTML.

## Usage

You can install this tool by running:

```
python -m pip install fh-matplotlib
```

After this step, it is ready for use! At the moment this package merely contains a decorator. You can use it to wrap any function that generates a matplotlib chart in order for it to return an `Img` for FastHTML to render. In, short you would typically use it like this:

```python
import numpy as np
import matplotlib.pylab as plt
from fh_matplotlib import matplotlib2fasthtml

# This function will return a proper Img that can be rendered
@matplotlib2fasthtml
def matplotlib_function():
    plt.plot(np.arange(25), np.random.exponential(1, size=25))
```

<details>
    <summary><b>Want to see a full example that you could copy and paste directly?</b></summary>

```python
from fh_matplotlib import matplotlib2fasthtml
from fasthtml.common import * 
import numpy as np
import matplotlib.pylab as plt

app, rt = fast_app()  


count = 0
plotdata = []

@matplotlib2fasthtml
def generate_chart():
    global plotdata
    plt.plot(range(len(plotdata)), plotdata)


@app.get("/")
def home():
    return Title("Matplotlib Demo"), Main(
        H1("Matplotlib Demo"),
        P("Nothing too fancy, but still kind of fancy."),
        Div(f"You have pressed the button {count} times.", id="chart"),
        Button("Increment", hx_get="/increment", hx_target="#chart", hx_swap="innerHTML"),
        style="margin: 20px"
    )


@app.get("/increment/")
def increment():
    global plotdata, count
    count += 1
    plotdata.append(np.random.exponential(1))
    return Div(
        generate_chart(),
        P(f"You have pressed the button {count} times."),
    )

serve()
```
</details>

## Roadmap

This repository is originally meant to be simple helper, but if there are more advanced use-cases to consider I will gladly consider them. Please start a conversation by opening up an issue before starting a PR though.