Created
July 3, 2020 04:34
-
-
Save velotiotech/4c3ee4b7851ef02d114bd8cbd8c3a726 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