{"id":22986533,"url":"https://github.com/lolei/spmf-py","last_synced_at":"2025-05-08T21:11:53.359Z","repository":{"id":47029165,"uuid":"257629225","full_name":"LoLei/spmf-py","owner":"LoLei","description":"Python SPMF Wrapper 🐍 🎁","archived":false,"fork":false,"pushed_at":"2024-05-24T10:54:24.000Z","size":43,"stargazers_count":66,"open_issues_count":5,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T21:11:29.198Z","etag":null,"topics":["data-mining","frequent-patterns","hacktoberfest","pattern-mining","python","sequential-patterns","spmf","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LoLei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-21T14:54:03.000Z","updated_at":"2025-01-09T12:45:58.000Z","dependencies_parsed_at":"2023-02-09T13:31:11.055Z","dependency_job_id":null,"html_url":"https://github.com/LoLei/spmf-py","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoLei%2Fspmf-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoLei%2Fspmf-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoLei%2Fspmf-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoLei%2Fspmf-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LoLei","download_url":"https://codeload.github.com/LoLei/spmf-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149617,"owners_count":21861739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-mining","frequent-patterns","hacktoberfest","pattern-mining","python","sequential-patterns","spmf","wrapper"],"created_at":"2024-12-15T03:50:22.898Z","updated_at":"2025-05-08T21:11:53.332Z","avatar_url":"https://github.com/LoLei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spmf-py\nPython Wrapper for SPMF 🐍 🎁\n\n## Information\nThe [SPMF](http://www.philippe-fournier-viger.com/spmf) [[1](https://github.com/LoLei/spmf-py#bibliography)] data mining Java library usable in Python.  \n\nEssentially, this module calls the Java command line tool of SPMF, passes the user arguments to it, and parses the output.  \nIn addition, transformation of the data to Pandas DataFrame and CSV is possible.\n\nIn theory, all algorithms featured in SPMF are callable. Nothing is hardcoded, the desired algorithm and its parameters need to be perused in the [SPMF documentation](http://www.philippe-fournier-viger.com/spmf/index.php?link=documentation.php).\n\n## Installation\n[`pip install spmf`](https://pypi.org/project/spmf/)\n\n## Usage\nExample:  \n```python\nfrom spmf import Spmf\n\nspmf = Spmf(\"PrefixSpan\", input_filename=\"contextPrefixSpan.txt\",\n            output_filename=\"output.txt\", arguments=[0.7, 5])\nspmf.run()\nprint(spmf.to_pandas_dataframe(pickle=True))\nspmf.to_csv(\"output.csv\")\n```\n\nOutput:\n```\n=============  PREFIXSPAN 0.99-2016 - STATISTICS =============\n Total time ~ 2 ms\n Frequent sequences count : 14\n Max memory (mb) : 6.487663269042969\n minsup = 3 sequences.\n Pattern count : 14\n===================================================\n\n      pattern sup\n0         [1]   4\n1      [1, 2]   4\n2      [1, 3]   4\n3   [1, 3, 2]   3\n4   [1, 3, 3]   3\n5         [2]   4\n6      [2, 3]   3\n7         [3]   4\n8      [3, 2]   3\n9      [3, 3]   3\n10        [4]   3\n11     [4, 3]   3\n12        [5]   3\n13        [6]   3\n```\n\nThe usage is similar to the one described in the SPMF [documentation](http://www.philippe-fournier-viger.com/spmf/index.php?link=documentation.php).  \nFor all Python parameters, see the [Spmf class](https://github.com/LoLei/spmf-py/blob/master/spmf/__init__.py).  \n\n### SPMF Arguments\nThe `arguments` parameter are the arguments that are passed to SPMF and depend on the chosen algorithm. SPMF handles optional parameters as an ordered list. As there are no named parameters for the algorithms, if e.g. only the first and the last parameter of an algorithm are to be used, the ones in between must be filled with `\"\"` blank strings.  \nFor advanced usage examples, see [`examples`](https://github.com/LoLei/spmf-py/tree/master/examples).\n\n### SPMF Executable\nDownload it from the [SPMF Website](http://www.philippe-fournier-viger.com/spmf/index.php?link=download.php).  \nIt is assumed that the SPMF binary `spmf.jar` is located in the same directory as `spmf-py`. If it is not, either symlink it, or use the `spmf_bin_location_dir` parameter.\n\n### Input Formats\nEither use an input file as specified by SPMF, or use one of the in-line formats as seen in [`examples`](https://github.com/LoLei/spmf-py/tree/master/examples).\n\n### Memory\nThe maxmimum memory can be increased in the constructor via `Spmf(memory=n)`,\nwhere `n` is megabyte, see SPMF's\n[FAQ](http://www.philippe-fournier-viger.com/spmf/index.php?link=FAQ.php#memory).\n\n## Background\nWhy? If you're in a Python pipeline, like a Jupyter Notebook, it might be cumbersome to use Java as an intermediate step. Using `spmf-py` you can stay in your pipeline as though Java is never used at all.\n\n## Bibliography\n```\nFournier-Viger, P., Lin, C.W., Gomariz, A., Gueniche, T., Soltani, A., Deng, Z., Lam, H. T. (2016).  \nThe SPMF Open-Source Data Mining Library Version 2.  \nProc. 19th European Conference on Principles of Data Mining and Knowledge Discovery (PKDD 2016) Part III, Springer LNCS 9853,  pp. 36-40.\n```\n\n## Disclaimer\n\nUse at your own risk. This repo is not/barely maintained. Use SPMF itself for more robust results.\n\nThis module has been tested for a fraction of the algorithms offered in SPMF.\nCalling them and writing to the output file should be possible for all.\nOutput parsing however should work for those that have outputs like the sequential pattern mining algorithms.\nIt was not tested with other types, some adaption of the output parsing might be necessary.\n\nIf something is not working, submit an issue or create a PR yourself!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flolei%2Fspmf-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flolei%2Fspmf-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flolei%2Fspmf-py/lists"}