Views
No views yet
PricePredictor (MLP)torch, scikit-learn, pandas, and huggingface_hub. You can download the model artifacts directly from the Hub.network.py (which defines the model class) in your working directory.1import torch
2import joblib
3import json
4import pandas as pd
5from huggingface_hub import hf_hub_download
6from safetensors.torch import load_file
7
8# Make sure you have network.py in the same directory
9from network import PricePredictor
10
11REPO_ID = "your-username/pokemon-price-predictor"
12MODEL_FILENAME = "model.safetensors"
13CONFIG_FILENAME = "config.json"
14SCALER_FILENAME = "scaler.pkl"
15
16print("Downloading model files from the Hub...")
17model_path = hf_hub_download(repo_id=REPO_ID, filename=MODEL_FILENAME)
18config_path = hf_hub_download(repo_id=REPO_ID, filename=CONFIG_FILENAME)
19scaler_path = hf_hub_download(repo_id=REPO_ID, filename=SCALER_FILENAME)
20print("Downloads complete.")
21
22with open(config_path, "r") as f:
23 config = json.load(f)
24
25feature_columns = config["feature_columns"]
26input_size = config["input_size"]
27
28model = PricePredictor(input_size=input_size)
29model.load_state_dict(load_file(model_path))
30model.eval()
31
32scaler = joblib.load(scaler_path)
33
34data_to_predict = {
35 'rawPrice': [10.0], 'gradedPriceTen': [100.0], 'gradedPriceNine': [50.0],
36}
37
38input_df = pd.DataFrame(data_to_predict)
39missing_cols = set(feature_columns) - set(input_df.columns)
40for c in missing_cols:
41 input_df[c] = 0.0
42input_df = input_df[feature_columns]
43
44
45input_scaled = scaler.transform(input_df.values)
46input_tensor = torch.tensor(input_scaled, dtype=torch.float32)
47
48with torch.no_grad():
49 logits = model(input_tensor)
50 probability = torch.sigmoid(logits).item()
51
52print(f"\nPrediction for the input card:")
53print(f" - Probability of 30% price rise in 6 months: {probability:.4f}")
54
55if probability > 0.5:
56 print(" - Prediction: Price WILL LIKELY rise.")
57else:
58 print(" - Prediction: Price WILL LIKELY NOT rise.")