ccfraud-detector 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ htmlcov/
37
+ .tox/
38
+ .nox/
39
+ .coverage
40
+ .coverage.*
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+ *.cover
45
+ *.py,cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Environments
54
+ .env
55
+ .venv
56
+ env/
57
+ venv/
58
+ ENV/
59
+ env.bak/
60
+ venv.bak/
61
+
62
+ # IDE
63
+ .idea/
64
+ .vscode/
65
+ *.swp
66
+ *.swo
67
+ *~
68
+
69
+ # Type checking
70
+ .mypy_cache/
71
+ .dmypy.json
72
+ dmypy.json
73
+
74
+ # Linting
75
+ .ruff_cache/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # Data files
81
+ data/
82
+ *.csv
83
+
84
+ # OS
85
+ .DS_Store
86
+ Thumbs.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aditya Patange, Ekta Bhatia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,89 @@
1
+ # CCFraud Detector - Build, Lint, and Test Commands
2
+ # Authors: Aditya Patange, Ekta Bhatia
3
+ # License: MIT
4
+
5
+ .PHONY: all install install-dev build clean lint format typecheck test test-unit test-integration coverage publish help
6
+
7
+ # Default target
8
+ all: lint typecheck test
9
+
10
+ # Installation
11
+ install:
12
+ pip install -e .
13
+
14
+ install-dev:
15
+ pip install -e ".[dev]"
16
+
17
+ # Build
18
+ build: clean
19
+ python -m build
20
+
21
+ clean:
22
+ rm -rf dist/ build/ *.egg-info/
23
+ rm -rf .pytest_cache/ .mypy_cache/ .ruff_cache/
24
+ rm -rf htmlcov/ .coverage
25
+ find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
26
+ find . -type f -name "*.pyc" -delete 2>/dev/null || true
27
+
28
+ # Linting and Formatting
29
+ lint:
30
+ ruff check ccfraud_detector/ tests/
31
+
32
+ format:
33
+ ruff format ccfraud_detector/ tests/
34
+ ruff check --fix ccfraud_detector/ tests/
35
+
36
+ typecheck:
37
+ mypy ccfraud_detector/
38
+
39
+ # Testing
40
+ test: test-unit
41
+
42
+ test-unit:
43
+ pytest tests/ -v --ignore=tests/test_integration.py -m "not integration"
44
+
45
+ test-integration:
46
+ pytest tests/ -v -m integration
47
+
48
+ test-all:
49
+ pytest tests/ -v
50
+
51
+ coverage:
52
+ pytest tests/ -v --cov=ccfraud_detector --cov-report=html --cov-report=term-missing
53
+
54
+ # Publishing
55
+ publish: build
56
+ twine upload dist/*
57
+
58
+ publish-test: build
59
+ twine upload --repository testpypi dist/*
60
+
61
+ # Help
62
+ help:
63
+ @echo "CCFraud Detector - Available Commands"
64
+ @echo "======================================"
65
+ @echo "Authors: Aditya Patange, Ekta Bhatia"
66
+ @echo ""
67
+ @echo "Installation:"
68
+ @echo " make install - Install package in editable mode"
69
+ @echo " make install-dev - Install with development dependencies"
70
+ @echo ""
71
+ @echo "Build:"
72
+ @echo " make build - Build distribution packages"
73
+ @echo " make clean - Remove build artifacts"
74
+ @echo ""
75
+ @echo "Code Quality:"
76
+ @echo " make lint - Run ruff linter"
77
+ @echo " make format - Format code with ruff"
78
+ @echo " make typecheck - Run mypy type checking"
79
+ @echo ""
80
+ @echo "Testing:"
81
+ @echo " make test - Run unit tests"
82
+ @echo " make test-unit - Run unit tests only"
83
+ @echo " make test-integration - Run integration tests (requires ANTHROPIC_API_KEY)"
84
+ @echo " make test-all - Run all tests"
85
+ @echo " make coverage - Run tests with coverage report"
86
+ @echo ""
87
+ @echo "Publishing:"
88
+ @echo " make publish - Publish to PyPI"
89
+ @echo " make publish-test - Publish to TestPyPI"
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.4
2
+ Name: ccfraud-detector
3
+ Version: 1.1.0
4
+ Summary: AI-powered credit card fraud detection using Anthropic Claude
5
+ Project-URL: Homepage, https://github.com/AdityaPatange1/creditcard_fraud_classifier
6
+ Project-URL: Documentation, https://github.com/AdityaPatange1/creditcard_fraud_classifier#readme
7
+ Project-URL: Repository, https://github.com/AdityaPatange1/creditcard_fraud_classifier.git
8
+ Project-URL: Issues, https://github.com/AdityaPatange1/creditcard_fraud_classifier/issues
9
+ Author-email: Aditya Patange <contact.adityapatange@gmail.com>, Ekta Bhatia <ekta.bhatia@example.com>
10
+ Maintainer-email: Aditya Patange <contact.adityapatange@gmail.com>, Ekta Bhatia <ekta.bhatia@example.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai,anthropic,claude,credit-card,fintech,fraud-detection,machine-learning,security
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Office/Business :: Financial
25
+ Classifier: Topic :: Security
26
+ Requires-Python: >=3.9
27
+ Requires-Dist: anthropic>=0.40.0
28
+ Requires-Dist: pydantic>=2.0.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: mypy>=1.13.0; extra == 'dev'
31
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.8.0; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # CCFraud Detector
37
+
38
+ **AI-powered credit card fraud detection using Anthropic Claude**
39
+
40
+ [![PyPI version](https://badge.fury.io/py/ccfraud-detector.svg)](https://pypi.org/project/ccfraud-detector/)
41
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
+
44
+ A production-ready Python package for comprehensive credit card fraud detection powered by Anthropic's Claude AI models.
45
+
46
+ ## Authors & Contributors
47
+
48
+ - **Aditya Patange** - Lead Developer - [contact.adityapatange@gmail.com](mailto:contact.adityapatange@gmail.com)
49
+ - **Ekta Bhatia** - Co-Developer
50
+
51
+ ## Features
52
+
53
+ - **Transaction Analysis** - Detect fraudulent transactions using AI-powered pattern recognition
54
+ - **Card Number Validation** - Luhn algorithm + AI analysis for card number verification
55
+ - **CVV Validation** - Intelligent CVV format and pattern analysis
56
+ - **Card Image Analysis** - Detect fake, tampered, or manipulated card images
57
+ - **Person Image Analysis** - Identify synthetic faces, deepfakes, and stolen identities
58
+ - **Form Field Signals** - Detect bot submissions, copy-paste patterns, and suspicious data
59
+ - **Scam Detection** - Identify various fraud schemes including:
60
+ - Prostitution/escort service disguised transactions
61
+ - Organized crime rackets
62
+ - Bank looting schemes
63
+ - Data mining/harvesting fraud
64
+ - Phishing attacks
65
+ - Identity theft
66
+ - Card skimming operations
67
+ - Account takeover attempts
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ pip install ccfraud-detector
73
+ ```
74
+
75
+ For development:
76
+
77
+ ```bash
78
+ pip install ccfraud-detector[dev]
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ ```python
84
+ from ccfraud_detector import CCFraudDetector, Transaction
85
+
86
+ # Initialize the detector
87
+ detector = CCFraudDetector(api_key="your-anthropic-api-key")
88
+
89
+ # Analyze a transaction
90
+ transaction = Transaction(
91
+ amount=9999.99,
92
+ merchant="Suspicious Electronics Store",
93
+ category="electronics",
94
+ timestamp="2026-01-10T03:45:00Z",
95
+ location="Unknown Location",
96
+ is_online=True,
97
+ ip_address="185.220.101.1"
98
+ )
99
+
100
+ result = detector.analyze_transaction(transaction)
101
+
102
+ print(f"Is Fraud: {result.is_fraud}")
103
+ print(f"Fraud Type: {result.fraud_type.value}")
104
+ print(f"Confidence: {result.confidence:.2%}")
105
+ print(f"Risk Score: {result.risk_score}/100")
106
+ print(f"Details: {result.details}")
107
+ print(f"Recommendations: {result.recommendations}")
108
+ ```
109
+
110
+ ## API Reference
111
+
112
+ ### CCFraudDetector
113
+
114
+ The main class for fraud detection.
115
+
116
+ ```python
117
+ from ccfraud_detector import CCFraudDetector
118
+
119
+ detector = CCFraudDetector(
120
+ api_key="your-api-key", # Optional: uses ANTHROPIC_API_KEY env var if not provided
121
+ model="claude-sonnet-4-20250514" # Optional: Claude model to use
122
+ )
123
+ ```
124
+
125
+ ### Methods
126
+
127
+ #### `analyze_transaction(transaction: Transaction) -> FraudResult`
128
+
129
+ Analyze a credit card transaction for fraud indicators.
130
+
131
+ ```python
132
+ from ccfraud_detector import Transaction
133
+
134
+ txn = Transaction(
135
+ amount=150.00,
136
+ merchant="Online Store",
137
+ category="retail",
138
+ timestamp="2026-01-10T14:30:00Z",
139
+ location="New York, NY",
140
+ card_last_four="1234",
141
+ is_online=True,
142
+ ip_address="192.168.1.1",
143
+ device_id="device-abc",
144
+ metadata={"user_agent": "Mozilla/5.0"}
145
+ )
146
+
147
+ result = detector.analyze_transaction(txn)
148
+ ```
149
+
150
+ #### `validate_card_number(card_number: str) -> FraudResult`
151
+
152
+ Validate a card number using Luhn algorithm and AI analysis.
153
+
154
+ ```python
155
+ result = detector.validate_card_number("4111111111111111")
156
+ ```
157
+
158
+ #### `validate_cvv(cvv: str, card_type: str = "unknown") -> FraudResult`
159
+
160
+ Validate CVV format and detect suspicious patterns.
161
+
162
+ ```python
163
+ result = detector.validate_cvv("123", card_type="visa")
164
+ ```
165
+
166
+ #### `analyze_card_image(image_path: str | Path) -> FraudResult`
167
+
168
+ Analyze a card image for signs of forgery or manipulation.
169
+
170
+ ```python
171
+ result = detector.analyze_card_image("/path/to/card_image.jpg")
172
+ ```
173
+
174
+ #### `analyze_person_image(image_path: str | Path) -> FraudResult`
175
+
176
+ Analyze a person's image for identity fraud indicators (synthetic faces, deepfakes).
177
+
178
+ ```python
179
+ result = detector.analyze_person_image("/path/to/person_photo.jpg")
180
+ ```
181
+
182
+ #### `analyze_field_signals(fields: dict) -> FraudResult`
183
+
184
+ Analyze form field data for suspicious patterns.
185
+
186
+ ```python
187
+ result = detector.analyze_field_signals({
188
+ "name": "John Doe",
189
+ "email": "john@example.com",
190
+ "phone": "+1-555-123-4567",
191
+ "address": "123 Main St"
192
+ })
193
+ ```
194
+
195
+ #### `detect_scam(...) -> FraudResult`
196
+
197
+ Detect various scam types in transaction or description.
198
+
199
+ ```python
200
+ result = detector.detect_scam(
201
+ transaction=txn,
202
+ description="Wire transfer for investment",
203
+ merchant_category="6012"
204
+ )
205
+ ```
206
+
207
+ #### `full_analysis(...) -> dict[str, FraudResult]`
208
+
209
+ Perform comprehensive fraud analysis on all provided data.
210
+
211
+ ```python
212
+ results = detector.full_analysis(
213
+ transaction=txn,
214
+ card_number="4111111111111111",
215
+ cvv="123",
216
+ card_image_path="/path/to/card.jpg",
217
+ person_image_path="/path/to/person.jpg",
218
+ form_fields={"name": "John Doe"}
219
+ )
220
+
221
+ for analysis_type, result in results.items():
222
+ print(f"{analysis_type}: {result.is_fraud} (risk: {result.risk_score})")
223
+ ```
224
+
225
+ ### Data Classes
226
+
227
+ #### `Transaction`
228
+
229
+ ```python
230
+ @dataclass
231
+ class Transaction:
232
+ amount: float
233
+ merchant: str
234
+ category: str
235
+ timestamp: str
236
+ location: str | None = None
237
+ card_last_four: str | None = None
238
+ is_online: bool = False
239
+ ip_address: str | None = None
240
+ device_id: str | None = None
241
+ metadata: dict[str, Any] = field(default_factory=dict)
242
+ ```
243
+
244
+ #### `FraudResult`
245
+
246
+ ```python
247
+ @dataclass
248
+ class FraudResult:
249
+ is_fraud: bool
250
+ fraud_type: FraudType
251
+ confidence: float # 0.0 to 1.0
252
+ risk_score: float # 0.0 to 100.0
253
+ details: str
254
+ recommendations: list[str]
255
+ raw_analysis: str
256
+ ```
257
+
258
+ #### `FraudType`
259
+
260
+ ```python
261
+ class FraudType(Enum):
262
+ TRANSACTION = "transaction_fraud"
263
+ CARD_NUMBER = "invalid_card_number"
264
+ CVV = "cvv_anomaly"
265
+ CARD_IMAGE = "fake_card_image"
266
+ PERSON_IMAGE = "fake_person_identity"
267
+ FIELD_SIGNAL = "suspicious_field_pattern"
268
+ SCAM_PROSTITUTION = "prostitution_scam"
269
+ SCAM_RACKET = "organized_racket"
270
+ SCAM_BANK_LOOTING = "bank_looting"
271
+ SCAM_DATA_MINING = "data_mining_fraud"
272
+ SCAM_PHISHING = "phishing_attack"
273
+ SCAM_IDENTITY_THEFT = "identity_theft"
274
+ SCAM_CARD_SKIMMING = "card_skimming"
275
+ SCAM_ACCOUNT_TAKEOVER = "account_takeover"
276
+ CLEAN = "no_fraud_detected"
277
+ ```
278
+
279
+ ## Development
280
+
281
+ ### Setup
282
+
283
+ ```bash
284
+ git clone https://github.com/AdityaPatange1/creditcard_fraud_classifier.git
285
+ cd creditcard_fraud_classifier
286
+ make install-dev
287
+ ```
288
+
289
+ ### Commands
290
+
291
+ ```bash
292
+ make lint # Run linter
293
+ make format # Format code
294
+ make typecheck # Run type checking
295
+ make test # Run unit tests
296
+ make test-integration # Run integration tests (requires ANTHROPIC_API_KEY)
297
+ make test-all # Run all tests
298
+ make coverage # Generate coverage report
299
+ make build # Build distribution
300
+ make clean # Clean build artifacts
301
+ ```
302
+
303
+ ### Running Tests
304
+
305
+ Unit tests (no API key required):
306
+
307
+ ```bash
308
+ make test-unit
309
+ ```
310
+
311
+ Integration tests (requires `ANTHROPIC_API_KEY`):
312
+
313
+ ```bash
314
+ export ANTHROPIC_API_KEY=your-key
315
+ make test-integration
316
+ ```
317
+
318
+ ## Dataset
319
+
320
+ This project includes analysis based on the [Kaggle Credit Card Fraud Detection Dataset](https://www.kaggle.com/mlg-ulb/creditcardfraud).
321
+
322
+ ## License
323
+
324
+ MIT License - see [LICENSE](LICENSE) for details.
325
+
326
+ ## Contributing
327
+
328
+ Contributions are welcome! Please feel free to submit a Pull Request.
329
+
330
+ 1. Fork the repository
331
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
332
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
333
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
334
+ 5. Open a Pull Request
335
+
336
+ ## Support
337
+
338
+ For issues and feature requests, please use the [GitHub Issues](https://github.com/AdityaPatange1/creditcard_fraud_classifier/issues) page.
339
+
340
+ ---
341
+
342
+ **Built with care by Aditya Patange & Ekta Bhatia**