|
--- |
|
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. |