Download test_kmeans_format.py from Deepu1965/code2-repo: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/Deepu1965/code2-repo/resolve/main/test_kmeans_format.py
- Command line
-
hf download hf://Deepu1965/code2-repo/test_kmeans_format.py
-
curl -L -o test_kmeans_format.py https://huggingface.co/Deepu1965/code2-repo/resolve/main/test_kmeans_format.py
2.07 kB
| #!/usr/bin/env python3 | |
| """ | |
| Quick test to verify K-Means returns proper format | |
| """ | |
| import sys | |
| sys.path.insert(0, '/home/deepu/Downloads/code2') | |
| from risk_discovery import UnsupervisedRiskDiscovery | |
| # Sample clauses | |
| sample_clauses = [ | |
| "The Company shall not be liable for any indirect damages.", | |
| "Either party may terminate this Agreement upon 30 days notice.", | |
| "All intellectual property rights remain with the Company.", | |
| "Customer agrees to pay monthly fees of $10,000.", | |
| "Each party shall keep confidential all information disclosed.", | |
| "The Service Provider agrees to indemnify the Client.", | |
| "This Agreement shall automatically terminate upon bankruptcy.", | |
| "Vendor shall maintain compliance with ISO 27001 standards.", | |
| ] | |
| print("="*80) | |
| print("Testing K-Means Risk Discovery Return Format") | |
| print("="*80) | |
| # Initialize and run discovery | |
| discovery = UnsupervisedRiskDiscovery(n_clusters=3, random_state=42) | |
| results = discovery.discover_risk_patterns(sample_clauses) | |
| # Check result structure | |
| print("\n" + "="*80) | |
| print("Checking Result Structure") | |
| print("="*80) | |
| required_keys = ['method', 'n_clusters', 'discovered_patterns', 'cluster_labels', 'quality_metrics'] | |
| for key in required_keys: | |
| if key in results: | |
| print(f"✅ '{key}' present") | |
| if key == 'method': | |
| print(f" Value: {results[key]}") | |
| elif key == 'n_clusters': | |
| print(f" Value: {results[key]}") | |
| elif key == 'quality_metrics': | |
| print(f" Metrics: {list(results[key].keys())}") | |
| else: | |
| print(f"❌ '{key}' MISSING") | |
| print("\n" + "="*80) | |
| print("Discovered Patterns:") | |
| print("="*80) | |
| for pattern_name, details in results['discovered_patterns'].items(): | |
| print(f"\n{pattern_name}:") | |
| print(f" Clauses: {details['clause_count']}") | |
| print(f" Key terms: {', '.join(details['key_terms'][:5])}") | |
| print("\n" + "="*80) | |
| if all(key in results for key in required_keys): | |
| print("✅ TEST PASSED: All required keys present") | |
| else: | |
| print("❌ TEST FAILED: Missing required keys") | |
| print("="*80) | |