{"id":31445784,"url":"https://github.com/science-analyse/clv_model","last_synced_at":"2025-10-15T12:17:58.594Z","repository":{"id":268114724,"uuid":"903357091","full_name":"science-analyse/clv_model","owner":"science-analyse","description":"customer lifetime value prediction","archived":false,"fork":false,"pushed_at":"2024-12-15T20:11:13.000Z","size":20652,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-30T23:37:15.604Z","etag":null,"topics":["banking","banking-applications","clv","clv-analysis","data","data-science","machine-learning"],"latest_commit_sha":null,"homepage":"https://clv-model.onrender.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/science-analyse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-14T11:56:13.000Z","updated_at":"2025-08-10T11:57:03.000Z","dependencies_parsed_at":"2024-12-14T13:20:03.256Z","dependency_job_id":"d375b89b-d16d-49f6-a694-3c59211f3ea4","html_url":"https://github.com/science-analyse/clv_model","commit_stats":null,"previous_names":["ismat-samadov/user_behaviour","ismat-samadov/clv_model","science-analyse/clv_model"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/science-analyse/clv_model","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/science-analyse%2Fclv_model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/science-analyse%2Fclv_model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/science-analyse%2Fclv_model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/science-analyse%2Fclv_model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/science-analyse","download_url":"https://codeload.github.com/science-analyse/clv_model/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/science-analyse%2Fclv_model/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279077248,"owners_count":26098234,"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","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["banking","banking-applications","clv","clv-analysis","data","data-science","machine-learning"],"created_at":"2025-09-30T23:32:17.557Z","updated_at":"2025-10-15T12:17:58.577Z","avatar_url":"https://github.com/science-analyse.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Banking Customer Lifetime Value (CLV) Prediction Model\n\nThis project implements a machine learning system for predicting Customer Lifetime Value in banking, including data generation, model training, and a web-based prediction API.\n\n## Project Overview\n\nThe system consists of three main components:\n1. Synthetic data generation for banking customers\n2. Machine learning model for CLV prediction\n3. FastAPI-based web service with an interactive UI\n\n### Directory Structure\n```\n.\n├── api.py              # FastAPI web service implementation\n├── data_gen.py         # Synthetic data generation script\n├── model.py            # CLV prediction model implementation\n├── index.html          # Web interface\n├── requirements.txt    # Project dependencies\n├── data/               # Generated datasets\n│   ├── customers.csv\n│   ├── products.csv\n│   ├── transactions.csv\n│   └── customer_metrics.csv\n└── models/            # Trained model artifacts\n    └── clv_model_latest/\n        ├── model.joblib\n        ├── scaler.joblib\n        ├── label_encoders.joblib\n        ├── feature_names.joblib\n        └── feature_importance.joblib\n```\n\n## Features\n\n- **Data Generation**\n  - Realistic synthetic customer data\n  - Transaction history generation\n  - Product holdings simulation\n  - Configurable parameters for data size and date ranges\n\n- **Machine Learning Model**\n  - Gradient Boosting Regressor\n  - Feature engineering pipeline\n  - Model persistence and versioning\n  - Confidence score calculation\n\n- **Web API \u0026 Interface**\n  - RESTful endpoints for predictions\n  - Interactive web UI for data input\n  - Real-time CLV predictions\n  - Error handling and validation\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/Ismat-Samadov/clv_model.git\ncd clv_model\n```\n\n2. Create and activate a virtual environment (recommended):\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## Usage\n\n### 1. Generate Synthetic Data\n\nRun the data generation script:\n```bash\npython data_gen.py\n```\nThis will create synthetic banking data in the `data/` directory.\n\n### 2. Train the Model\n\nThe model training is handled automatically when running the API for the first time. To manually train:\n```python\nfrom model import BankingCLVModel\nmodel = BankingCLVModel()\nmodel.train(customers_df, transactions_df, products_df, metrics_df)\n```\n\n### 3. Start the API Server\n\nRun the FastAPI server:\n```bash\nuvicorn api:app --reload\n```\nThe server will start at `http://localhost:8000`\n\n### 4. Access the Web Interface\n\nOpen `http://localhost:8000` in your web browser to access the CLV prediction interface.\n\n## API Endpoints\n\n### POST /predict/clv\nPredicts CLV for a given customer profile.\n\nExample request body:\n```json\n{\n  \"customer_id\": 1,\n  \"age\": 35,\n  \"income\": 75000,\n  \"credit_score\": 720,\n  \"tenure_months\": 24,\n  \"region\": \"North\",\n  \"acquisition_channel\": \"Online\",\n  \"products\": [\n    {\n      \"product_type\": \"Savings\",\n      \"start_date\": \"2023-01-01T00:00:00\",\n      \"balance\": 5000,\n      \"status\": \"Active\"\n    }\n  ],\n  \"transactions\": [\n    {\n      \"transaction_date\": \"2024-01-01T10:00:00\",\n      \"transaction_type\": \"Deposit\",\n      \"amount\": 1000,\n      \"channel\": \"Online\"\n    }\n  ]\n}\n```\n\n### GET /health\nReturns the health status of the API and model.\n\n## Model Details\n\nThe CLV prediction model:\n- Uses a Gradient Boosting Regressor\n- Incorporates customer demographics, product holdings, and transaction patterns\n- Provides confidence scores for predictions\n- Includes feature importance analysis\n\n### Key Features Used:\n- Customer demographics (age, income, credit score)\n- Account tenure\n- Transaction patterns\n- Product holdings\n- Regional indicators\n- Channel preferences\n\n## Configuration\n\nKey configuration options are available in the respective Python files:\n- `data_gen.py`: Data generation parameters\n- `model.py`: Model hyperparameters\n- `api.py`: API settings and validation rules\n\n## Logging\n\nThe system logs important events and errors to `api.log`. Configure logging levels in `api.py`.\n\n## Development\n\n### Adding New Features\n1. Modify the data generation in `data_gen.py`\n2. Update feature engineering in `model.py`\n3. Add new endpoints in `api.py`\n4. Update the web interface in `index.html`\n\n### Testing\nRun the development server with:\n```bash\nuvicorn api:app --reload --port 8000\n```\n\n## Security Considerations\n\n- Input validation for all API endpoints\n- Error handling for invalid data\n- Confidence score calculation for predictions\n- Rate limiting for API endpoints (TODO)\n\n## Dependencies\n\nMajor dependencies include:\n- FastAPI\n- scikit-learn\n- pandas\n- numpy\n- joblib\n- uvicorn\n\nSee `requirements.txt` for complete list.\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit changes\n4. Push to the branch\n5. Create a Pull Request\n\n\n## Author\n\nIsmat Samadov\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscience-analyse%2Fclv_model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscience-analyse%2Fclv_model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscience-analyse%2Fclv_model/lists"}