kaknikhil commented on code in PR #613:
URL: https://github.com/apache/madlib/pull/613#discussion_r1496650974
##########
src/ports/postgres/modules/pmml/formula.py_in:
##########
@@ -2,25 +2,50 @@ import plpy
import re
class Formula(object):
+
def __init__(self, y_str, x_str, coef_len):
- self.n_coef = coef_len
+ """
+ :param y_str: Dependent variable used during training
+ :param x_str: Independent variable used during training. Can take
+ multiple formats like
+ 'ARRAY[1,x1,x2]', 'ARRAY[x1,x2]' or just 'x'
+ :param coef_len: Length of all the coefficients including the
+ intercept's coefficient(if any)
+ """
+ # TODO: Fix the nested warning
Review Comment:
This only shows up when you run the unit tests or if you try running this
regex directly in python. I'll try to fix this warning in the next PR
##########
src/ports/postgres/modules/pmml/formula.py_in:
##########
@@ -2,25 +2,50 @@ import plpy
import re
class Formula(object):
+
def __init__(self, y_str, x_str, coef_len):
- self.n_coef = coef_len
+ """
+ :param y_str: Dependent variable used during training
+ :param x_str: Independent variable used during training. Can take
+ multiple formats like
+ 'ARRAY[1,x1,x2]', 'ARRAY[x1,x2]' or just 'x'
+ :param coef_len: Length of all the coefficients including the
+ intercept's coefficient(if any)
+ """
+ # TODO: Fix the nested warning
+ self.array_expr = re.compile(r'array[[]([0-1],)?(["a-z0-9_, .]+)[]]',
flags=re.I)
+ self.non_array_expr = re.compile(r'["a-z0-9_]+', flags=re.I)
+
+ self.intercept = self.has_intercept(x_str)
+ self.all_coef_len = coef_len
+ if self.intercept:
+ self.feature_coef_len = coef_len - 1
+ else:
+ self.feature_coef_len = coef_len
self.y = y_str.replace('"','')
self.x = self.parse(x_str)
+ # TODO: add comments
Review Comment:
yes done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]