Random Forest
Random Forest
Random Forest
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.ensemble import RandomForestClassifier
# Assuming your Excel file has columns 'text' and 'label' for text data and labels
X = df['text'].astype(str)
y = df['label']
Accuracy: 0.7500
Classification Report:
precision recall f1-score support
accuracy 1.00 4
macro avg 1.00 1.00 1.00 4
weighted avg 1.00 1.00 1.00 4
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from xgboost import XGBClassifier
from sklearn.metrics import accuracy_score, classification_report
# Assuming your Excel file has columns 'text' and 'label' for text data and labels
X = df['text'].astype(str)
y = df['label']
Accuracy: 0.7500
Classification Report:
precision recall f1-score support
accuracy 0.50 4
macro avg 0.50 0.50 0.50 4
weighted avg 0.50 0.50 0.50 4
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.svm import LinearSVC
from sklearn.metrics import accuracy_score, classification_report
# Assuming your Excel file has columns 'text' and 'label' for text data and labels
X = df['text'].astype(str)
y = df['label']
Accuracy: 0.7500
Classification Report:
precision recall f1-score support
accuracy 1.00 4
macro avg 1.00 1.00 1.00 4
weighted avg 1.00 1.00 1.00 4
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import accuracy_score, classification_report
# Assuming your Excel file has columns 'text' and 'label' for text data and labels
X = df['text'].astype(str)
y = df['label']
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=42)
Accuracy: 0.75
Classification Report:
precision recall f1-score support
accuracy 0.75 4
macro avg 0.83 0.75 0.73 4
weighted avg 0.83 0.75 0.73 4
SVM CLASSIFIER
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, classification_report
# Assuming your Excel file has columns 'text' and 'label' for text data and labels
X = df['text'].astype(str)
y = df['label']
Accuracy: 0.8
Classification Report:
precision recall f1-score support
accuracy 1.00 4
macro avg 1.00 1.00 1.00 4
weighted avg 1.00 1.00 1.00 4