def predictions(posts): """Given a collection of posts (in StackExchange JSON format), return our model's predictions for whether or not each post will be closed. """ # Read in Model with open('model.pickle', 'rb') as f: scaler, classifier = pickle.load(f) data = [cleandata.extract_data_vector(post) for post in posts] X = np.array(data, dtype=np.float64) X_scaled = scaler.transform(X) preds = classifier.predict(X_scaled) return preds
def probabilities(posts): """Given a collection of posts (in StackExchange JSON format), return our model's estimated probabilities that the posts will be closed. """ # Read in Model with open('model.pickle', 'rb') as f: scaler, classifier = pickle.load(f) data = [cleandata.extract_data_vector(post) for post in posts] X = np.array(data, dtype=np.float64) X_scaled = scaler.transform(X) probs = classifier.predict_proba(X_scaled)[:,1] return probs