signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def custom(self, command): | self.command.append(command)<EOL>return self<EOL> | Run arbitrary SoX effect commands.
Examples:
custom('echo 0.8 0.9 1000 0.3') for an echo effect.
References:
- https://linux.die.net/man/1/soxexam
- http://sox.sourceforge.net/sox.html
- http://tldp.org/LDP/LG/issue73/chung.html
- http://dsl.... | f7577:c0:m36 |
def buy_product(self, product_pk): | if self.invoice_sales.filter(line_invoice_sales__line_order__product__pk=product_pk).exists()or self.ticket_sales.filter(line_ticket_sales__line_order__product__pk=product_pk).exists():<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | determina si el customer ha comprado un producto | f7606:c1:m5 |
@staticmethod<EOL><INDENT>def create_document_from_another(pk, list_lines,<EOL>MODEL_SOURCE, MODEL_FINAL,<EOL>url_reverse,<EOL>msg_error_relation, msg_error_not_found, unique):<DEDENT> | context = {}<EOL>obj_src = MODEL_SOURCE.objects.filter(pk=pk).first()<EOL>if list_lines and obj_src:<EOL><INDENT>list_lines = [int(x) for x in list_lines]<EOL>if unique:<EOL><INDENT>create = not SalesLines.objects.filter(**{"<STR_LIT>": list_lines}).exists()<EOL><DEDENT>else:<EOL><INDENT>create = True<EOL><DEDENT>"""<S... | pk: pk del documento origen
list_lines: listado de pk de lineas de origen
MODEL_SOURCE: modelo del documento origen
MODEL_FINAL: model del documento final
url_reverse: url del destino
msg_error_relation: Mensaje de error indicando que las lineas ya están relacionadas
msg_error_not_found: Mensaje de error indicando que ... | f7606:c20:m0 |
@staticmethod<EOL><INDENT>def create_albaran_automatic(pk, list_lines):<DEDENT> | lines = SalesLines.objects.filter(pk__in=list_lines).exclude(albaran__isnull=False).values_list('<STR_LIT>')<EOL>lines_to_albaran = [x[<NUM_LIT:0>] for x in lines]<EOL>SalesLines.create_albaran_from_order(pk, lines_to_albaran)<EOL>"""<STR_LIT>"""<EOL> | creamos de forma automatica el albaran | f7606:c20:m3 |
@staticmethod<EOL><INDENT>def find(pos, user):<DEDENT> | <EOL>ck = dateparse.parse_time(getattr(settings, "<STR_LIT>", '<STR_LIT>'))<EOL>year = timezone.now().year<EOL>month = timezone.now().month<EOL>day = timezone.now().day<EOL>hour = ck.hour<EOL>minute = ck.minute<EOL>second = ck.second<EOL>checkpoint = timezone.datetime(year, month, day, hour, minute, second)<EOL>cashdia... | Get a valid CashDiary for today from the given POS, it will return:
- None: if no CashDiary is available today and older one was already closed
- New CashDiary: if no CashDiary is available today but there is an older one which it was opened
- Existing CashDiary: if a CashDiary is available today (open or c... | f7610:c0:m2 |
def buy_product(self, product_pk): | if self.invoice_sales.filter(lines_sales__product_final__pk=product_pk).exists()or self.ticket_sales.filter(lines_sales__product_final__pk=product_pk).exists():<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | determina si el customer ha comprado un producto | f7612:c1:m5 |
@staticmethod<EOL><INDENT>def create_document_from_another(pk, list_lines,<EOL>MODEL_SOURCE, MODEL_FINAL,<EOL>url_reverse,<EOL>msg_error_relation, msg_error_not_found, msg_error_line_not_found,<EOL>unique):<DEDENT> | context = {}<EOL>obj_src = MODEL_SOURCE.objects.filter(pk=pk).first()<EOL>if list_lines and obj_src:<EOL><INDENT>list_lines = [int(x) for x in list_lines]<EOL>obj_final = MODEL_FINAL()<EOL>complete = True<EOL>field_final_tax = None<EOL>if isinstance(obj_final, SalesOrder):<EOL><INDENT>obj_final.budget = obj_src<EOL>fie... | pk: pk del documento origen
list_lines: listado de pk de lineas de origen
MODEL_SOURCE: modelo del documento origen
MODEL_FINAL: model del documento final
url_reverse: url del destino
msg_error_relation: Mensaje de error indicando que las lineas ya están relacionadas
msg_error_not_found: Mensaje de error indicando que ... | f7612:c19:m13 |
@staticmethod <EOL><INDENT>def create_albaran_automatic(pk, list_lines):<DEDENT> | lines = SalesLines.objects.filter(pk__in=list_lines, removed=False).exclude(albaran__isnull=False).values_list('<STR_LIT>')<EOL>lines_to_albaran = [x[<NUM_LIT:0>] for x in lines]<EOL>SalesLines.create_albaran_from_order(pk, lines_to_albaran)<EOL> | creamos de forma automatica el albaran | f7612:c19:m16 |
def get(self, request, *args, **kwargs): | cart = ShoppingCartProxy(request)<EOL>return JsonResponse(cart.get_products(onlypublic=request.GET.get('<STR_LIT>', True)))<EOL> | List all products in the shopping cart | f7617:c132:m0 |
def post(self, request, *args, **kwargs): | POST = json.loads(request.body.decode('<STR_LIT:utf-8>'))<EOL>if '<STR_LIT>' in POST and '<STR_LIT>' in POST:<EOL><INDENT>cart = ShoppingCartProxy(request)<EOL>cart.add(<EOL>product_pk=int(POST['<STR_LIT>']),<EOL>quantity=int(POST['<STR_LIT>'])<EOL>)<EOL>return JsonResponse(cart.products)<EOL><DEDENT>return HttpRespons... | Adds new product to the current shopping cart | f7617:c132:m1 |
def buy_product(self, product_pk): | if self.invoice_sales.filter(line_invoice_sales__line_order__product__pk=product_pk).exists()or self.ticket_sales.filter(line_ticket_sales__line_order__product__pk=product_pk).exists():<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | determina si el customer ha comprado un producto | f7625:c1:m5 |
@staticmethod<EOL><INDENT>def create_document_from_another(pk, list_lines,<EOL>MODEL_SOURCE, MODEL_FINAL, MODEL_LINE_SOURCE, MODEL_LINE_FINAL,<EOL>url_reverse, related_line, related_object,<EOL>msg_error_relation, msg_error_not_found, unique):<DEDENT> | context = {}<EOL>obj_src = MODEL_SOURCE.objects.filter(pk=pk).first()<EOL>if list_lines and obj_src:<EOL><INDENT>list_lines = [int(x) for x in list_lines]<EOL>if unique:<EOL><INDENT>create = not MODEL_LINE_FINAL.objects.filter(**{"<STR_LIT>".format(related_line): list_lines}).exists()<EOL><DEDENT>else:<EOL><INDENT>crea... | pk: pk del documento origen
list_lines: listado de pk de lineas de origen
MODEL_SOURCE: modelo del documento origen
MODEL_FINAL: model del documento final
MODEL_LINE_SOURCE: modelo de la linea origen
MODEL_LINE_FINAL: modelo de la linea final
url_reverse: url del destino
related_line: campo del modelo linea final en el... | f7625:c11:m7 |
@staticmethod<EOL><INDENT>def create_albaran_automatic(pk, list_lines):<DEDENT> | line_bd = SalesLineAlbaran.objects.filter(line_order__pk__in=list_lines).values_list('<STR_LIT>')<EOL>if line_bd.count() == <NUM_LIT:0> or len(list_lines) != len(line_bd[<NUM_LIT:0>]):<EOL><INDENT>if line_bd.count() != <NUM_LIT:0>:<EOL><INDENT>for x in line_bd[<NUM_LIT:0>]:<EOL><INDENT>list_lines.pop(list_lines.index(x... | creamos de forma automatica el albaran | f7625:c11:m10 |
@staticmethod<EOL><INDENT>def create_ticket_from_albaran(pk, list_lines):<DEDENT> | context = {}<EOL>if list_lines:<EOL><INDENT>new_list_lines = [x[<NUM_LIT:0>] for x in SalesLineAlbaran.objects.values_list('<STR_LIT>').filter(<EOL>pk__in=[int(x) for x in list_lines]<EOL>).exclude(invoiced=True)]<EOL>if new_list_lines:<EOL><INDENT>lo = SalesLineOrder.objects.values_list('<STR_LIT>').filter(pk__in=new_... | la pk y list_lines son de albaranes, necesitamos la info de las lineas de pedidos | f7625:c11:m15 |
@staticmethod<EOL><INDENT>def create_invoice_from_albaran(pk, list_lines):<DEDENT> | context = {}<EOL>if list_lines:<EOL><INDENT>new_list_lines = [x[<NUM_LIT:0>] for x in SalesLineAlbaran.objects.values_list('<STR_LIT>').filter(<EOL>pk__in=[int(x) for x in list_lines]<EOL>).exclude(invoiced=True)]<EOL>if new_list_lines:<EOL><INDENT>lo = SalesLineOrder.objects.values_list('<STR_LIT>').filter(pk__in=new_... | la pk y list_lines son de albaranes, necesitamos la info de las lineas de pedidos | f7625:c11:m16 |
@staticmethod<EOL><INDENT>def create_invoice_from_ticket(pk, list_lines):<DEDENT> | context = {}<EOL>if list_lines:<EOL><INDENT>new_list_lines = [x[<NUM_LIT:0>] for x in SalesLineTicket.objects.values_list('<STR_LIT>').filter(pk__in=[int(x) for x in list_lines])]<EOL>if new_list_lines:<EOL><INDENT>lo = SalesLineOrder.objects.values_list('<STR_LIT>').filter(pk__in=new_list_lines)[:<NUM_LIT:1>]<EOL>if l... | la pk y list_lines son de ticket, necesitamos la info de las lineas de pedidos | f7625:c11:m17 |
def set_options(self, options): | with transaction.atomic():<EOL><INDENT>for option in options:<EOL><INDENT>opt = self.line_basket_option_sales.filter(<EOL>product_option=option['<STR_LIT>']<EOL>).first()<EOL>if opt: <EOL><INDENT>change = False<EOL>if opt.quantity != option['<STR_LIT>']:<EOL><INDENT>opt.quantity = option['<STR_LIT>']<EOL>change = True... | options = [{
'product_option': instance of ProductFinalOption,
'product_final': instance of ProductFinal,
'quantity': Float
}, ] | f7625:c15:m4 |
def ensure_path_exists(dir_path): | if not os.path.exists(dir_path):<EOL><INDENT>os.makedirs(dir_path)<EOL>return True<EOL><DEDENT>return False<EOL> | Make sure that a path exists | f7641:m2 |
def ensure_path_exists(dir_path): | if not os.path.exists(dir_path):<EOL><INDENT>os.makedirs(dir_path)<EOL>return True<EOL><DEDENT>return False<EOL> | Make sure that a path exists | f7646:m3 |
def p_jsonpath_binop(self, p): | op = p[<NUM_LIT:2>]<EOL>if op == '<STR_LIT:.>':<EOL><INDENT>p[<NUM_LIT:0>] = Child(p[<NUM_LIT:1>], p[<NUM_LIT:3>])<EOL><DEDENT>elif op == '<STR_LIT:..>':<EOL><INDENT>p[<NUM_LIT:0>] = Descendants(p[<NUM_LIT:1>], p[<NUM_LIT:3>])<EOL><DEDENT>elif op == '<STR_LIT>':<EOL><INDENT>p[<NUM_LIT:0>] = Where(p[<NUM_LIT:1>], p[<NUM... | jsonpath : jsonpath '.' jsonpath
| jsonpath DOUBLEDOT jsonpath
| jsonpath WHERE jsonpath
| jsonpath '|' jsonpath
| jsonpath '&' jsonpath | f7655:c0:m4 |
def p_jsonpath_fields(self, p): | p[<NUM_LIT:0>] = Fields(*p[<NUM_LIT:1>])<EOL> | jsonpath : fields_or_any | f7655:c0:m5 |
def p_jsonpath_named_operator(self, p): | if p[<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>p[<NUM_LIT:0>] = This()<EOL><DEDENT>elif p[<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>p[<NUM_LIT:0>] = Parent()<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>' % (p[<NUM_LIT:1>], p.lineno(<NUM_LIT:1>), p.lexpos(<NUM_LIT:1>)))<EOL><DEDENT> | jsonpath : NAMED_OPERATOR | f7655:c0:m6 |
def p_jsonpath_root(self, p): | p[<NUM_LIT:0>] = Root()<EOL> | jsonpath : '$ | f7655:c0:m7 |
def p_jsonpath_idx(self, p): | p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL> | jsonpath : '[' idx '] | f7655:c0:m8 |
def p_jsonpath_slice(self, p): | p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL> | jsonpath : '[' slice '] | f7655:c0:m9 |
def p_jsonpath_fieldbrackets(self, p): | p[<NUM_LIT:0>] = Fields(*p[<NUM_LIT:2>])<EOL> | jsonpath : '[' fields '] | f7655:c0:m10 |
def p_jsonpath_child_fieldbrackets(self, p): | p[<NUM_LIT:0>] = Child(p[<NUM_LIT:1>], Fields(*p[<NUM_LIT:3>]))<EOL> | jsonpath : jsonpath '[' fields '] | f7655:c0:m11 |
def p_jsonpath_child_idxbrackets(self, p): | p[<NUM_LIT:0>] = Child(p[<NUM_LIT:1>], p[<NUM_LIT:3>])<EOL> | jsonpath : jsonpath '[' idx '] | f7655:c0:m12 |
def p_jsonpath_child_slicebrackets(self, p): | p[<NUM_LIT:0>] = Child(p[<NUM_LIT:1>], p[<NUM_LIT:3>])<EOL> | jsonpath : jsonpath '[' slice '] | f7655:c0:m13 |
def p_jsonpath_parens(self, p): | p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL> | jsonpath : '(' jsonpath ') | f7655:c0:m14 |
def p_fields_or_any(self, p): | if p[<NUM_LIT:1>] == '<STR_LIT:*>':<EOL><INDENT>p[<NUM_LIT:0>] = ['<STR_LIT:*>']<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL><DEDENT> | fields_or_any : fields
| '* | f7655:c0:m15 |
def p_fields_id(self, p): | p[<NUM_LIT:0>] = [p[<NUM_LIT:1>]]<EOL> | fields : ID | f7655:c0:m16 |
def p_fields_comma(self, p): | p[<NUM_LIT:0>] = p[<NUM_LIT:1>] + p[<NUM_LIT:3>]<EOL> | fields : fields ',' fields | f7655:c0:m17 |
def p_idx(self, p): | p[<NUM_LIT:0>] = Index(p[<NUM_LIT:1>])<EOL> | idx : NUMBER | f7655:c0:m18 |
def p_slice_any(self, p): | p[<NUM_LIT:0>] = Slice()<EOL> | slice : '* | f7655:c0:m19 |
def p_slice(self, p): | p[<NUM_LIT:0>] = Slice(start=p[<NUM_LIT:1>], end=p[<NUM_LIT:3>])<EOL> | slice : maybe_int ':' maybe_int | f7655:c0:m20 |
def p_maybe_int(self, p): | p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL> | maybe_int : NUMBER
| empty | f7655:c0:m21 |
def p_empty(self, p): | p[<NUM_LIT:0>] = None<EOL> | empty : | f7655:c0:m22 |
def tokenize(self, string): | new_lexer = ply.lex.lex(module=self, debug=self.debug, errorlog=logger)<EOL>new_lexer.latest_newline = <NUM_LIT:0><EOL>new_lexer.string_value = None<EOL>new_lexer.input(string)<EOL>while True:<EOL><INDENT>t = new_lexer.token()<EOL>if t is None: break<EOL>t.col = t.lexpos - new_lexer.latest_newline<EOL>yield t<EOL><DEDE... | Maps a string to an iterator over tokens. In other words: [char] -> [token] | f7656:c1:m1 |
def t_ID(self, t): | t.type = self.reserved_words.get(t.value, '<STR_LIT>')<EOL>return t<EOL> | r'[a-zA-Z_@][a-zA-Z0-9_@\-]* | f7656:c1:m2 |
def t_NUMBER(self, t): | t.value = int(t.value)<EOL>return t<EOL> | r'-?\d+ | f7656:c1:m3 |
def t_singlequote(self, t): | t.lexer.string_start = t.lexer.lexpos<EOL>t.lexer.string_value = '<STR_LIT>'<EOL>t.lexer.push_state('<STR_LIT>')<EOL> | r | f7656:c1:m4 |
def t_singlequote_content(self, t): | t.lexer.string_value += t.value<EOL> | r"[^'\\]+ | f7656:c1:m5 |
def t_singlequote_escape(self, t): | t.lexer.string_value += t.value[<NUM_LIT:1>]<EOL> | r'\\. | f7656:c1:m6 |
def t_singlequote_end(self, t): | t.value = t.lexer.string_value<EOL>t.type = '<STR_LIT>'<EOL>t.lexer.string_value = None<EOL>t.lexer.pop_state()<EOL>return t<EOL> | r | f7656:c1:m7 |
def t_doublequote(self, t): | t.lexer.string_start = t.lexer.lexpos<EOL>t.lexer.string_value = '<STR_LIT>'<EOL>t.lexer.push_state('<STR_LIT>')<EOL> | r | f7656:c1:m9 |
def t_doublequote_content(self, t): | t.lexer.string_value += t.value<EOL> | r'[^"\\]+ | f7656:c1:m10 |
def t_doublequote_escape(self, t): | t.lexer.string_value += t.value[<NUM_LIT:1>]<EOL> | r'\\. | f7656:c1:m11 |
def t_doublequote_end(self, t): | t.value = t.lexer.string_value<EOL>t.type = '<STR_LIT>'<EOL>t.lexer.string_value = None<EOL>t.lexer.pop_state()<EOL>return t<EOL> | r | f7656:c1:m12 |
def t_backquote(self, t): | t.lexer.string_start = t.lexer.lexpos<EOL>t.lexer.string_value = '<STR_LIT>'<EOL>t.lexer.push_state('<STR_LIT>')<EOL> | r'` | f7656:c1:m14 |
def t_backquote_escape(self, t): | t.lexer.string_value += t.value[<NUM_LIT:1>]<EOL> | r'\\. | f7656:c1:m15 |
def t_backquote_content(self, t): | t.lexer.string_value += t.value<EOL> | r"[^`\\]+ | f7656:c1:m16 |
def t_backquote_end(self, t): | t.value = t.lexer.string_value<EOL>t.type = '<STR_LIT>'<EOL>t.lexer.string_value = None<EOL>t.lexer.pop_state()<EOL>return t<EOL> | r'` | f7656:c1:m17 |
def t_newline(self, t): | t.lexer.lineno += <NUM_LIT:1><EOL>t.lexer.latest_newline = t.lexpos<EOL> | r'\n | f7656:c1:m19 |
def find(self, data): | raise NotImplementedError()<EOL> | All `JSONPath` types support `find()`, which returns an iterable of `DatumInContext`s.
They keep track of the path followed to the current location, so if the calling code
has some opinion about that, it can be passed in here as a starting point. | f7659:c0:m0 |
def update(self, data, val): | raise NotImplementedError()<EOL> | Returns `data` with the specified path replaced by `val`. Only updates
if the specified path exists. | f7659:c0:m1 |
def child(self, child): | if isinstance(self, This) or isinstance(self, Root):<EOL><INDENT>return child<EOL><DEDENT>elif isinstance(child, This):<EOL><INDENT>return self<EOL><DEDENT>elif isinstance(child, Root):<EOL><INDENT>return child<EOL><DEDENT>else:<EOL><INDENT>return Child(self, child)<EOL><DEDENT> | Equivalent to Child(self, next) but with some canonicalization | f7659:c0:m2 |
@property<EOL><INDENT>def id_pseudopath(self):<DEDENT> | try:<EOL><INDENT>pseudopath = Fields(str(self.value[auto_id_field]))<EOL><DEDENT>except (TypeError, AttributeError, KeyError): <EOL><INDENT>pseudopath = self.path<EOL><DEDENT>if self.context:<EOL><INDENT>return self.context.id_pseudopath.child(pseudopath)<EOL><DEDENT>else:<EOL><INDENT>return pseudopath<EOL><DEDENT> | Looks like a path, but with ids stuck in when available | f7659:c1:m4 |
def __init__(self, datum, id_field=None): | self.datum = datum<EOL>self.id_field = id_field or auto_id_field<EOL> | Invariant is that datum.path is the path from context to datum. The auto id
will either be the id in the datum (if present) or the id of the context
followed by the path to the datum.
The path to this datum is always the path to the context, the path to the
datum, and then the auto id field. | f7659:c2:m0 |
def find(self, datum): | return [submatch<EOL>for subdata in self.left.find(datum)<EOL>if not isinstance(subdata, AutoIdForDatum)<EOL>for submatch in self.right.find(subdata)]<EOL> | Extra special case: auto ids do not have children,
so cut it off right now rather than auto id the auto id | f7659:c5:m1 |
def setUp(self): | <EOL>num_replicates = <NUM_LIT:100><EOL>num_params = <NUM_LIT:5><EOL>self.bootstrap_replicates =(np.arange(<NUM_LIT:1>, <NUM_LIT:1> + num_replicates)[:, None] *<EOL>np.arange(<NUM_LIT:1>, <NUM_LIT:1> + num_params)[None, :])<EOL>self.mle_params = self.bootstrap_replicates[<NUM_LIT:50>, :]<EOL>array_container = []<EOL>fo... | Note that the spatial test data used in many of these tests comes from
Efron, Bradley, and Robert J. Tibshirani. An Introduction to the
Bootstrap. CRC press, 1994. Chapter 14. | f7662:c0:m0 |
def setUp(self): | self.asym_model = self.make_asym_model()<EOL>self.uneven_model, self.scobit_model =self.make_uneven_and_scobit_models()<EOL>self.clog_model, self.mnl_model = self.make_clog_and_mnl_models()<EOL>self.mixed_model = self.make_mixed_model()<EOL>self.nested_model = self.make_nested_model()<EOL>return None<EOL> | Create the real model objects. | f7664:c0:m5 |
def setUp(self): | <EOL>self.fake_draws = mlc.get_normal_draws(<NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:1>, seed=<NUM_LIT:1>)[<NUM_LIT:0>]<EOL>self.fake_betas = np.array([<NUM_LIT>, -<NUM_LIT>, <NUM_LIT>])<EOL>self.fake_std = <NUM_LIT:1><EOL>self.fake_betas_ext = np.concatenate((self.fake_betas,<EOL>np.array([self.fake_std])),<EOL>axis=<NUM_LI... | Set up a mixed logit model | f7668:c0:m0 |
def setUp(self): | <EOL>self.fake_betas = np.array([-<NUM_LIT>])<EOL>self.fake_intercepts = np.array([<NUM_LIT:1>, <NUM_LIT:0.5>])<EOL>self.fake_intercept_names = ["<STR_LIT>", "<STR_LIT>"]<EOL>self.fake_intercept_ref_pos = <NUM_LIT:2><EOL>self.fake_shapes = np.array([-<NUM_LIT:1>, <NUM_LIT:1>])<EOL>self.fake_shape_names = ["<STR_LIT>", ... | Create a fake dataset and specification from which we can initialize a
choice model. | f7669:c0:m0 |
def setUp(self): | <EOL>self.fake_betas = np.array([-<NUM_LIT>])<EOL>self.fake_intercepts = np.array([<NUM_LIT:1>, <NUM_LIT:0.5>])<EOL>self.fake_intercept_names = ["<STR_LIT>", "<STR_LIT>"]<EOL>self.fake_intercept_ref_pos = <NUM_LIT:2><EOL>self.fake_shapes = np.array([-<NUM_LIT:1>, <NUM_LIT:1>])<EOL>self.fake_shape_names = ["<STR_LIT>", ... | Perform additional setup materials needed to test the store estimation
results functions. | f7669:c4:m0 |
def temp_utility_transform(sys_utility_array, *args, **kwargs): | <EOL>if len(sys_utility_array.shape) == <NUM_LIT:1>:<EOL><INDENT>systematic_utilities = sys_utility_array[:, np.newaxis]<EOL><DEDENT>else:<EOL><INDENT>systematic_utilities = sys_utility_array<EOL><DEDENT>return systematic_utilities<EOL> | Parameters
----------
sys_utility_array : numpy array.
Should have 1D or 2D. Should have been created by the dot product of a
design matrix and an array of index coefficients.
Returns
-------
2D numpy array.
The returned array will contain a representation of the
`sys_utility_array`. If `sys_utility_a... | f7672:m0 |
def setUp(self): | <EOL>self.fake_betas = np.array([-<NUM_LIT>])<EOL>self.fake_intercepts = np.array([<NUM_LIT:1>, <NUM_LIT:0.5>])<EOL>self.fake_intercept_names = ["<STR_LIT>", "<STR_LIT>"]<EOL>self.fake_intercept_ref_pos = <NUM_LIT:2><EOL>self.fake_shapes = np.array([-<NUM_LIT:1>, <NUM_LIT:1>])<EOL>self.fake_shape_names = ["<STR_LIT>", ... | Create a fake dataset and specification from which we can initialize a
choice model. | f7677:c0:m0 |
def setUp(self): | <EOL>self.fake_betas = np.array([-<NUM_LIT>])<EOL>self.fake_intercepts = np.array([<NUM_LIT:1>, <NUM_LIT:0.5>])<EOL>self.fake_intercept_names = ["<STR_LIT>", "<STR_LIT>"]<EOL>self.fake_intercept_ref_pos = <NUM_LIT:2><EOL>self.fake_shapes = np.array([-<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>])<EOL>self.fake_shape_names = [... | Create the input data needed to test the choice model constructor. | f7678:c0:m0 |
def setUp(self): | self.mnl_model = self.make_mnl_model()<EOL>self.asym_model = self.make_asym_model()<EOL>self.mixed_model = self.make_mixed_model()<EOL>self.nested_model = self.make_nested_model()<EOL>return None<EOL> | Create the real model objects. | f7680:c2:m4 |
def calc_theta(self, weight): | a_mean = weight.dot(self.test_data)<EOL>differences = (self.test_data - a_mean)<EOL>squared_diffs = differences**<NUM_LIT:2><EOL>return weight.dot(squared_diffs)<EOL> | See Equation 14.22 of Efron and Tibshirani (1994). | f7681:c1:m0 |
def split_param_vec(param_vec, rows_to_alts, design, return_all_types=False): | <EOL>num_index_coefs = design.shape[<NUM_LIT:1>]<EOL>betas = param_vec[-<NUM_LIT:1> * num_index_coefs:]<EOL>remaining_idx = param_vec.shape[<NUM_LIT:0>] - num_index_coefs<EOL>if remaining_idx > <NUM_LIT:0>:<EOL><INDENT>intercepts = param_vec[:remaining_idx]<EOL><DEDENT>else:<EOL><INDENT>intercepts = None<EOL><DEDENT>if... | Parameters
----------
param_vec : 1D ndarray.
Elements should all be ints, floats, or longs. Should have as many
elements as there are parameters being estimated.
rows_to_alts : 2D scipy sparse matrix.
There should be one row per observation per available alternative and
one column per possible alternat... | f7683:m0 |
def _cloglog_utility_transform(systematic_utilities,<EOL>alt_IDs,<EOL>rows_to_alts,<EOL>shape_params,<EOL>intercept_params,<EOL>intercept_ref_pos=None,<EOL>*args, **kwargs): | <EOL>exp_v = np.exp(systematic_utilities)<EOL>exp_exp_v = np.exp(exp_v)<EOL>transformations = np.log(exp_exp_v - <NUM_LIT:1>)<EOL>transformations[np.isneginf(transformations)] = -<NUM_LIT:1> * max_comp_value<EOL>too_big_idx = np.where(systematic_utilities >= <NUM_LIT>)<EOL>transformations[too_big_idx] = np.exp(systemat... | Parameters
----------
systematic_utilities : 1D ndarray.
All elements should be ints, floats, or longs. Should contain the
systematic utilities of each observation per available alternative.
Note that this vector is formed by the dot product of the design matrix
with the vector of utility coefficients.
... | f7683:m1 |
def _cloglog_transform_deriv_v(systematic_utilities,<EOL>alt_IDs,<EOL>rows_to_alts,<EOL>shape_params,<EOL>output_array=None,<EOL>*args, **kwargs): | exp_neg_v = np.exp(-<NUM_LIT:1> * systematic_utilities)<EOL>exp_v = np.exp(systematic_utilities)<EOL>denom_part_1 = <NUM_LIT:1> - np.exp(-<NUM_LIT:1> * exp_v)<EOL>exp_neg_v[np.isposinf(exp_neg_v)] = max_comp_value<EOL>exp_neg_v[np.where(exp_neg_v == <NUM_LIT:0>)] = min_comp_value<EOL>derivs = <NUM_LIT:1.0> / (denom_par... | Parameters
----------
systematic_utilities : 1D ndarray.
All elements should be ints, floats, or longs. Should contain the
systematic utilities of each observation per available alternative.
Note that this vector is formed by the dot product of the design matrix
with the vector of utility coefficients.
... | f7683:m2 |
def _cloglog_transform_deriv_c(*args, **kwargs): | return None<EOL> | Returns
-------
None. This is a place holder function since the Clog-log model has no shape
parameters. | f7683:m3 |
def _cloglog_transform_deriv_alpha(systematic_utilities,<EOL>alt_IDs,<EOL>rows_to_alts,<EOL>intercept_params,<EOL>output_array=None,<EOL>*args, **kwargs): | return output_array<EOL> | Parameters
----------
systematic_utilities : 1D ndarray.
All elements should be ints, floats, or longs. Should contain the
systematic utilities of each observation per available alternative.
Note that this vector is formed by the dot product of the design matrix
with the vector of utility coefficients.
... | f7683:m4 |
def create_calc_dh_dv(estimator): | dh_dv = diags(np.ones(estimator.design.shape[<NUM_LIT:0>]), <NUM_LIT:0>, format='<STR_LIT>')<EOL>calc_dh_dv = partial(_cloglog_transform_deriv_v, output_array=dh_dv)<EOL>return calc_dh_dv<EOL> | Return the function that can be used in the various gradient and hessian
calculations to calculate the derivative of the transformation with respect
to the index.
Parameters
----------
estimator : an instance of the estimation.LogitTypeEstimator class.
Should contain a `design` attribute that is a 2D ndarray repre... | f7683:m5 |
def create_calc_dh_d_alpha(estimator): | if estimator.intercept_ref_pos is not None:<EOL><INDENT>needed_idxs = range(estimator.rows_to_alts.shape[<NUM_LIT:1>])<EOL>needed_idxs.remove(estimator.intercept_ref_pos)<EOL>dh_d_alpha = (estimator.rows_to_alts<EOL>.copy()<EOL>.transpose()[needed_idxs, :]<EOL>.transpose())<EOL><DEDENT>else:<EOL><INDENT>dh_d_alpha = No... | Return the function that can be used in the various gradient and hessian
calculations to calculate the derivative of the transformation with respect
to the outside intercept parameters.
Parameters
----------
estimator : an instance of the estimation.LogitTypeEstimator class.
Should contain a `rows_to_alts` attribu... | f7683:m6 |
def check_length_of_initial_values(self, init_values): | <EOL>num_alts = self.rows_to_alts.shape[<NUM_LIT:1>]<EOL>num_index_coefs = self.design.shape[<NUM_LIT:1>]<EOL>if self.intercept_ref_pos is not None:<EOL><INDENT>assumed_param_dimensions = num_index_coefs + num_alts - <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>assumed_param_dimensions = num_index_coefs<EOL><DEDENT>if ini... | Ensures that `init_values` is of the correct length. Raises a helpful
ValueError if otherwise.
Parameters
----------
init_values : 1D ndarray.
The initial values to start the optimization process with. There
should be one value for each index coefficient, outside intercept
parameter, and shape parameter be... | f7683:c0:m1 |
def fit_mle(self,<EOL>init_vals,<EOL>init_intercepts=None,<EOL>init_coefs=None,<EOL>print_res=True,<EOL>method="<STR_LIT>",<EOL>loss_tol=<NUM_LIT>,<EOL>gradient_tol=<NUM_LIT>,<EOL>maxiter=<NUM_LIT:1000>,<EOL>ridge=None,<EOL>constrained_pos=None,<EOL>just_point=False,<EOL>**kwargs): | <EOL>if "<STR_LIT>" in kwargs:<EOL><INDENT>msg = "<STR_LIT>"<EOL>msg_2 = "<STR_LIT>"<EOL>msg_3 = "<STR_LIT>"<EOL>raise ValueError(msg + msg_2 + msg_3)<EOL><DEDENT>if ridge is not None:<EOL><INDENT>warnings.warn(_ridge_warning_msg)<EOL><DEDENT>self.optimization_method = method<EOL>self.ridge_param = ridge<EOL>mapping_re... | Parameters
----------
init_vals : 1D ndarray.
The initial values to start the optimization process with. There
should be one value for each index coefficient and shape
parameter being estimated. Shape parameters should come before
intercept parameters, which should come before index coefficients.
On... | f7683:c1:m1 |
def calc_probabilities(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>utility_transform,<EOL>intercept_params=None,<EOL>shape_params=None,<EOL>chosen_row_to_obs=None,<EOL>return_long_probs=False): | <EOL>if (len(beta.shape) >= <NUM_LIT:2>) and (len(design.shape) >= <NUM_LIT:3>):<EOL><INDENT>msg_1 = "<STR_LIT>"<EOL>msg_2 = "<STR_LIT>"<EOL>raise ValueError(msg_1 + msg_2)<EOL><DEDENT>if chosen_row_to_obs is None and return_long_probs is False:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg)<EOL><DEDENT>sys_ut... | Parameters
----------
beta : 1D or 2D ndarray.
All elements should by ints, floats, or longs. If 1D, should have 1
element for each utility coefficient being estimated (i.e.
num_features). If 2D, should have 1 column for each set of coefficients
being used to predict the probabilities of each alternativ... | f7684:m0 |
def calc_log_likelihood(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>choice_vector,<EOL>utility_transform,<EOL>intercept_params=None,<EOL>shape_params=None,<EOL>ridge=None,<EOL>weights=None): | <EOL>long_probs = calc_probabilities(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>utility_transform,<EOL>intercept_params=intercept_params,<EOL>shape_params=shape_params,<EOL>return_long_probs=True)<EOL>if weights is None:<EOL><INDENT>weights = <NUM_LIT:1><EOL><DEDENT>log_likelihood = choice_ve... | Parameters
----------
beta : 1D ndarray.
All elements should by ints, floats, or longs. Should have 1 element
for each utility coefficient being estimated (i.e. num_features).
design : 2D ndarray.
There should be one row per observation per available alternative.
There should be one column per utility c... | f7684:m1 |
def calc_gradient(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>choice_vector,<EOL>utility_transform,<EOL>transform_first_deriv_c,<EOL>transform_first_deriv_v,<EOL>transform_deriv_alpha,<EOL>intercept_params,<EOL>shape_params,<EOL>ridge,<EOL>weights): | <EOL>sys_utilities = design.dot(beta)<EOL>long_probs = calc_probabilities(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>utility_transform,<EOL>intercept_params=intercept_params,<EOL>shape_params=shape_params,<EOL>return_long_probs=True)<EOL>if weights is None:<EOL><INDENT>weights = <NUM_LIT:1><E... | Parameters
----------
beta : 1D ndarray.
All elements should by ints, floats, or longs. Should have 1 element
for each utility coefficient being estimated (i.e. num_features).
design : 2D ndarray.
Tjere should be one row per observation per available alternative.
There should be one column per utility c... | f7684:m2 |
def create_matrix_block_indices(row_to_obs): | <EOL>output_indices = []<EOL>num_obs = row_to_obs.shape[<NUM_LIT:1>]<EOL>row_indices, col_indices, values = scipy.sparse.find(row_to_obs)<EOL>for col in xrange(num_obs):<EOL><INDENT>output_indices.append(row_indices[np.where(col_indices == col)])<EOL><DEDENT>return output_indices<EOL> | Parameters
----------
row_to_obs: 2D ndarray.
There should be one row per observation per available alternative and
one column per observation. This matrix maps the rows of the design
matrix to the unique observations (on the columns).
Returns
-------
output_indices : list of arrays.
There will be one ... | f7684:m3 |
def robust_outer_product(vec_1, vec_2): | mantissa_1, exponents_1 = np.frexp(vec_1)<EOL>mantissa_2, exponents_2 = np.frexp(vec_2)<EOL>new_mantissas = mantissa_1[None, :] * mantissa_2[:, None]<EOL>new_exponents = exponents_1[None, :] + exponents_2[:, None]<EOL>return new_mantissas * np.exp2(new_exponents)<EOL> | Calculates a 'robust' outer product of two vectors that may or may not
contain very small values.
Parameters
----------
vec_1 : 1D ndarray
vec_2 : 1D ndarray
Returns
-------
outer_prod : 2D ndarray. The outer product of vec_1 and vec_2 | f7684:m4 |
def create_matrix_blocks(long_probs, matrix_block_indices): | <EOL>output_matrices = []<EOL>for indices in matrix_block_indices:<EOL><INDENT>current_probs = long_probs[indices]<EOL>probability_outer_product = robust_outer_product(current_probs,<EOL>current_probs)<EOL>dP_i_dh_i = np.diag(current_probs) - probability_outer_product<EOL>diag_idx = np.diag_indices_from(dP_i_dh_i)<EOL>... | Parameters
----------
long_probs : 1D ndarray.
There should be one row per observation per available alternative. The
elements of the array will indicate the probability of the alternative
being the outcome associated with the corresponding observation.
matrix_block_indices : list of arrays.
There will ... | f7684:m5 |
def calc_hessian(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>utility_transform,<EOL>transform_first_deriv_c,<EOL>transform_first_deriv_v,<EOL>transform_deriv_alpha,<EOL>block_matrix_idxs,<EOL>intercept_params,<EOL>shape_params,<EOL>ridge,<EOL>weights): | <EOL>sys_utilities = design.dot(beta)<EOL>long_probs = calc_probabilities(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>utility_transform,<EOL>intercept_params=intercept_params,<EOL>shape_params=shape_params,<EOL>return_long_probs=True)<EOL>if weights is None:<EOL><INDENT>weights = np.ones(desig... | Parameters
----------
beta : 1D ndarray.
All elements should by ints, floats, or longs. Should have 1 element
for each utility coefficient being estimated (i.e. num_features).
design : 2D ndarray.
There should be one row per observation per available alternative.
There should be one column per utility c... | f7684:m6 |
def calc_fisher_info_matrix(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>choice_vector,<EOL>utility_transform,<EOL>transform_first_deriv_c,<EOL>transform_first_deriv_v,<EOL>transform_deriv_alpha,<EOL>intercept_params,<EOL>shape_params,<EOL>ridge,<EOL>weights): | <EOL>sys_utilities = design.dot(beta)<EOL>long_probs = calc_probabilities(beta,<EOL>design,<EOL>alt_IDs,<EOL>rows_to_obs,<EOL>rows_to_alts,<EOL>utility_transform,<EOL>intercept_params=intercept_params,<EOL>shape_params=shape_params,<EOL>return_long_probs=True)<EOL>if weights is None:<EOL><INDENT>weights = np.ones(desig... | Parameters
----------
beta : 1D ndarray.
All elements should by ints, floats, or longs. Should have 1 element
for each utility coefficient being estimated (i.e. num_features).
design : 2D ndarray.
There should be one row per observation per available alternative.
There should be one column per utility c... | f7684:m7 |
def calc_asymptotic_covariance(hessian, fisher_info_matrix): | <EOL>hess_inv = scipy.linalg.inv(hessian)<EOL>return np.dot(hess_inv, np.dot(fisher_info_matrix, hess_inv))<EOL> | Parameters
----------
hessian : 2D ndarray.
It should have shape `(num_vars, num_vars)`. It is the matrix of second
derivatives of the total loss across the dataset, with respect to each
pair of coefficients being estimated.
fisher_info_matrix : 2D ndarray.
It should have a shape of `(num_vars, num_vars... | f7684:m8 |
def split_param_vec(beta,<EOL>rows_to_alts=None,<EOL>design=None,<EOL>return_all_types=False,<EOL>*args, **kwargs): | if return_all_types:<EOL><INDENT>return None, None, None, beta<EOL><DEDENT>else:<EOL><INDENT>return None, None, beta<EOL><DEDENT> | Parameters
----------
beta : 1D ndarray.
All elements should by ints, floats, or longs. Should have 1 element
for each utility coefficient being estimated (i.e. num_features).
rows_to_alts : None,
Not actually used. Included merely for consistency with other models.
design : None.
Not actually used. Inc... | f7685:m0 |
def _mnl_utility_transform(systematic_utilities, *args, **kwargs): | <EOL>if len(systematic_utilities.shape) == <NUM_LIT:1>:<EOL><INDENT>systematic_utilities = systematic_utilities[:, np.newaxis]<EOL><DEDENT>return systematic_utilities<EOL> | Parameters
----------
systematic_utilities : 1D ndarray.
Should contain the systematic utilities for each each available
alternative for each observation.
Returns
-------
`systematic_utilities[:, None]` | f7685:m1 |
def _mnl_transform_deriv_c(*args, **kwargs): | <EOL>return None<EOL> | Returns None.
This is a place holder function since the MNL model has no shape
parameters. | f7685:m2 |
def _mnl_transform_deriv_alpha(*args, **kwargs): | <EOL>return None<EOL> | Returns None.
This is a place holder function since the MNL model has no intercept
parameters outside of the index. | f7685:m3 |
def check_length_of_initial_values(self, init_values): | <EOL>num_index_coefs = self.design.shape[<NUM_LIT:1>]<EOL>if init_values.shape[<NUM_LIT:0>] != num_index_coefs:<EOL><INDENT>msg_1 = "<STR_LIT>"<EOL>msg_2 = "<STR_LIT>"<EOL>msg_3 = "<STR_LIT>"<EOL>raise ValueError(msg_1 +<EOL>msg_2.format(num_index_coefs) +<EOL>msg_3.format(init_values.shape[<NUM_LIT:0>]))<EOL><DEDENT>r... | Ensures that `init_values` is of the correct length. Raises a helpful
ValueError if otherwise.
Parameters
----------
init_values : 1D ndarray.
The initial values to start the optimization process with. There
should be one value for each index coefficient, outside intercept
parameter, and shape parameter be... | f7685:c0:m1 |
def fit_mle(self,<EOL>init_vals,<EOL>print_res=True,<EOL>method="<STR_LIT>",<EOL>loss_tol=<NUM_LIT>,<EOL>gradient_tol=<NUM_LIT>,<EOL>maxiter=<NUM_LIT:1000>,<EOL>ridge=None,<EOL>constrained_pos=None,<EOL>just_point=False,<EOL>**kwargs): | <EOL>kwargs_to_be_ignored = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]<EOL>if any([x in kwargs for x in kwargs_to_be_ignored]):<EOL><INDENT>msg = "<STR_LIT>"<EOL>msg_2 = "<STR_LIT>"<EOL>raise ValueError(msg.format(kwargs_to_be_ignored) + msg_2)<EOL><DEDENT>if ridge is not None:<EOL><INDENT>warnings.warn(_ridge_warning_msg... | Parameters
----------
init_vals : 1D ndarray.
The initial values to start the optimization process with. There
should be one value for each utility coefficient being estimated.
print_res : bool, optional.
Determines whether the timing and initial and final log likelihood
results will be printed as they ... | f7685:c1:m1 |
def is_kernel(): | if any([x in sys.modules for x in ['<STR_LIT>', '<STR_LIT>']]):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | Determines whether or not one's code is executed inside of an ipython
notebook environment. | f7686:m0 |
def get_param_names(model_obj): | <EOL>all_names = deepcopy(model_obj.ind_var_names)<EOL>if model_obj.intercept_names is not None:<EOL><INDENT>all_names = model_obj.intercept_names + all_names<EOL><DEDENT>if model_obj.shape_names is not None:<EOL><INDENT>all_names = model_obj.shape_names + all_names<EOL><DEDENT>if model_obj.nest_names is not None:<EOL>... | Extracts all the names to be displayed for the estimated parameters.
Parameters
----------
model_obj : an instance of an MNDC object.
Should have the following attributes:
`['ind_var_names', 'intercept_names', 'shape_names', 'nest_names']`.
Returns
-------
all_names : list of strings.
There will be one el... | f7686:m1 |
def get_param_list_for_prediction(model_obj, replicates): | <EOL>ensure_samples_is_ndim_ndarray(replicates, ndim=<NUM_LIT:2>, name='<STR_LIT>')<EOL>num_idx_coefs = len(model_obj.ind_var_names)<EOL>intercept_names = model_obj.intercept_names<EOL>num_outside_intercepts =<NUM_LIT:0> if intercept_names is None else len(intercept_names)<EOL>shape_names = model_obj.shape_names<EOL>nu... | Create the `param_list` argument for use with `model_obj.predict`.
Parameters
----------
model_obj : an instance of an MNDC object.
Should have the following attributes:
`['ind_var_names', 'intercept_names', 'shape_names', 'nest_names']`.
This model should have already undergone a complete estimation proce... | f7686:m2 |
def ensure_replicates_kwarg_validity(replicate_kwarg): | if replicate_kwarg not in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg)<EOL><DEDENT>return None<EOL> | Ensures `replicate_kwarg` is either 'bootstrap' or 'jackknife'. Raises a
helpful ValueError otherwise. | f7686:m3 |
def generate_bootstrap_replicates(self,<EOL>num_samples,<EOL>mnl_obj=None,<EOL>mnl_init_vals=None,<EOL>mnl_fit_kwargs=None,<EOL>extract_init_vals=None,<EOL>print_res=False,<EOL>method="<STR_LIT>",<EOL>loss_tol=<NUM_LIT>,<EOL>gradient_tol=<NUM_LIT>,<EOL>maxiter=<NUM_LIT:1000>,<EOL>ridge=None,<EOL>constrained_pos=None,<E... | print("<STR_LIT>")<EOL>print(time.strftime("<STR_LIT>"))<EOL>sys.stdout.flush()<EOL>obs_id_array = self.model_obj.data[self.model_obj.obs_id_col].values<EOL>alt_id_array = self.model_obj.alt_IDs<EOL>choice_array = self.model_obj.choices<EOL>num_params = self.mle_params.shape[<NUM_LIT:0>]<EOL>obs_id_per_sample =bs.creat... | Generates the bootstrap replicates for one's given model and dataset.
Parameters
----------
num_samples : positive int.
Specifies the number of bootstrap samples that are to be drawn.
mnl_obj : an instance of pylogit.MNL or None, optional.
Should be the MNL model object that is used to provide starting
val... | f7686:c0:m1 |
def generate_jackknife_replicates(self,<EOL>mnl_obj=None,<EOL>mnl_init_vals=None,<EOL>mnl_fit_kwargs=None,<EOL>extract_init_vals=None,<EOL>print_res=False,<EOL>method="<STR_LIT>",<EOL>loss_tol=<NUM_LIT>,<EOL>gradient_tol=<NUM_LIT>,<EOL>maxiter=<NUM_LIT:1000>,<EOL>ridge=None,<EOL>constrained_pos=None): | print("<STR_LIT>")<EOL>print(time.strftime("<STR_LIT>"))<EOL>sys.stdout.flush()<EOL>obs_id_col = self.model_obj.obs_id_col<EOL>orig_obs_id_array =self.model_obj.data[obs_id_col].values<EOL>unique_obs_ids = np.sort(np.unique(orig_obs_id_array))<EOL>num_obs = unique_obs_ids.size<EOL>num_params = self.mle_params.size<EOL>... | Generates the jackknife replicates for one's given model and dataset.
Parameters
----------
mnl_obj : an instance of pylogit.MNL or None, optional.
Should be the MNL model object that is used to provide starting
values for the final model being estimated. If None, then one's
final model should be an MNL mo... | f7686:c0:m2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.