-
Notifications
You must be signed in to change notification settings - Fork 0
/
linemodel.py
executable file
·44 lines (36 loc) · 980 Bytes
/
linemodel.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
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 5 16:17:04 2020
@author: deborahkhider
Simple line model for testing MIC
"""
import json
import sys
import numpy as np
import os
def calc_predict(x,a,b,c):
y=a*x+b+c
return y
if __name__ == "__main__":
with open(sys.argv[1]) as json_file:
config=json.load(json_file)
#open
dataset_name = config['input']['dataset_name']
dir_out = config['output']['path']
a=float(config['params']['a'])
b=float(config['params']['b'])
c=float(config['params']['c'])
#open the file
x=np.genfromtxt('x.csv')[1:]
#calculate
y=calc_predict(x,a,b,c)
#save as csv
if dir_out[-1]=='/':
if os.path.isdir(dir_out+'results') is False:
os.makedirs(dir_out+'results')
else:
if os.path.isdir(dir_out+'/results') is False:
os.makedirs(dir_out+'/results')
path=dir_out+'/results/y.csv'
np.savetxt(path,y)