# 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")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "fwpods-py",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "fwpods, data stream mining, stream mining, frequent weighted pattern data stream, sliding window over data streams",
"author": "Fishappy0",
"author_email": "<fishappy0@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d9/14/d320a0b721409e2a88a8779aa6aec63cf50f37d995102c5db474ad257264/fwpods_py-0.0.3.tar.gz",
"platform": null,
"description": "\r\n# FWPODS PY\r\n\r\n\r\n\r\n[![github](https://shields.io/badge/github-green?logo=github&color=informational&style=for-the-badge)](https://github.com/fishappy0/FWPODS-Core)\r\n\r\n\r\n\r\n</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\r\n\r\n\r\n\r\n```\r\n\r\nH. 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},\r\n\r\n```\r\n\r\n\r\n\r\n# Example usage\r\n\r\n\r\n\r\nUsing the existing window manager to add a transaction to the window and start the mining process\r\n\r\n\r\n\r\n```py\r\n\r\nfrom random import randint\r\n\r\nfrom collections import OrderedDict\r\n\r\nfrom fwpods_py.classes import *\r\n\r\n\r\n\r\nFWPs = []\r\n\r\nruntimes = []\r\n\r\nitem_weights = {}\r\n\r\n\r\n\r\nwindow_size = 45000\r\n\r\nmin_ws = 0.8\r\n\r\npanel_size = 1\r\n\r\ntwm = weights_manager()\r\n\r\n\r\n\r\ntransactions = OrderedDict()\r\n\r\ncount = 0\r\n\r\n# This sample dataset can be found on the SPMF website at https://www.philippe-fournier-viger.com/spmf/index.php?link=datasets.php\r\n\r\nds_name = \"retail\"\r\n\r\nwith open(f\"./datasets/{ds_name}.txt\", \"r\") as f:\r\n\r\n t_id = \"1\"\r\n\r\n for line in f:\r\n\r\n if count == window_size + 50:\r\n\r\n break\r\n\r\n transactions[t_id] = line.strip().split()\r\n\r\n for item in line.strip().split():\r\n\r\n if item in item_weights:\r\n\r\n continue\r\n\r\n else:\r\n\r\n item_weights[item] = randint(1, 10)\r\n\r\n t_id = str(int(t_id) + 1)\r\n\r\n count += 1\r\n\r\n\r\n\r\nwin_man = window_manager(None, window_size, panel_size, min_ws)\r\n\r\nwin_man.new_weights(item_weights)\r\n\r\n\r\n\r\n# Simulate a data stream\r\n\r\nfor t_id, t_items in transactions.items():\r\n\r\n win_man.add_transaction(t_id, t_items)\r\n\r\n\r\n\r\nres_location = f\"./results/{ds_name}/\"\r\n\r\nwith open(f\"{ds_name}_runtime_total.txt\", \"w\") as f:\r\n\r\n for ttr in win_man.total_runtime:\r\n\r\n f.write(f\"{ttr.total_seconds()}\\n\")\r\n\r\n\r\n\r\nwith open(f\"{ds_name}_runtime_algo.txt\", \"w\") as f:\r\n\r\n for art in win_man.algo_runtime:\r\n\r\n f.write(f\"{art.total_seconds()}\\n\")\r\n\r\n\r\n\r\nwith open(f\"{ds_name}_runtime_tree.txt\", \"w\") as f:\r\n\r\n for tr in win_man.tree_build_time:\r\n\r\n f.write(f\"{tr.total_seconds()}\\n\")\r\n\r\n```\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A python implementation on the FWPODS algorithm.",
"version": "0.0.3",
"project_urls": null,
"split_keywords": [
"fwpods",
" data stream mining",
" stream mining",
" frequent weighted pattern data stream",
" sliding window over data streams"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c2cac3629f11b2c9d2dfd725748bd57a3c658b6613d3ffd081936e5a702e65e3",
"md5": "7558c7657ae03e383e012d23a4e5708d",
"sha256": "e6d1337806176daa1e815a41cbbf37f0b1348754ceb41076627b51e15c350df5"
},
"downloads": -1,
"filename": "fwpods_py-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7558c7657ae03e383e012d23a4e5708d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 21224,
"upload_time": "2024-08-08T13:45:08",
"upload_time_iso_8601": "2024-08-08T13:45:08.027790Z",
"url": "https://files.pythonhosted.org/packages/c2/ca/c3629f11b2c9d2dfd725748bd57a3c658b6613d3ffd081936e5a702e65e3/fwpods_py-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d914d320a0b721409e2a88a8779aa6aec63cf50f37d995102c5db474ad257264",
"md5": "23bf7ad46b405eb5a7dbca7ea4149b2f",
"sha256": "eb12875d02414057b8bfe9d4d6ab21439672803266f18e7570f83413ae3656ac"
},
"downloads": -1,
"filename": "fwpods_py-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "23bf7ad46b405eb5a7dbca7ea4149b2f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21042,
"upload_time": "2024-08-08T13:45:09",
"upload_time_iso_8601": "2024-08-08T13:45:09.562208Z",
"url": "https://files.pythonhosted.org/packages/d9/14/d320a0b721409e2a88a8779aa6aec63cf50f37d995102c5db474ad257264/fwpods_py-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-08 13:45:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "fwpods-py"
}