ai-fuzzy-rec


Nameai-fuzzy-rec JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/fadedreams/ai-fuzzy-rec
SummaryAn AI-enhanced fuzzy logic-based item recommendation system for SQLite databases.
upload_time2025-07-14 09:17:03
maintainerNone
docs_urlNone
authorfadedreams7
requires_python>=3.6
licenseMIT
keywords fuzzy logic recommender system ai sqlite recommendations
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AIFuzzyRec

A Python library for generating AI-powered item recommendations using fuzzy logic and SQLite databases. AIFuzzyRec leverages fuzzy set theory and artificial intelligence to compute item similarities based on user-item interactions, providing flexible and AI-enhanced recommendations for applications like e-commerce, content platforms, or personalized systems.

## Features
- Fuzzy Logic-Based Recommendations: Uses fuzzy membership functions to compute item similarities, allowing nuanced recommendation scores.

- Flexible Database Schema: Supports any SQLite database with user-item interaction data, with customizable table and column names.

- Context Manager Support: Ensures automatic cleanup of database connections using Python's with statement.

- Configurable Fuzzy Weights: Adjust weights for low, medium, and high similarity to fine-tune recommendation behavior.

- Error Handling: Robust handling of invalid user/item IDs and empty databases.

- Logging: Optional logging of recommendations to a file for debugging and analysis.

- Easy Integration: Lightweight and compatible with Python 3.6+.

## Installation

Install AIFuzzyRec using pip:
```
pip install ai-fuzzy-rec
```
Or, if using Poetry, add it to your project:
```
poetry add ai-fuzzy-rec
```
### Requirements
Python >= 3.6
pandas >= 2.0.0
scikit-fuzzy >= 0.4.2
numpy >= 1.25.0
scipy >= 1.10.0
packaging >= 21.3

## Usage

### Basic Example

Generate recommendations using a SQLite database (purchases.db) containing user-item interactions:
```
from ai_fuzzy_rec import FuzzyRecommender

# Initialize with default settings
with FuzzyRecommender(db_path='purchases.db') as recommender:
    # Recommend items similar to item ID 2
    item_rec = recommender.recommend_items_for_item(2, top_n=3)
    print(f"Items recommended for item 2: {[(item, round(score, 3)) for item, score in item_rec]}")

    # Recommend items for user ID 1
    user_rec = recommender.recommend_items_for_user(1, top_n=3)
    print(f"Items recommended for user 1: {[(item, round(score, 3)) for item, score in user_rec]}")
```
Expected Output:
```
Items recommended for item 2: [(3, 0.5), (4, 0.5), (1, 0.5)]
Items recommended for user 1: [(4, 1.0), (5, 0.5)]
```
### Custom Schema and Parameters

Use a custom database schema and adjust fuzzy weights:
```
from ai_fuzzy_rec import FuzzyRecommender

with FuzzyRecommender(
    db_path='custom.db',
    table_name='orders',
    user_col='customer_id',
    item_col='product_id',
    fuzzy_weights=(0.1, 0.4, 0.5),  # Emphasize high similarity
    log_file='custom_recommendations.log'
) as recommender:
    item_rec = recommender.recommend_items_for_item(2, top_n=2)
    print(f"Top 2 items for item 2: {item_rec}")
```
### Database Setup

Create a SQLite database with user-item interactions:
```
import sqlite3

# Create a sample database
conn = sqlite3.connect('purchases.db')
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS purchases
                 (user_id INTEGER, item_id INTEGER)''')
# Insert sample data
data = [(1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (2, 4),
        (3, 3), (3, 4), (3, 5), (4, 1), (4, 4), (5, 1), (5, 2)]
cursor.executemany('INSERT INTO purchases VALUES (?, ?)', data)
conn.commit()
conn.close()
```
### Testing

Run tests to verify functionality:
```
poetry run pytest
```
This executes tests in tests/test_ai_fuzzy_rec.py, ensuring recommendations and error handling work as expected.

