RTRP Batch 10
RTRP Batch 10
• # Splitting dataset
• X_train, X_test, y_train, y_test = train_test_split(df['text'],
df['label'], test_size=0.2, random_state=42)
• # Creating a text processing and classification pipeline
• pipeline = Pipeline([
• ('vectorizer', CountVectorizer()),
• ('tfidf', TfidfTransformer()),
• ('classifier', MultinomialNB())
• ])
• # Train model
• pipeline.fit(X_train, y_train)
• # Example
• sms_text = "Congratulations! You've won a free lottery ticket. Call now!"
• print("Prediction:", predict_sms(sms_text))
Program Implimentation:
output:
Benefits of Using Python for SMS Spam
Detection:
1.Easy to Use & Readable – Python’s simple syntax makes it beginner-friendly for
machine learning and text processing.
2.Rich Libraries – Powerful tools like scikit-learn, NLTK, and pandas simplify spam
detection.
3.Strong Text Processing – Efficient tokenization, stemming, and TF-IDF
transformation for better accuracy.
4.AI & ML Integration – Supports Naïve Bayes, Deep Learning, and scalable
deployment with Flask/FastAPI.
5.Large Community Support – Open-source tools, datasets, and active forums for
learning and troubleshooting.
THANK YOU