30 lines
894 B
Python
30 lines
894 B
Python
#!/usr/bin/python3
|
|
|
|
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
from sklearn.decomposition import TruncatedSVD
|
|
from sklearn.linear_model import LinearRegression
|
|
import pandas as pd
|
|
import csv
|
|
import pickle
|
|
|
|
def predict():
|
|
reg = pickle.load(open("reg.model", "rb"))
|
|
vect = pickle.load(open("vect.model", "rb"))
|
|
|
|
dev0 = pd.read_csv("dev-0/in_new.tsv", delimiter="\t", header=None, names=["text"], quoting=csv.QUOTE_NONE)
|
|
testA = pd.read_csv("test-A/in_new.tsv", delimiter="\t", header=None, names=["text"], quoting=csv.QUOTE_NONE)
|
|
|
|
devdoc = dev0["text"]
|
|
testdoc = testA["text"]
|
|
|
|
dev0_vectorizer = vect.transform(devdoc)
|
|
testA_vectorizer = vect.transform(testdoc)
|
|
|
|
dev0_pca = pca.transform(dev0_vectorizer)
|
|
testA_pca = pca.transform(testA_vectorizer)
|
|
|
|
y_dev = reg.predict(dev0_pca)
|
|
y_test = reg.predict(testA_pca)
|
|
|
|
predict()
|