Spaces:
Sleeping
Sleeping
Commit
·
aff826c
1
Parent(s):
59cce6a
fix: Correctly track large files with LFS
Browse files
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: PokePrice
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
|
@@ -8,7 +8,24 @@ sdk_version: 4.32.0
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description:
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: PokePrice
|
| 3 |
+
emoji: 🔮
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
short_description: Predicts Pokémon card price trends with a neural network.
|
| 12 |
---
|
| 13 |
|
| 14 |
+
## PricePoke: Pokémon Card Price Trend Predictor
|
| 15 |
+
|
| 16 |
+
This application uses a PyTorch-based neural network to predict whether the market price of a specific Pokémon card will rise by 30% or more over the next six months.
|
| 17 |
+
|
| 18 |
+
### How It Works
|
| 19 |
+
1. **Select a Card:** Choose a Pokémon card from the dropdown menu. The list is populated from a dataset containing historical price information.
|
| 20 |
+
2. **Get Prediction:** The model analyzes various features of the selected card, such as its rarity, type, and historical price data, to make a prediction.
|
| 21 |
+
3. **View Results:** The application displays:
|
| 22 |
+
* The prediction (whether the price is expected to **RISE** or **NOT RISE**).
|
| 23 |
+
* The model's confidence level in the prediction.
|
| 24 |
+
* A direct link to view the card on TCGPlayer.com.
|
| 25 |
+
* The actual historical outcome if it exists in the dataset, for comparison.
|
| 26 |
+
|
| 27 |
+
### The Technology
|
| 28 |
+
- **Model:** A simple feed-forward neural network built with PyTorch.
|
| 29 |
+
- **Data:** The model was trained on a custom dataset derived from the [Pokémon TCG API](https://pokemontcg.io/) and historical market data from TCGPlayer.
|
| 30 |
+
- **Frontend:** The user interface is created with [Gradio](https://www.gradio.app/).
|
| 31 |
+
- **Deployment:** Hosted on [Hugging Face Spaces](https://huggingface.co/spaces).
|
app.py
CHANGED
|
@@ -13,6 +13,7 @@ MODEL_DIR = "model"
|
|
| 13 |
DATA_DIR = "data"
|
| 14 |
SCALER_PATH = os.path.join(DATA_DIR, "scaler.pkl")
|
| 15 |
DATA_PATH = os.path.join(DATA_DIR, "pokemon_final_with_labels.csv")
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
def load_model_and_config(model_dir: str) -> Tuple[torch.nn.Module, List[str]]:
|
|
@@ -77,16 +78,19 @@ def predict_price_trend(card_display_name: str) -> str:
|
|
| 77 |
prediction_text = "**RISE**" if predicted_class else "**NOT RISE**"
|
| 78 |
confidence = probability if predicted_class else 1 - probability
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
true_label_text = ""
|
| 82 |
-
if
|
| 83 |
-
true_label = bool(card_sample[
|
| 84 |
true_label_text = f"\n- **Actual Result in Dataset:** The price did **{'RISE' if true_label else 'NOT RISE'}**."
|
| 85 |
|
| 86 |
output = f"""
|
| 87 |
## 🔮 Prediction Report for {card_sample['name']}
|
| 88 |
- **Prediction:** The model predicts the card's price will {prediction_text} by 30% in the next 6 months.
|
| 89 |
- **Confidence:** {confidence:.2%}
|
|
|
|
| 90 |
{true_label_text}
|
| 91 |
"""
|
| 92 |
return output
|
|
|
|
| 13 |
DATA_DIR = "data"
|
| 14 |
SCALER_PATH = os.path.join(DATA_DIR, "scaler.pkl")
|
| 15 |
DATA_PATH = os.path.join(DATA_DIR, "pokemon_final_with_labels.csv")
|
| 16 |
+
TARGET_COLUMN = 'price_will_rise_30_in_6m'
|
| 17 |
|
| 18 |
|
| 19 |
def load_model_and_config(model_dir: str) -> Tuple[torch.nn.Module, List[str]]:
|
|
|
|
| 78 |
prediction_text = "**RISE**" if predicted_class else "**NOT RISE**"
|
| 79 |
confidence = probability if predicted_class else 1 - probability
|
| 80 |
|
| 81 |
+
# Construct the TCGPlayer link
|
| 82 |
+
tcgplayer_link = f"https://www.tcgplayer.com/product/{tcgplayer_id}?Language=English"
|
| 83 |
+
|
| 84 |
true_label_text = ""
|
| 85 |
+
if TARGET_COLUMN in card_sample and pd.notna(card_sample[TARGET_COLUMN]):
|
| 86 |
+
true_label = bool(card_sample[TARGET_COLUMN])
|
| 87 |
true_label_text = f"\n- **Actual Result in Dataset:** The price did **{'RISE' if true_label else 'NOT RISE'}**."
|
| 88 |
|
| 89 |
output = f"""
|
| 90 |
## 🔮 Prediction Report for {card_sample['name']}
|
| 91 |
- **Prediction:** The model predicts the card's price will {prediction_text} by 30% in the next 6 months.
|
| 92 |
- **Confidence:** {confidence:.2%}
|
| 93 |
+
- **View on TCGPlayer:** [Check Current Price]({tcgplayer_link})
|
| 94 |
{true_label_text}
|
| 95 |
"""
|
| 96 |
return output
|