File size: 3,762 Bytes
4df9cee 7812756 4df9cee 7812756 4df9cee 7812756 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
---
title: Kickstarter Success Prediction
emoji: π
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: "3.9"
app_file: app.py
pinned: false
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
# Kickstarter Success Prediction API
This API predicts the success probability of Kickstarter campaigns using machine learning.
## API Usage
### Endpoint: `/predict`
Send a POST request with your campaign data in JSON format.
### Input Format
```json
{
"raw_description": "Detailed project description...",
"raw_blurb": "Short project summary...",
"raw_risks": "Project risks and challenges...",
"raw_category": "Technology",
"raw_subcategory": "Gadgets",
"raw_country": "Canada",
"description_length": 557,
"funding_goal": 58000,
"image_count": 8,
"video_count": 3,
"campaign_duration": 90,
"previous_projects_count": 5,
"previous_success_rate": 0.4,
"previous_pledged": 18745.33,
"previous_funding_goal": 23564.99
}
```
The system will use the provided numerical values directly if they exist in the input. If any numerical fields are missing, they will be calculated during preprocessing.
### Output Format
```json
{
"success_probability": 0.7532,
"predicted_outcome": "Success",
"shap_values": {
"funding_goal": -0.8991450071334839,
"description_embedding": -0.04273056983947754,
"subcategory_embedding": 0.011444330215454102,
"previous_funding_goal": -0.008600413799285889,
"video_count": 0.0037734508514404297,
...
},
"longformer_embedding": [0.0213, -0.0124, 0.0342, ..., 0.0547]
}
```
- `success_probability`: A value between 0 and 1 representing the likelihood of project success
- `predicted_outcome`: "Success" if probability β₯ 0.5, otherwise "Failure"
- `shap_values`: Contribution of each feature to the prediction (positive values increase success probability, negative values decrease it)
- `longformer_embedding`: The 768-dimensional vector generated by the Longformer model representing the semantic content of the project description (useful for further analysis or clustering)
## Example Usage with Python
```python
import requests
import json
import numpy as np
# API endpoint
api_url = "https://huggingface.co/spaces/angusfung/kickstarter-success-prediction/predict"
# Load your campaign data
campaign_data = {
"raw_description": "Introducing the AquaGo...",
"raw_blurb": "AquaGo is a smart, eco-friendly portable water purifier...",
"raw_risks": "Bringing a product to market involves...",
"raw_subcategory": "Gadgets",
"raw_category": "Technology",
"raw_country": "Canada",
"funding_goal": 2000,
"image_count": 8,
"video_count": 3
}
# Make prediction request
response = requests.post(api_url, json=campaign_data)
# Print results
if response.status_code == 200:
result = response.json()
print(f"Success Probability: {result['success_probability']:.2f}")
print(f"Predicted Outcome: {result['predicted_outcome']}")
print("\nTop 5 SHAP Values (Feature Importance):")
for i, (feature, value) in enumerate(list(result['shap_values'].items())[:5]):
print(f"{feature}: {value:.4f}")
# Access the longformer embedding if needed
if 'longformer_embedding' in result:
embedding = np.array(result['longformer_embedding'])
print(f"\nLongformer Embedding Shape: {embedding.shape}")
else:
print(f"Error: {response.status_code}")
print(response.text)
```
## Example Usage with cURL
```bash
curl -X POST "https://huggingface.co/spaces/angusfung/kickstarter-success-prediction/predict" \
-H "Content-Type: application/json" \
-d @campaign.json
```
Where `campaign.json` contains your campaign data in the format described above. |