-
-
Save leetcode-notes/9296c9790c9e8d92392922a1d1f20ab1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#predicting the streaming kafka messages | |
consumer = KafkaConsumer('twitter-stream',bootstrap_servers=\['localhost:9092']) | |
print("Starting ML predictions.") | |
for message in consumer: | |
X_new_counts = count_vect.transform([message.value]) | |
X_new_tfidf = tfidf_transformer.transform(X_new_counts) | |
predicted = load_model.predict(X_new_tfidf) | |
print(message.value+" => "+fetch_train_dataset(categories).target_names[predicted[0]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment