Commit 9b5100e0 authored by Uwe Köckemann's avatar Uwe Köckemann
Browse files

Notebook for wine example working

parent 79a115a3
......@@ -33,6 +33,7 @@ class SciKitLearnFunction(Function):
def apply(self, mlProblem):
x, y = splitAiddlMlProblem(mlProblem)
print(y)
self.model.fit(x, y)
y_p = self.model.predict(x)
r = []
......@@ -99,9 +100,12 @@ def splitAiddlMlProblem(mlProblem):
x = []
labelIdx = -1
for i in range(len(atts)):
# print(atts[i][0], type(atts[i][0]), label, type(label), atts[i][0] == label)
if atts[i][0] == label:
labelIdx = i
break
if labelIdx == -1:
raise ValueError("Label not found.")
c = 0
for row in data:
x_row = []
......@@ -111,7 +115,7 @@ def splitAiddlMlProblem(mlProblem):
else:
x_row.append(row[i].unpack())
print(c, row[i], type(row[i]), type(row[i].unpack()))
# print(c, row[i], type(row[i]), type(row[i].unpack()))
c += 1
x.append(x_row)
return x, y
......@@ -14,26 +14,23 @@ class CsvLoader(Function):
def apply(self, args):
fName = str(args[0].get_string_value())
sep = str(args[1].get_string_value())
label = str(args[2])
print("Separator: " + sep)
label = args[2]
f = open(fName, "r")
lines = f.readlines()
f.close()
print(lines[0])
atts = []
for att in lines[0].split(sep):
if att.strip() != "":
print(att)
atts.append(Tuple([parse_term(att.strip()), Symbolic("org.aiddl.term")]))
atts.append(Tuple([String(att.strip()), Symbolic("org.aiddl.term")]))
data = []
for row in lines[1:]:
data_row = []
for e in row.split(sep):
if e.strip() != "":
data_row.append(parse_term(e.strip()))
data.append(List(data_row))
if row.strip() != "":
data_row = []
for e in row.split(sep):
if e.strip() != "":
data_row.append(parse_term(e.strip()))
data.append(List(data_row))
f.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment