current_month_mean_from_train
This commit is contained in:
parent
402e7b90ac
commit
ec4be03ea1
19
current_month_mean_from_train/run.py
Normal file
19
current_month_mean_from_train/run.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pandas as pd
|
||||
|
||||
train_in = pd.read_csv('../train/in.tsv', header = None, names = ['id', 'nazwa','typ_zbioru', 'rok', 'miesiąc'], sep='\t')
|
||||
train_exp = pd.read_csv('../train/expected.tsv', header = None, names = ['opad'], sep='\t')
|
||||
|
||||
train = train_in.copy()
|
||||
train['opad'] = train_exp
|
||||
|
||||
|
||||
by_miesiac = train.groupby(['rok', 'miesiąc']).mean()
|
||||
|
||||
|
||||
for dataset in ('dev-0', 'test-A'):
|
||||
with open(f'../{dataset}/out.tsv','w') as f_out, open(f'../{dataset}/in.tsv', 'r') as f_in:
|
||||
for line in f_in:
|
||||
_, _, _, rok, miesiac = line.rstrip().split('\t')
|
||||
srednia = by_miesiac.loc[int(rok), int(miesiac)]['opad']
|
||||
f_out.write(str(srednia) + '\n')
|
||||
|
1200
dev-0/out.tsv
1200
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
1440
test-A/out.tsv
1440
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user