December 2018
Intermediate to advanced
274 pages
7h 46m
English
In your project folder, create a python file with the following code to create a model file:
# importing required packagesimport numpy as npimport pandas as pd
# Reading in and parsing dataraw_data = open('SMSSpamCollection.txt', 'r')sms_data = []for line in raw_data: split_line = line.split("\t") sms_data.append(split_line)#Splitting data into messages and labels and training and test in y we are having labels and x with the message textsms_data = np.array(sms_data)X = sms_data[:, 1]y = sms_data[:, 0]#Build a LinearSVC modelfrom sklearn.feature_extraction.text import TfidfVectorizerfrom sklearn.svm import LinearSVC#Build tf-idf vector representation of datavectorizer = TfidfVectorizer()# converting ...Read now
Unlock full access