forked from HSE-LAMBDA/coopetition-addition-baseline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.py
executable file
·31 lines (24 loc) · 853 Bytes
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
""" demo of a simple coopetition solution """
import os
import sys
import pandas as pd
def predict(data):
"""
get two colums from `df` and returns the predicted ouput as a column (pd.Series)
"""
result = data['col1'] + data['col2']
return result
def main(input_dir, output_dir):
""" main procedure """
df = pd.read_csv(os.path.join(input_dir, 'data.tsv'), sep='\t')
predicted_result = predict(df)
assert isinstance(predicted_result, pd.core.series.Series), \
f"Invalid predicted output type {type(predicted_result)}"
predicted_result.to_csv(
os.path.join(output_dir, 'data.predict'),
index=False,
header=False)
if __name__ == "__main__":
assert len(sys.argv) >= 3, f"Invalid number of arguments: {len(sys.argv)}"
main(sys.argv[1], sys.argv[2])