File size: 742 Bytes
4aaa648
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from tensorflow import keras
import pandas as pd
import numpy as np

# Load model
model = keras.models.load_model("niche_classifier_model.keras")

# Example input (replace this with real preprocessed data)
sample = pd.DataFrame({
    "score": [123],
    "num_comments": [45],
    "upvote_ratio": [0.92],
    "title_length": [84],
    "selftext_length": [203],
    "contains_question": [1],
    "contains_capslock": [0],
    "engagement_score": [0.85],
    "hour_of_posting": [15],
    "num_caps_words": [2],
    "subreddit_AskReddit": [1],
    "subreddit_relationships": [0],
    "subreddit_TIFU": [0],
    # add other one-hot subreddit features as needed
})

pred = model.predict(sample).argmax(axis=1)
print("Predicted class index:", pred)