regresja
This commit is contained in:
parent
33b70ce7b1
commit
3b814045a7
20000
dev-0/out.tsv
Normal file
20000
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
11563
dev-1/out.tsv
Normal file
11563
dev-1/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
35
run.py
Normal file
35
run.py
Normal file
@ -0,0 +1,35 @@
|
||||
from sklearn.linear_model import LinearRegression
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
import pandas as pd
|
||||
|
||||
def regresja(path):
|
||||
|
||||
# dnae do modelu
|
||||
train = pd.read_csv('train/train.tsv', sep='\t', header=None)
|
||||
y_train = train[0]
|
||||
x_train = train[4]
|
||||
|
||||
# dane do predykcji
|
||||
x_predict = []
|
||||
with open(f"{path}/in.tsv", encoding='utf-8') as f:
|
||||
for line in f:
|
||||
x_predict.append(line)
|
||||
|
||||
# tfidf
|
||||
vectorizer = TfidfVectorizer()
|
||||
x_train = vectorizer.fit_transform(x_train)
|
||||
|
||||
x_predict = vectorizer.transform(x_predict)
|
||||
|
||||
# model regresji
|
||||
model = LinearRegression()
|
||||
model.fit(x_train, y_train)
|
||||
|
||||
# przewidywanie wyniku
|
||||
y_predict = model.predict(x_predict)
|
||||
pd.DataFrame(y_predict).to_csv(f"{path}/out.tsv", header=False, index=None)
|
||||
|
||||
|
||||
regresja("dev-0")
|
||||
regresja("dev-1")
|
||||
regresja("test-A")
|
14220
test-A/out.tsv
Normal file
14220
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
107471
train/train.tsv
Normal file
107471
train/train.tsv
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user