### Project Structure
```
/home/m/pyprj/
├── ai_fuzzy_rec/
│   ├── __init__.py
│   ├── ai_fuzzy_rec.py
├── create_database.py
├── purchases.db
├── pyproject.toml
├── README.md
├── LICENSE
├── test_recommender.py
└── tests/
    └── test_ai_fuzzy_rec.py

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fadedreams/ai-fuzzy-rec",
    "name": "ai-fuzzy-rec",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "fuzzy logic, recommender system, ai, sqlite, recommendations",
    "author": "fadedreams7",
    "author_email": "fadedreams7@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2a/77/5045383c3b835590c71d506dea27741c78aba13d1beb53750d3b6928ac1f/ai_fuzzy_rec-0.1.0.tar.gz",
    "platform": null,
    "description": "# AIFuzzyRec\n\nA Python library for generating AI-powered item recommendations using fuzzy logic and SQLite databases. AIFuzzyRec leverages fuzzy set theory and artificial intelligence to compute item similarities based on user-item interactions, providing flexible and AI-enhanced recommendations for applications like e-commerce, content platforms, or personalized systems.\n\n## Features\n- Fuzzy Logic-Based Recommendations: Uses fuzzy membership functions to compute item similarities, allowing nuanced recommendation scores.\n\n- Flexible Database Schema: Supports any SQLite database with user-item interaction data, with customizable table and column names.\n\n- Context Manager Support: Ensures automatic cleanup of database connections using Python's with statement.\n\n- Configurable Fuzzy Weights: Adjust weights for low, medium, and high similarity to fine-tune recommendation behavior.\n\n- Error Handling: Robust handling of invalid user/item IDs and empty databases.\n\n- Logging: Optional logging of recommendations to a file for debugging and analysis.\n\n- Easy Integration: Lightweight and compatible with Python 3.6+.\n\n## Installation\n\nInstall AIFuzzyRec using pip:\n```\npip install ai-fuzzy-rec\n```\nOr, if using Poetry, add it to your project:\n```\npoetry add ai-fuzzy-rec\n```\n### Requirements\nPython >= 3.6\npandas >= 2.0.0\nscikit-fuzzy >= 0.4.2\nnumpy >= 1.25.0\nscipy >= 1.10.0\npackaging >= 21.3\n\n## Usage\n\n### Basic Example\n\nGenerate recommendations using a SQLite database (purchases.db) containing user-item interactions:\n```\nfrom ai_fuzzy_rec import FuzzyRecommender\n\n# Initialize with default settings\nwith FuzzyRecommender(db_path='purchases.db') as recommender:\n    # Recommend items similar to item ID 2\n    item_rec = recommender.recommend_items_for_item(2, top_n=3)\n    print(f\"Items recommended for item 2: {[(item, round(score, 3)) for item, score in item_rec]}\")\n\n    # Recommend items for user ID 1\n    user_rec = recommender.recommend_items_for_user(1, top_n=3)\n    print(f\"Items recommended for user 1: {[(item, round(score, 3)) for item, score in user_rec]}\")\n```\nExpected Output:\n```\nItems recommended for item 2: [(3, 0.5), (4, 0.5), (1, 0.5)]\nItems recommended for user 1: [(4, 1.0), (5, 0.5)]\n```\n### Custom Schema and Parameters\n\nUse a custom database schema and adjust fuzzy weights:\n```\nfrom ai_fuzzy_rec import FuzzyRecommender\n\nwith FuzzyRecommender(\n    db_path='custom.db',\n    table_name='orders',\n    user_col='customer_id',\n    item_col='product_id',\n    fuzzy_weights=(0.1, 0.4, 0.5),  # Emphasize high similarity\n    log_file='custom_recommendations.log'\n) as recommender:\n    item_rec = recommender.recommend_items_for_item(2, top_n=2)\n    print(f\"Top 2 items for item 2: {item_rec}\")\n```\n### Database Setup\n\nCreate a SQLite database with user-item interactions:\n```\nimport sqlite3\n\n# Create a sample database\nconn = sqlite3.connect('purchases.db')\ncursor = conn.cursor()\ncursor.execute('''CREATE TABLE IF NOT EXISTS purchases\n                 (user_id INTEGER, item_id INTEGER)''')\n# Insert sample data\ndata = [(1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (2, 4),\n        (3, 3), (3, 4), (3, 5), (4, 1), (4, 4), (5, 1), (5, 2)]\ncursor.executemany('INSERT INTO purchases VALUES (?, ?)', data)\nconn.commit()\nconn.close()\n```\n### Testing\n\nRun tests to verify functionality:\n```\npoetry run pytest\n```\nThis executes tests in tests/test_ai_fuzzy_rec.py, ensuring recommendations and error handling work as expected.\n\n### Project Structure\n```\n/home/m/pyprj/\n\u251c\u2500\u2500 ai_fuzzy_rec/\n\u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u251c\u2500\u2500 ai_fuzzy_rec.py\n\u251c\u2500\u2500 create_database.py\n\u251c\u2500\u2500 purchases.db\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 test_recommender.py\n\u2514\u2500\u2500 tests/\n    \u2514\u2500\u2500 test_ai_fuzzy_rec.py\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An AI-enhanced fuzzy logic-based item recommendation system for SQLite databases.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/fadedreams/ai-fuzzy-rec",
        "Repository": "https://github.com/fadedreams/ai-fuzzy-rec"
    },
    "split_keywords": [
        "fuzzy logic",
        " recommender system",
        " ai",
        " sqlite",
        " recommendations"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "833f542e244ef33eb5357b1d77c7cabce456d9c1e66bb629b320b7406a4370bb",
                "md5": "91d5620e5f023cde430fd8d115a9eefc",
                "sha256": "51e5adc61635a51d5b4dbfbc6320349ac69cfd03e9c3d92d509b0e0e2d4bb0ad"
            },
            "downloads": -1,
            "filename": "ai_fuzzy_rec-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "91d5620e5f023cde430fd8d115a9eefc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6174,
            "upload_time": "2025-07-14T09:17:01",
            "upload_time_iso_8601": "2025-07-14T09:17:01.859563Z",
            "url": "https://files.pythonhosted.org/packages/83/3f/542e244ef33eb5357b1d77c7cabce456d9c1e66bb629b320b7406a4370bb/ai_fuzzy_rec-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a775045383c3b835590c71d506dea27741c78aba13d1beb53750d3b6928ac1f",
                "md5": "d3192780b7a0dc90d80ce9f6558fcdbe",
                "sha256": "7992a4399de8cd1205901cd5c3fbe910c7e3ec1f546c343381f9303606ba8786"
            },
            "downloads": -1,
            "filename": "ai_fuzzy_rec-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d3192780b7a0dc90d80ce9f6558fcdbe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5292,
            "upload_time": "2025-07-14T09:17:03",
            "upload_time_iso_8601": "2025-07-14T09:17:03.070108Z",
            "url": "https://files.pythonhosted.org/packages/2a/77/5045383c3b835590c71d506dea27741c78aba13d1beb53750d3b6928ac1f/ai_fuzzy_rec-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-14 09:17:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fadedreams",
    "github_project": "ai-fuzzy-rec",
    "github_not_found": true,
    "lcname": "ai-fuzzy-rec"
}
        
Elapsed time: 0.41735s