repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.from_yaml | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a DiscreteChoiceModel instance from a saved YAML configuration.
Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
s... | python | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a DiscreteChoiceModel instance from a saved YAML configuration.
Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
s... | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_str",
"=",
"None",
",",
"str_or_buffer",
"=",
"None",
")",
":",
"cfg",
"=",
"yamlio",
".",
"yaml_to_dict",
"(",
"yaml_str",
",",
"str_or_buffer",
")",
"model",
"=",
"cls",
"(",
"cfg",
"[",
"'model_expression'",
... | Create a DiscreteChoiceModel instance from a saved YAML configuration.
Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
str_or_buffer : str or file like, optional
File name or buffer f... | [
"Create",
"a",
"DiscreteChoiceModel",
"instance",
"from",
"a",
"saved",
"YAML",
"configuration",
".",
"Arguments",
"are",
"mutally",
"exclusive",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L278-L320 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.fit | def fit(self, choosers, alternatives, current_choice):
"""
Fit and save model parameters based on given data.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
... | python | def fit(self, choosers, alternatives, current_choice):
"""
Fit and save model parameters based on given data.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
... | [
"def",
"fit",
"(",
"self",
",",
"choosers",
",",
"alternatives",
",",
"current_choice",
")",
":",
"logger",
".",
"debug",
"(",
"'start: fit LCM model {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"not",
"isinstance",
"(",
"current_choice",
... | Fit and save model parameters based on given data.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
Table describing the things from which agents are choosing,
... | [
"Fit",
"and",
"save",
"model",
"parameters",
"based",
"on",
"given",
"data",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L371-L427 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.probabilities | def probabilities(self, choosers, alternatives, filter_tables=True):
"""
Returns the probabilities for a set of choosers to choose
from among a set of alternatives.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, ... | python | def probabilities(self, choosers, alternatives, filter_tables=True):
"""
Returns the probabilities for a set of choosers to choose
from among a set of alternatives.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, ... | [
"def",
"probabilities",
"(",
"self",
",",
"choosers",
",",
"alternatives",
",",
"filter_tables",
"=",
"True",
")",
":",
"logger",
".",
"debug",
"(",
"'start: calculate probabilities for LCM model {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
... | Returns the probabilities for a set of choosers to choose
from among a set of alternatives.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
Table describing the... | [
"Returns",
"the",
"probabilities",
"for",
"a",
"set",
"of",
"choosers",
"to",
"choose",
"from",
"among",
"a",
"set",
"of",
"alternatives",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L474-L560 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.summed_probabilities | def summed_probabilities(self, choosers, alternatives):
"""
Calculate total probability associated with each alternative.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.Data... | python | def summed_probabilities(self, choosers, alternatives):
"""
Calculate total probability associated with each alternative.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.Data... | [
"def",
"summed_probabilities",
"(",
"self",
",",
"choosers",
",",
"alternatives",
")",
":",
"def",
"normalize",
"(",
"s",
")",
":",
"return",
"s",
"/",
"s",
".",
"sum",
"(",
")",
"choosers",
",",
"alternatives",
"=",
"self",
".",
"apply_predict_filters",
... | Calculate total probability associated with each alternative.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
Table describing the things from which agents are choosing... | [
"Calculate",
"total",
"probability",
"associated",
"with",
"each",
"alternative",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L562-L597 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.predict | def predict(self, choosers, alternatives, debug=False):
"""
Choose from among alternatives for a group of agents.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
... | python | def predict(self, choosers, alternatives, debug=False):
"""
Choose from among alternatives for a group of agents.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
... | [
"def",
"predict",
"(",
"self",
",",
"choosers",
",",
"alternatives",
",",
"debug",
"=",
"False",
")",
":",
"self",
".",
"assert_fitted",
"(",
")",
"logger",
".",
"debug",
"(",
"'start: predict LCM model {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
... | Choose from among alternatives for a group of agents.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataFrame
Table describing the things from which agents are choosing.
... | [
"Choose",
"from",
"among",
"alternatives",
"for",
"a",
"group",
"of",
"agents",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L599-L657 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.to_dict | def to_dict(self):
"""
Return a dict respresentation of an MNLDiscreteChoiceModel
instance.
"""
return {
'model_type': 'discretechoice',
'model_expression': self.model_expression,
'sample_size': self.sample_size,
'name': self.name,... | python | def to_dict(self):
"""
Return a dict respresentation of an MNLDiscreteChoiceModel
instance.
"""
return {
'model_type': 'discretechoice',
'model_expression': self.model_expression,
'sample_size': self.sample_size,
'name': self.name,... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'model_type'",
":",
"'discretechoice'",
",",
"'model_expression'",
":",
"self",
".",
"model_expression",
",",
"'sample_size'",
":",
"self",
".",
"sample_size",
",",
"'name'",
":",
"self",
".",
"name",
... | Return a dict respresentation of an MNLDiscreteChoiceModel
instance. | [
"Return",
"a",
"dict",
"respresentation",
"of",
"an",
"MNLDiscreteChoiceModel",
"instance",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L659-L684 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.choosers_columns_used | def choosers_columns_used(self):
"""
Columns from the choosers table that are used for filtering.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.choosers_predict_filters),
util.columns_in_filters(self.choosers_fit_filters)))) | python | def choosers_columns_used(self):
"""
Columns from the choosers table that are used for filtering.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.choosers_predict_filters),
util.columns_in_filters(self.choosers_fit_filters)))) | [
"def",
"choosers_columns_used",
"(",
"self",
")",
":",
"return",
"list",
"(",
"tz",
".",
"unique",
"(",
"tz",
".",
"concatv",
"(",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
"choosers_predict_filters",
")",
",",
"util",
".",
"columns_in_filters",
"... | Columns from the choosers table that are used for filtering. | [
"Columns",
"from",
"the",
"choosers",
"table",
"that",
"are",
"used",
"for",
"filtering",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L712-L719 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.interaction_columns_used | def interaction_columns_used(self):
"""
Columns from the interaction dataset used for filtering and in
the model. These may come originally from either the choosers or
alternatives tables.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.int... | python | def interaction_columns_used(self):
"""
Columns from the interaction dataset used for filtering and in
the model. These may come originally from either the choosers or
alternatives tables.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.int... | [
"def",
"interaction_columns_used",
"(",
"self",
")",
":",
"return",
"list",
"(",
"tz",
".",
"unique",
"(",
"tz",
".",
"concatv",
"(",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
"interaction_predict_filters",
")",
",",
"util",
".",
"columns_in_formula... | Columns from the interaction dataset used for filtering and in
the model. These may come originally from either the choosers or
alternatives tables. | [
"Columns",
"from",
"the",
"interaction",
"dataset",
"used",
"for",
"filtering",
"and",
"in",
"the",
"model",
".",
"These",
"may",
"come",
"originally",
"from",
"either",
"the",
"choosers",
"or",
"alternatives",
"tables",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L730-L739 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModel.predict_from_cfg | def predict_from_cfg(cls, choosers, alternatives, cfgname=None, cfg=None,
alternative_ratio=2.0, debug=False):
"""
Simulate choices for the specified choosers
Parameters
----------
choosers : DataFrame
A dataframe of agents doing the choosing... | python | def predict_from_cfg(cls, choosers, alternatives, cfgname=None, cfg=None,
alternative_ratio=2.0, debug=False):
"""
Simulate choices for the specified choosers
Parameters
----------
choosers : DataFrame
A dataframe of agents doing the choosing... | [
"def",
"predict_from_cfg",
"(",
"cls",
",",
"choosers",
",",
"alternatives",
",",
"cfgname",
"=",
"None",
",",
"cfg",
"=",
"None",
",",
"alternative_ratio",
"=",
"2.0",
",",
"debug",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"'start: predict fro... | Simulate choices for the specified choosers
Parameters
----------
choosers : DataFrame
A dataframe of agents doing the choosing.
alternatives : DataFrame
A dataframe of locations which the choosers are locating in and
which have a supply.
cfgn... | [
"Simulate",
"choices",
"for",
"the",
"specified",
"choosers"
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L787-L847 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModelGroup.add_model_from_params | def add_model_from_params(
self, name, model_expression, sample_size,
probability_mode='full_product', choice_mode='individual',
choosers_fit_filters=None, choosers_predict_filters=None,
alts_fit_filters=None, alts_predict_filters=None,
interaction_predict_fil... | python | def add_model_from_params(
self, name, model_expression, sample_size,
probability_mode='full_product', choice_mode='individual',
choosers_fit_filters=None, choosers_predict_filters=None,
alts_fit_filters=None, alts_predict_filters=None,
interaction_predict_fil... | [
"def",
"add_model_from_params",
"(",
"self",
",",
"name",
",",
"model_expression",
",",
"sample_size",
",",
"probability_mode",
"=",
"'full_product'",
",",
"choice_mode",
"=",
"'individual'",
",",
"choosers_fit_filters",
"=",
"None",
",",
"choosers_predict_filters",
"... | Add a model by passing parameters through to MNLDiscreteChoiceModel.
Parameters
----------
name
Must match a segment in the choosers table.
model_expression : str, iterable, or dict
A patsy model expression. Should contain only a right-hand side.
sample_s... | [
"Add",
"a",
"model",
"by",
"passing",
"parameters",
"through",
"to",
"MNLDiscreteChoiceModel",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L893-L960 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModelGroup.apply_fit_filters | def apply_fit_filters(self, choosers, alternatives):
"""
Filter `choosers` and `alternatives` for fitting.
This is done by filtering each submodel and concatenating
the results.
Parameters
----------
choosers : pandas.DataFrame
Table describing the ag... | python | def apply_fit_filters(self, choosers, alternatives):
"""
Filter `choosers` and `alternatives` for fitting.
This is done by filtering each submodel and concatenating
the results.
Parameters
----------
choosers : pandas.DataFrame
Table describing the ag... | [
"def",
"apply_fit_filters",
"(",
"self",
",",
"choosers",
",",
"alternatives",
")",
":",
"ch",
"=",
"[",
"]",
"alts",
"=",
"[",
"]",
"for",
"name",
",",
"df",
"in",
"self",
".",
"_iter_groups",
"(",
"choosers",
")",
":",
"filtered_choosers",
",",
"filt... | Filter `choosers` and `alternatives` for fitting.
This is done by filtering each submodel and concatenating
the results.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
alternatives : pandas.DataF... | [
"Filter",
"choosers",
"and",
"alternatives",
"for",
"fitting",
".",
"This",
"is",
"done",
"by",
"filtering",
"each",
"submodel",
"and",
"concatenating",
"the",
"results",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L986-L1014 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModelGroup.fit | def fit(self, choosers, alternatives, current_choice):
"""
Fit and save models based on given data after segmenting
the `choosers` table.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
... | python | def fit(self, choosers, alternatives, current_choice):
"""
Fit and save models based on given data after segmenting
the `choosers` table.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
... | [
"def",
"fit",
"(",
"self",
",",
"choosers",
",",
"alternatives",
",",
"current_choice",
")",
":",
"with",
"log_start_finish",
"(",
"'fit models in LCM group {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
",",
"logger",
")",
":",
"return",
"{",
"name",
... | Fit and save models based on given data after segmenting
the `choosers` table.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
Must have a column with the same name as the .segmentation_col
... | [
"Fit",
"and",
"save",
"models",
"based",
"on",
"given",
"data",
"after",
"segmenting",
"the",
"choosers",
"table",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1049-L1078 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModelGroup.fitted | def fitted(self):
"""
Whether all models in the group have been fitted.
"""
return (all(m.fitted for m in self.models.values())
if self.models else False) | python | def fitted(self):
"""
Whether all models in the group have been fitted.
"""
return (all(m.fitted for m in self.models.values())
if self.models else False) | [
"def",
"fitted",
"(",
"self",
")",
":",
"return",
"(",
"all",
"(",
"m",
".",
"fitted",
"for",
"m",
"in",
"self",
".",
"models",
".",
"values",
"(",
")",
")",
"if",
"self",
".",
"models",
"else",
"False",
")"
] | Whether all models in the group have been fitted. | [
"Whether",
"all",
"models",
"in",
"the",
"group",
"have",
"been",
"fitted",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1081-L1087 | train |
UDST/urbansim | urbansim/models/dcm.py | MNLDiscreteChoiceModelGroup.summed_probabilities | def summed_probabilities(self, choosers, alternatives):
"""
Returns the sum of probabilities for alternatives across all
chooser segments.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
... | python | def summed_probabilities(self, choosers, alternatives):
"""
Returns the sum of probabilities for alternatives across all
chooser segments.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
... | [
"def",
"summed_probabilities",
"(",
"self",
",",
"choosers",
",",
"alternatives",
")",
":",
"if",
"len",
"(",
"alternatives",
")",
"==",
"0",
"or",
"len",
"(",
"choosers",
")",
"==",
"0",
":",
"return",
"pd",
".",
"Series",
"(",
")",
"logger",
".",
"... | Returns the sum of probabilities for alternatives across all
chooser segments.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
Must have a column matching the .segmentation_col attribute.
alte... | [
"Returns",
"the",
"sum",
"of",
"probabilities",
"for",
"alternatives",
"across",
"all",
"chooser",
"segments",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1119-L1156 | train |
UDST/urbansim | urbansim/models/dcm.py | SegmentedMNLDiscreteChoiceModel.from_yaml | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML
configuration. Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load mode... | python | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML
configuration. Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load mode... | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_str",
"=",
"None",
",",
"str_or_buffer",
"=",
"None",
")",
":",
"cfg",
"=",
"yamlio",
".",
"yaml_to_dict",
"(",
"yaml_str",
",",
"str_or_buffer",
")",
"default_model_expr",
"=",
"cfg",
"[",
"'default_config'",
"]",
... | Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML
configuration. Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
str_or_buffer : str or file like, optional
File name... | [
"Create",
"a",
"SegmentedMNLDiscreteChoiceModel",
"instance",
"from",
"a",
"saved",
"YAML",
"configuration",
".",
"Arguments",
"are",
"mutally",
"exclusive",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1334-L1397 | train |
UDST/urbansim | urbansim/models/dcm.py | SegmentedMNLDiscreteChoiceModel.add_segment | def add_segment(self, name, model_expression=None):
"""
Add a new segment with its own model expression.
Parameters
----------
name
Segment name. Must match a segment in the groupby of the data.
model_expression : str or dict, optional
A patsy mod... | python | def add_segment(self, name, model_expression=None):
"""
Add a new segment with its own model expression.
Parameters
----------
name
Segment name. Must match a segment in the groupby of the data.
model_expression : str or dict, optional
A patsy mod... | [
"def",
"add_segment",
"(",
"self",
",",
"name",
",",
"model_expression",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'adding LCM model {} to segmented model {}'",
".",
"format",
"(",
"name",
",",
"self",
".",
"name",
")",
")",
"if",
"not",
"model_ex... | Add a new segment with its own model expression.
Parameters
----------
name
Segment name. Must match a segment in the groupby of the data.
model_expression : str or dict, optional
A patsy model expression that can be used with statsmodels.
Should cont... | [
"Add",
"a",
"new",
"segment",
"with",
"its",
"own",
"model",
"expression",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1399-L1437 | train |
UDST/urbansim | urbansim/models/dcm.py | SegmentedMNLDiscreteChoiceModel.fit | def fit(self, choosers, alternatives, current_choice):
"""
Fit and save models based on given data after segmenting
the `choosers` table. Segments that have not already been explicitly
added will be automatically added with default model.
Parameters
----------
ch... | python | def fit(self, choosers, alternatives, current_choice):
"""
Fit and save models based on given data after segmenting
the `choosers` table. Segments that have not already been explicitly
added will be automatically added with default model.
Parameters
----------
ch... | [
"def",
"fit",
"(",
"self",
",",
"choosers",
",",
"alternatives",
",",
"current_choice",
")",
":",
"logger",
".",
"debug",
"(",
"'start: fit models in segmented LCM {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"choosers",
",",
"alternatives",
"=",
... | Fit and save models based on given data after segmenting
the `choosers` table. Segments that have not already been explicitly
added will be automatically added with default model.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making ch... | [
"Fit",
"and",
"save",
"models",
"based",
"on",
"given",
"data",
"after",
"segmenting",
"the",
"choosers",
"table",
".",
"Segments",
"that",
"have",
"not",
"already",
"been",
"explicitly",
"added",
"will",
"be",
"automatically",
"added",
"with",
"default",
"mod... | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1480-L1526 | train |
UDST/urbansim | urbansim/models/dcm.py | SegmentedMNLDiscreteChoiceModel._filter_choosers_alts | def _filter_choosers_alts(self, choosers, alternatives):
"""
Apply filters to the choosers and alts tables.
"""
return (
util.apply_filter_query(
choosers, self.choosers_predict_filters),
util.apply_filter_query(
alternatives, self... | python | def _filter_choosers_alts(self, choosers, alternatives):
"""
Apply filters to the choosers and alts tables.
"""
return (
util.apply_filter_query(
choosers, self.choosers_predict_filters),
util.apply_filter_query(
alternatives, self... | [
"def",
"_filter_choosers_alts",
"(",
"self",
",",
"choosers",
",",
"alternatives",
")",
":",
"return",
"(",
"util",
".",
"apply_filter_query",
"(",
"choosers",
",",
"self",
".",
"choosers_predict_filters",
")",
",",
"util",
".",
"apply_filter_query",
"(",
"alter... | Apply filters to the choosers and alts tables. | [
"Apply",
"filters",
"to",
"the",
"choosers",
"and",
"alts",
"tables",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1536-L1545 | train |
UDST/urbansim | scripts/cache_to_hdf5.py | cache_to_df | def cache_to_df(dir_path):
"""
Convert a directory of binary array data files to a Pandas DataFrame.
Parameters
----------
dir_path : str
"""
table = {}
for attrib in glob.glob(os.path.join(dir_path, '*')):
attrib_name, attrib_ext = os.path.splitext(os.path.basename(attrib))
... | python | def cache_to_df(dir_path):
"""
Convert a directory of binary array data files to a Pandas DataFrame.
Parameters
----------
dir_path : str
"""
table = {}
for attrib in glob.glob(os.path.join(dir_path, '*')):
attrib_name, attrib_ext = os.path.splitext(os.path.basename(attrib))
... | [
"def",
"cache_to_df",
"(",
"dir_path",
")",
":",
"table",
"=",
"{",
"}",
"for",
"attrib",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dir_path",
",",
"'*'",
")",
")",
":",
"attrib_name",
",",
"attrib_ext",
"=",
"os",
".",
... | Convert a directory of binary array data files to a Pandas DataFrame.
Parameters
----------
dir_path : str | [
"Convert",
"a",
"directory",
"of",
"binary",
"array",
"data",
"files",
"to",
"a",
"Pandas",
"DataFrame",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/scripts/cache_to_hdf5.py#L14-L60 | train |
UDST/urbansim | scripts/cache_to_hdf5.py | convert_dirs | def convert_dirs(base_dir, hdf_name, complib=None, complevel=0):
"""
Convert nested set of directories to
"""
print('Converting directories in {}'.format(base_dir))
dirs = glob.glob(os.path.join(base_dir, '*'))
dirs = {d for d in dirs if os.path.basename(d) in DIRECTORIES}
if not dirs:
... | python | def convert_dirs(base_dir, hdf_name, complib=None, complevel=0):
"""
Convert nested set of directories to
"""
print('Converting directories in {}'.format(base_dir))
dirs = glob.glob(os.path.join(base_dir, '*'))
dirs = {d for d in dirs if os.path.basename(d) in DIRECTORIES}
if not dirs:
... | [
"def",
"convert_dirs",
"(",
"base_dir",
",",
"hdf_name",
",",
"complib",
"=",
"None",
",",
"complevel",
"=",
"0",
")",
":",
"print",
"(",
"'Converting directories in {}'",
".",
"format",
"(",
"base_dir",
")",
")",
"dirs",
"=",
"glob",
".",
"glob",
"(",
"... | Convert nested set of directories to | [
"Convert",
"nested",
"set",
"of",
"directories",
"to"
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/scripts/cache_to_hdf5.py#L72-L130 | train |
UDST/urbansim | urbansim/utils/misc.py | get_run_number | def get_run_number():
"""
Get a run number for this execution of the model system, for
identifying the output hdf5 files).
Returns
-------
The integer number for this run of the model system.
"""
try:
f = open(os.path.join(os.getenv('DATA_HOME', "."), 'RUNNUM'), 'r')
num... | python | def get_run_number():
"""
Get a run number for this execution of the model system, for
identifying the output hdf5 files).
Returns
-------
The integer number for this run of the model system.
"""
try:
f = open(os.path.join(os.getenv('DATA_HOME', "."), 'RUNNUM'), 'r')
num... | [
"def",
"get_run_number",
"(",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getenv",
"(",
"'DATA_HOME'",
",",
"\".\"",
")",
",",
"'RUNNUM'",
")",
",",
"'r'",
")",
"num",
"=",
"int",
"(",
"f",
".",... | Get a run number for this execution of the model system, for
identifying the output hdf5 files).
Returns
-------
The integer number for this run of the model system. | [
"Get",
"a",
"run",
"number",
"for",
"this",
"execution",
"of",
"the",
"model",
"system",
"for",
"identifying",
"the",
"output",
"hdf5",
"files",
")",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L97-L115 | train |
UDST/urbansim | urbansim/utils/misc.py | compute_range | def compute_range(travel_data, attr, travel_time_attr, dist, agg=np.sum):
"""
Compute a zone-based accessibility query using the urbansim format
travel data dataframe.
Parameters
----------
travel_data : dataframe
The dataframe of urbansim format travel data. Has from_zone_id as
... | python | def compute_range(travel_data, attr, travel_time_attr, dist, agg=np.sum):
"""
Compute a zone-based accessibility query using the urbansim format
travel data dataframe.
Parameters
----------
travel_data : dataframe
The dataframe of urbansim format travel data. Has from_zone_id as
... | [
"def",
"compute_range",
"(",
"travel_data",
",",
"attr",
",",
"travel_time_attr",
",",
"dist",
",",
"agg",
"=",
"np",
".",
"sum",
")",
":",
"travel_data",
"=",
"travel_data",
".",
"reset_index",
"(",
"level",
"=",
"1",
")",
"travel_data",
"=",
"travel_data... | Compute a zone-based accessibility query using the urbansim format
travel data dataframe.
Parameters
----------
travel_data : dataframe
The dataframe of urbansim format travel data. Has from_zone_id as
first index, to_zone_id as second index, and different impedances
between zo... | [
"Compute",
"a",
"zone",
"-",
"based",
"accessibility",
"query",
"using",
"the",
"urbansim",
"format",
"travel",
"data",
"dataframe",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L118-L142 | train |
UDST/urbansim | urbansim/utils/misc.py | reindex | def reindex(series1, series2):
"""
This reindexes the first series by the second series. This is an extremely
common operation that does not appear to be in Pandas at this time.
If anyone knows of an easier way to do this in Pandas, please inform the
UrbanSim developers.
The canonical example... | python | def reindex(series1, series2):
"""
This reindexes the first series by the second series. This is an extremely
common operation that does not appear to be in Pandas at this time.
If anyone knows of an easier way to do this in Pandas, please inform the
UrbanSim developers.
The canonical example... | [
"def",
"reindex",
"(",
"series1",
",",
"series2",
")",
":",
"df",
"=",
"pd",
".",
"merge",
"(",
"pd",
".",
"DataFrame",
"(",
"{",
"\"left\"",
":",
"series2",
"}",
")",
",",
"pd",
".",
"DataFrame",
"(",
"{",
"\"right\"",
":",
"series1",
"}",
")",
... | This reindexes the first series by the second series. This is an extremely
common operation that does not appear to be in Pandas at this time.
If anyone knows of an easier way to do this in Pandas, please inform the
UrbanSim developers.
The canonical example would be a parcel series which has an inde... | [
"This",
"reindexes",
"the",
"first",
"series",
"by",
"the",
"second",
"series",
".",
"This",
"is",
"an",
"extremely",
"common",
"operation",
"that",
"does",
"not",
"appear",
"to",
"be",
"in",
"Pandas",
"at",
"this",
"time",
".",
"If",
"anyone",
"knows",
... | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L145-L177 | train |
UDST/urbansim | urbansim/utils/misc.py | df64bitto32bit | def df64bitto32bit(tbl):
"""
Convert a Pandas dataframe from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
tbl : The dataframe to convert
Returns
-------
The converted dataframe
"""
newtbl = pd.DataFrame(index=tbl.index)
for colname in... | python | def df64bitto32bit(tbl):
"""
Convert a Pandas dataframe from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
tbl : The dataframe to convert
Returns
-------
The converted dataframe
"""
newtbl = pd.DataFrame(index=tbl.index)
for colname in... | [
"def",
"df64bitto32bit",
"(",
"tbl",
")",
":",
"newtbl",
"=",
"pd",
".",
"DataFrame",
"(",
"index",
"=",
"tbl",
".",
"index",
")",
"for",
"colname",
"in",
"tbl",
".",
"columns",
":",
"newtbl",
"[",
"colname",
"]",
"=",
"series64bitto32bit",
"(",
"tbl",... | Convert a Pandas dataframe from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
tbl : The dataframe to convert
Returns
-------
The converted dataframe | [
"Convert",
"a",
"Pandas",
"dataframe",
"from",
"64",
"bit",
"types",
"to",
"32",
"bit",
"types",
"to",
"save",
"memory",
"or",
"disk",
"space",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L320-L336 | train |
UDST/urbansim | urbansim/utils/misc.py | series64bitto32bit | def series64bitto32bit(s):
"""
Convert a Pandas series from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
s : The series to convert
Returns
-------
The converted series
"""
if s.dtype == np.float64:
return s.astype('float32')
e... | python | def series64bitto32bit(s):
"""
Convert a Pandas series from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
s : The series to convert
Returns
-------
The converted series
"""
if s.dtype == np.float64:
return s.astype('float32')
e... | [
"def",
"series64bitto32bit",
"(",
"s",
")",
":",
"if",
"s",
".",
"dtype",
"==",
"np",
".",
"float64",
":",
"return",
"s",
".",
"astype",
"(",
"'float32'",
")",
"elif",
"s",
".",
"dtype",
"==",
"np",
".",
"int64",
":",
"return",
"s",
".",
"astype",
... | Convert a Pandas series from 64 bit types to 32 bit types to save
memory or disk space.
Parameters
----------
s : The series to convert
Returns
-------
The converted series | [
"Convert",
"a",
"Pandas",
"series",
"from",
"64",
"bit",
"types",
"to",
"32",
"bit",
"types",
"to",
"save",
"memory",
"or",
"disk",
"space",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L339-L356 | train |
UDST/urbansim | urbansim/utils/misc.py | pandasdfsummarytojson | def pandasdfsummarytojson(df, ndigits=3):
"""
Convert the result of a
Parameters
----------
df : The result of a Pandas describe operation.
ndigits : int, optional - The number of significant digits to round to.
Returns
-------
A json object which captures the describe. Keys are f... | python | def pandasdfsummarytojson(df, ndigits=3):
"""
Convert the result of a
Parameters
----------
df : The result of a Pandas describe operation.
ndigits : int, optional - The number of significant digits to round to.
Returns
-------
A json object which captures the describe. Keys are f... | [
"def",
"pandasdfsummarytojson",
"(",
"df",
",",
"ndigits",
"=",
"3",
")",
":",
"df",
"=",
"df",
".",
"transpose",
"(",
")",
"return",
"{",
"k",
":",
"_pandassummarytojson",
"(",
"v",
",",
"ndigits",
")",
"for",
"k",
",",
"v",
"in",
"df",
".",
"iter... | Convert the result of a
Parameters
----------
df : The result of a Pandas describe operation.
ndigits : int, optional - The number of significant digits to round to.
Returns
-------
A json object which captures the describe. Keys are field names and
values are dictionaries with all of... | [
"Convert",
"the",
"result",
"of",
"a"
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L363-L379 | train |
UDST/urbansim | urbansim/utils/misc.py | column_map | def column_map(tables, columns):
"""
Take a list of tables and a list of column names and resolve which
columns come from which table.
Parameters
----------
tables : sequence of _DataFrameWrapper or _TableFuncWrapper
Could also be sequence of modified pandas.DataFrames, the important
... | python | def column_map(tables, columns):
"""
Take a list of tables and a list of column names and resolve which
columns come from which table.
Parameters
----------
tables : sequence of _DataFrameWrapper or _TableFuncWrapper
Could also be sequence of modified pandas.DataFrames, the important
... | [
"def",
"column_map",
"(",
"tables",
",",
"columns",
")",
":",
"if",
"not",
"columns",
":",
"return",
"{",
"t",
".",
"name",
":",
"None",
"for",
"t",
"in",
"tables",
"}",
"columns",
"=",
"set",
"(",
"columns",
")",
"colmap",
"=",
"{",
"t",
".",
"n... | Take a list of tables and a list of column names and resolve which
columns come from which table.
Parameters
----------
tables : sequence of _DataFrameWrapper or _TableFuncWrapper
Could also be sequence of modified pandas.DataFrames, the important
thing is that they have ``.name`` and `... | [
"Take",
"a",
"list",
"of",
"tables",
"and",
"a",
"list",
"of",
"column",
"names",
"and",
"resolve",
"which",
"columns",
"come",
"from",
"which",
"table",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L382-L410 | train |
UDST/urbansim | urbansim/utils/misc.py | column_list | def column_list(tables, columns):
"""
Take a list of tables and a list of column names and return the columns
that are present in the tables.
Parameters
----------
tables : sequence of _DataFrameWrapper or _TableFuncWrapper
Could also be sequence of modified pandas.DataFrames, the impor... | python | def column_list(tables, columns):
"""
Take a list of tables and a list of column names and return the columns
that are present in the tables.
Parameters
----------
tables : sequence of _DataFrameWrapper or _TableFuncWrapper
Could also be sequence of modified pandas.DataFrames, the impor... | [
"def",
"column_list",
"(",
"tables",
",",
"columns",
")",
":",
"columns",
"=",
"set",
"(",
"columns",
")",
"foundcols",
"=",
"tz",
".",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
".",
"union",
"(",
"y",
")",
",",
"(",
"set",
"(",
"t",
".... | Take a list of tables and a list of column names and return the columns
that are present in the tables.
Parameters
----------
tables : sequence of _DataFrameWrapper or _TableFuncWrapper
Could also be sequence of modified pandas.DataFrames, the important
thing is that they have ``.name``... | [
"Take",
"a",
"list",
"of",
"tables",
"and",
"a",
"list",
"of",
"column",
"names",
"and",
"return",
"the",
"columns",
"that",
"are",
"present",
"in",
"the",
"tables",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/misc.py#L413-L434 | train |
UDST/urbansim | urbansim/utils/sampling.py | accounting_sample_replace | def accounting_sample_replace(total, data, accounting_column, prob_column=None, max_iterations=50):
"""
Sample rows with accounting with replacement.
Parameters
----------
total : int
The control total the sampled rows will attempt to match.
data: pandas.DataFrame
Table to sampl... | python | def accounting_sample_replace(total, data, accounting_column, prob_column=None, max_iterations=50):
"""
Sample rows with accounting with replacement.
Parameters
----------
total : int
The control total the sampled rows will attempt to match.
data: pandas.DataFrame
Table to sampl... | [
"def",
"accounting_sample_replace",
"(",
"total",
",",
"data",
",",
"accounting_column",
",",
"prob_column",
"=",
"None",
",",
"max_iterations",
"=",
"50",
")",
":",
"p",
"=",
"get_probs",
"(",
"data",
",",
"prob_column",
")",
"per_sample",
"=",
"data",
"[",... | Sample rows with accounting with replacement.
Parameters
----------
total : int
The control total the sampled rows will attempt to match.
data: pandas.DataFrame
Table to sample from.
accounting_column: string
Name of column with accounting totals/quantities to apply towards ... | [
"Sample",
"rows",
"with",
"accounting",
"with",
"replacement",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/sampling.py#L35-L105 | train |
UDST/urbansim | urbansim/utils/sampling.py | accounting_sample_no_replace | def accounting_sample_no_replace(total, data, accounting_column, prob_column=None):
"""
Samples rows with accounting without replacement.
Parameters
----------
total : int
The control total the sampled rows will attempt to match.
data: pandas.DataFrame
Table to sample from.
... | python | def accounting_sample_no_replace(total, data, accounting_column, prob_column=None):
"""
Samples rows with accounting without replacement.
Parameters
----------
total : int
The control total the sampled rows will attempt to match.
data: pandas.DataFrame
Table to sample from.
... | [
"def",
"accounting_sample_no_replace",
"(",
"total",
",",
"data",
",",
"accounting_column",
",",
"prob_column",
"=",
"None",
")",
":",
"if",
"total",
">",
"data",
"[",
"accounting_column",
"]",
".",
"sum",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Control... | Samples rows with accounting without replacement.
Parameters
----------
total : int
The control total the sampled rows will attempt to match.
data: pandas.DataFrame
Table to sample from.
accounting_column: string
Name of column with accounting totals/quantities to apply towa... | [
"Samples",
"rows",
"with",
"accounting",
"without",
"replacement",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/sampling.py#L108-L172 | train |
UDST/urbansim | urbansim/developer/sqftproforma.py | SqFtProFormaConfig._convert_types | def _convert_types(self):
"""
convert lists and dictionaries that are useful for users to
np vectors that are usable by machines
"""
self.fars = np.array(self.fars)
self.parking_rates = np.array([self.parking_rates[use] for use in self.uses])
self.res_ratios = {}... | python | def _convert_types(self):
"""
convert lists and dictionaries that are useful for users to
np vectors that are usable by machines
"""
self.fars = np.array(self.fars)
self.parking_rates = np.array([self.parking_rates[use] for use in self.uses])
self.res_ratios = {}... | [
"def",
"_convert_types",
"(",
"self",
")",
":",
"self",
".",
"fars",
"=",
"np",
".",
"array",
"(",
"self",
".",
"fars",
")",
"self",
".",
"parking_rates",
"=",
"np",
".",
"array",
"(",
"[",
"self",
".",
"parking_rates",
"[",
"use",
"]",
"for",
"use... | convert lists and dictionaries that are useful for users to
np vectors that are usable by machines | [
"convert",
"lists",
"and",
"dictionaries",
"that",
"are",
"useful",
"for",
"users",
"to",
"np",
"vectors",
"that",
"are",
"usable",
"by",
"machines"
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/sqftproforma.py#L192-L207 | train |
UDST/urbansim | urbansim/developer/sqftproforma.py | SqFtProForma._building_cost | def _building_cost(self, use_mix, stories):
"""
Generate building cost for a set of buildings
Parameters
----------
use_mix : array
The mix of uses for this form
stories : series
A Pandas Series of stories
Returns
-------
... | python | def _building_cost(self, use_mix, stories):
"""
Generate building cost for a set of buildings
Parameters
----------
use_mix : array
The mix of uses for this form
stories : series
A Pandas Series of stories
Returns
-------
... | [
"def",
"_building_cost",
"(",
"self",
",",
"use_mix",
",",
"stories",
")",
":",
"c",
"=",
"self",
".",
"config",
"heights",
"=",
"stories",
"*",
"c",
".",
"height_per_story",
"costs",
"=",
"np",
".",
"searchsorted",
"(",
"c",
".",
"heights_for_costs",
",... | Generate building cost for a set of buildings
Parameters
----------
use_mix : array
The mix of uses for this form
stories : series
A Pandas Series of stories
Returns
-------
array
The cost per sqft for this unit mix and height... | [
"Generate",
"building",
"cost",
"for",
"a",
"set",
"of",
"buildings"
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/sqftproforma.py#L279-L307 | train |
UDST/urbansim | urbansim/developer/sqftproforma.py | SqFtProForma._generate_lookup | def _generate_lookup(self):
"""
Run the developer model on all possible inputs specified in the
configuration object - not generally called by the user. This part
computes the final cost per sqft of the building to construct and
then turns it into the yearly rent necessary to ma... | python | def _generate_lookup(self):
"""
Run the developer model on all possible inputs specified in the
configuration object - not generally called by the user. This part
computes the final cost per sqft of the building to construct and
then turns it into the yearly rent necessary to ma... | [
"def",
"_generate_lookup",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"config",
"keys",
"=",
"c",
".",
"forms",
".",
"keys",
"(",
")",
"keys",
"=",
"sorted",
"(",
"keys",
")",
"df_d",
"=",
"{",
"}",
"for",
"name",
"in",
"keys",
":",
"uses_dist... | Run the developer model on all possible inputs specified in the
configuration object - not generally called by the user. This part
computes the final cost per sqft of the building to construct and
then turns it into the yearly rent necessary to make break even on
that cost. | [
"Run",
"the",
"developer",
"model",
"on",
"all",
"possible",
"inputs",
"specified",
"in",
"the",
"configuration",
"object",
"-",
"not",
"generally",
"called",
"by",
"the",
"user",
".",
"This",
"part",
"computes",
"the",
"final",
"cost",
"per",
"sqft",
"of",
... | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/sqftproforma.py#L309-L398 | train |
UDST/urbansim | urbansim/developer/sqftproforma.py | SqFtProForma.lookup | def lookup(self, form, df, only_built=True, pass_through=None):
"""
This function does the developer model lookups for all the actual input data.
Parameters
----------
form : string
One of the forms specified in the configuration file
df: dataframe
... | python | def lookup(self, form, df, only_built=True, pass_through=None):
"""
This function does the developer model lookups for all the actual input data.
Parameters
----------
form : string
One of the forms specified in the configuration file
df: dataframe
... | [
"def",
"lookup",
"(",
"self",
",",
"form",
",",
"df",
",",
"only_built",
"=",
"True",
",",
"pass_through",
"=",
"None",
")",
":",
"df",
"=",
"pd",
".",
"concat",
"(",
"self",
".",
"_lookup_parking_cfg",
"(",
"form",
",",
"parking_config",
",",
"df",
... | This function does the developer model lookups for all the actual input data.
Parameters
----------
form : string
One of the forms specified in the configuration file
df: dataframe
Pass in a single data frame which is indexed by parcel_id and has the
... | [
"This",
"function",
"does",
"the",
"developer",
"model",
"lookups",
"for",
"all",
"the",
"actual",
"input",
"data",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/sqftproforma.py#L445-L537 | train |
UDST/urbansim | urbansim/developer/sqftproforma.py | SqFtProForma._debug_output | def _debug_output(self):
"""
this code creates the debugging plots to understand
the behavior of the hypothetical building model
"""
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
c = self.config
df_d = self.dev_d
... | python | def _debug_output(self):
"""
this code creates the debugging plots to understand
the behavior of the hypothetical building model
"""
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
c = self.config
df_d = self.dev_d
... | [
"def",
"_debug_output",
"(",
"self",
")",
":",
"import",
"matplotlib",
"matplotlib",
".",
"use",
"(",
"'Agg'",
")",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"c",
"=",
"self",
".",
"config",
"df_d",
"=",
"self",
".",
"dev_d",
"keys",
"=",
"df... | this code creates the debugging plots to understand
the behavior of the hypothetical building model | [
"this",
"code",
"creates",
"the",
"debugging",
"plots",
"to",
"understand",
"the",
"behavior",
"of",
"the",
"hypothetical",
"building",
"model"
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/sqftproforma.py#L666-L716 | train |
UDST/urbansim | urbansim/models/transition.py | add_rows | def add_rows(data, nrows, starting_index=None, accounting_column=None):
"""
Add rows to data table according to a given nrows.
New rows will have their IDs set to NaN.
Parameters
----------
data : pandas.DataFrame
nrows : int
Number of rows to add.
starting_index : int, optional... | python | def add_rows(data, nrows, starting_index=None, accounting_column=None):
"""
Add rows to data table according to a given nrows.
New rows will have their IDs set to NaN.
Parameters
----------
data : pandas.DataFrame
nrows : int
Number of rows to add.
starting_index : int, optional... | [
"def",
"add_rows",
"(",
"data",
",",
"nrows",
",",
"starting_index",
"=",
"None",
",",
"accounting_column",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'start: adding {} rows in transition model'",
".",
"format",
"(",
"nrows",
")",
")",
"if",
"nrows",... | Add rows to data table according to a given nrows.
New rows will have their IDs set to NaN.
Parameters
----------
data : pandas.DataFrame
nrows : int
Number of rows to add.
starting_index : int, optional
The starting index from which to calculate indexes for the new
rows... | [
"Add",
"rows",
"to",
"data",
"table",
"according",
"to",
"a",
"given",
"nrows",
".",
"New",
"rows",
"will",
"have",
"their",
"IDs",
"set",
"to",
"NaN",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/transition.py#L24-L68 | train |
UDST/urbansim | urbansim/models/transition.py | remove_rows | def remove_rows(data, nrows, accounting_column=None):
"""
Remove a random `nrows` number of rows from a table.
Parameters
----------
data : DataFrame
nrows : float
Number of rows to remove.
accounting_column: string, optional
Name of column with accounting totals/quanties to... | python | def remove_rows(data, nrows, accounting_column=None):
"""
Remove a random `nrows` number of rows from a table.
Parameters
----------
data : DataFrame
nrows : float
Number of rows to remove.
accounting_column: string, optional
Name of column with accounting totals/quanties to... | [
"def",
"remove_rows",
"(",
"data",
",",
"nrows",
",",
"accounting_column",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'start: removing {} rows in transition model'",
".",
"format",
"(",
"nrows",
")",
")",
"nrows",
"=",
"abs",
"(",
"nrows",
")",
"un... | Remove a random `nrows` number of rows from a table.
Parameters
----------
data : DataFrame
nrows : float
Number of rows to remove.
accounting_column: string, optional
Name of column with accounting totals/quanties to apply towards the control. If not provided
then row count... | [
"Remove",
"a",
"random",
"nrows",
"number",
"of",
"rows",
"from",
"a",
"table",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/transition.py#L71-L104 | train |
UDST/urbansim | urbansim/models/transition.py | _update_linked_table | def _update_linked_table(table, col_name, added, copied, removed):
"""
Copy and update rows in a table that has a column referencing another
table that has had rows added via copying.
Parameters
----------
table : pandas.DataFrame
Table to update with new or removed rows.
col_name :... | python | def _update_linked_table(table, col_name, added, copied, removed):
"""
Copy and update rows in a table that has a column referencing another
table that has had rows added via copying.
Parameters
----------
table : pandas.DataFrame
Table to update with new or removed rows.
col_name :... | [
"def",
"_update_linked_table",
"(",
"table",
",",
"col_name",
",",
"added",
",",
"copied",
",",
"removed",
")",
":",
"logger",
".",
"debug",
"(",
"'start: update linked table after transition'",
")",
"table",
"=",
"table",
".",
"loc",
"[",
"~",
"table",
"[",
... | Copy and update rows in a table that has a column referencing another
table that has had rows added via copying.
Parameters
----------
table : pandas.DataFrame
Table to update with new or removed rows.
col_name : str
Name of column in `table` that corresponds to the index values
... | [
"Copy",
"and",
"update",
"rows",
"in",
"a",
"table",
"that",
"has",
"a",
"column",
"referencing",
"another",
"table",
"that",
"has",
"had",
"rows",
"added",
"via",
"copying",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/transition.py#L424-L468 | train |
UDST/urbansim | urbansim/models/transition.py | TransitionModel.transition | def transition(self, data, year, linked_tables=None):
"""
Add or remove rows from a table based on population targets.
Parameters
----------
data : pandas.DataFrame
Rows will be removed from or added to this table.
year : int
Year number that will... | python | def transition(self, data, year, linked_tables=None):
"""
Add or remove rows from a table based on population targets.
Parameters
----------
data : pandas.DataFrame
Rows will be removed from or added to this table.
year : int
Year number that will... | [
"def",
"transition",
"(",
"self",
",",
"data",
",",
"year",
",",
"linked_tables",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'start: transition'",
")",
"linked_tables",
"=",
"linked_tables",
"or",
"{",
"}",
"updated_links",
"=",
"{",
"}",
"with",... | Add or remove rows from a table based on population targets.
Parameters
----------
data : pandas.DataFrame
Rows will be removed from or added to this table.
year : int
Year number that will be passed to `transitioner`.
linked_tables : dict of tuple, optio... | [
"Add",
"or",
"remove",
"rows",
"from",
"a",
"table",
"based",
"on",
"population",
"targets",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/transition.py#L486-L525 | train |
UDST/urbansim | urbansim/utils/yamlio.py | series_to_yaml_safe | def series_to_yaml_safe(series, ordered=False):
"""
Convert a pandas Series to a dict that will survive YAML serialization
and re-conversion back to a Series.
Parameters
----------
series : pandas.Series
ordered: bool, optional, default False
If True, an OrderedDict is returned.
... | python | def series_to_yaml_safe(series, ordered=False):
"""
Convert a pandas Series to a dict that will survive YAML serialization
and re-conversion back to a Series.
Parameters
----------
series : pandas.Series
ordered: bool, optional, default False
If True, an OrderedDict is returned.
... | [
"def",
"series_to_yaml_safe",
"(",
"series",
",",
"ordered",
"=",
"False",
")",
":",
"index",
"=",
"series",
".",
"index",
".",
"to_native_types",
"(",
"quoting",
"=",
"True",
")",
"values",
"=",
"series",
".",
"values",
".",
"tolist",
"(",
")",
"if",
... | Convert a pandas Series to a dict that will survive YAML serialization
and re-conversion back to a Series.
Parameters
----------
series : pandas.Series
ordered: bool, optional, default False
If True, an OrderedDict is returned.
Returns
-------
safe : dict or OrderedDict | [
"Convert",
"a",
"pandas",
"Series",
"to",
"a",
"dict",
"that",
"will",
"survive",
"YAML",
"serialization",
"and",
"re",
"-",
"conversion",
"back",
"to",
"a",
"Series",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/yamlio.py#L32-L55 | train |
UDST/urbansim | urbansim/utils/yamlio.py | frame_to_yaml_safe | def frame_to_yaml_safe(frame, ordered=False):
"""
Convert a pandas DataFrame to a dictionary that will survive
YAML serialization and re-conversion back to a DataFrame.
Parameters
----------
frame : pandas.DataFrame
ordered: bool, optional, default False
If True, an OrderedDict is r... | python | def frame_to_yaml_safe(frame, ordered=False):
"""
Convert a pandas DataFrame to a dictionary that will survive
YAML serialization and re-conversion back to a DataFrame.
Parameters
----------
frame : pandas.DataFrame
ordered: bool, optional, default False
If True, an OrderedDict is r... | [
"def",
"frame_to_yaml_safe",
"(",
"frame",
",",
"ordered",
"=",
"False",
")",
":",
"if",
"ordered",
":",
"return",
"OrderedDict",
"(",
"tuple",
"(",
"(",
"col",
",",
"series_to_yaml_safe",
"(",
"series",
",",
"True",
")",
")",
"for",
"col",
",",
"series"... | Convert a pandas DataFrame to a dictionary that will survive
YAML serialization and re-conversion back to a DataFrame.
Parameters
----------
frame : pandas.DataFrame
ordered: bool, optional, default False
If True, an OrderedDict is returned.
Returns
-------
safe : dict or Order... | [
"Convert",
"a",
"pandas",
"DataFrame",
"to",
"a",
"dictionary",
"that",
"will",
"survive",
"YAML",
"serialization",
"and",
"re",
"-",
"conversion",
"back",
"to",
"a",
"DataFrame",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/yamlio.py#L58-L79 | train |
UDST/urbansim | urbansim/utils/yamlio.py | ordered_yaml | def ordered_yaml(cfg, order=None):
"""
Convert a dictionary to a YAML string with preferential ordering
for some keys. Converted string is meant to be fairly human readable.
Parameters
----------
cfg : dict
Dictionary to convert to a YAML string.
order: list
If provided, ove... | python | def ordered_yaml(cfg, order=None):
"""
Convert a dictionary to a YAML string with preferential ordering
for some keys. Converted string is meant to be fairly human readable.
Parameters
----------
cfg : dict
Dictionary to convert to a YAML string.
order: list
If provided, ove... | [
"def",
"ordered_yaml",
"(",
"cfg",
",",
"order",
"=",
"None",
")",
":",
"if",
"order",
"is",
"None",
":",
"order",
"=",
"[",
"'name'",
",",
"'model_type'",
",",
"'segmentation_col'",
",",
"'fit_filters'",
",",
"'predict_filters'",
",",
"'choosers_fit_filters'"... | Convert a dictionary to a YAML string with preferential ordering
for some keys. Converted string is meant to be fairly human readable.
Parameters
----------
cfg : dict
Dictionary to convert to a YAML string.
order: list
If provided, overrides the default key ordering.
Returns
... | [
"Convert",
"a",
"dictionary",
"to",
"a",
"YAML",
"string",
"with",
"preferential",
"ordering",
"for",
"some",
"keys",
".",
"Converted",
"string",
"is",
"meant",
"to",
"be",
"fairly",
"human",
"readable",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/yamlio.py#L92-L134 | train |
UDST/urbansim | urbansim/utils/yamlio.py | convert_to_yaml | def convert_to_yaml(cfg, str_or_buffer):
"""
Convert a dictionary to YAML and return the string or write it out
depending on the type of `str_or_buffer`.
Parameters
----------
cfg : dict or OrderedDict
Dictionary or OrderedDict to convert.
str_or_buffer : None, str, or buffer
... | python | def convert_to_yaml(cfg, str_or_buffer):
"""
Convert a dictionary to YAML and return the string or write it out
depending on the type of `str_or_buffer`.
Parameters
----------
cfg : dict or OrderedDict
Dictionary or OrderedDict to convert.
str_or_buffer : None, str, or buffer
... | [
"def",
"convert_to_yaml",
"(",
"cfg",
",",
"str_or_buffer",
")",
":",
"order",
"=",
"None",
"if",
"isinstance",
"(",
"cfg",
",",
"OrderedDict",
")",
":",
"order",
"=",
"[",
"]",
"s",
"=",
"ordered_yaml",
"(",
"cfg",
",",
"order",
")",
"if",
"not",
"s... | Convert a dictionary to YAML and return the string or write it out
depending on the type of `str_or_buffer`.
Parameters
----------
cfg : dict or OrderedDict
Dictionary or OrderedDict to convert.
str_or_buffer : None, str, or buffer
If None: the YAML string will be returned.
... | [
"Convert",
"a",
"dictionary",
"to",
"YAML",
"and",
"return",
"the",
"string",
"or",
"write",
"it",
"out",
"depending",
"on",
"the",
"type",
"of",
"str_or_buffer",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/utils/yamlio.py#L160-L193 | train |
UDST/urbansim | urbansim/accounts.py | Account.add_transaction | def add_transaction(self, amount, subaccount=None, metadata=None):
"""
Add a new transaction to the account.
Parameters
----------
amount : float
Negative for withdrawls, positive for deposits.
subaccount : object, optional
Any indicator of a suba... | python | def add_transaction(self, amount, subaccount=None, metadata=None):
"""
Add a new transaction to the account.
Parameters
----------
amount : float
Negative for withdrawls, positive for deposits.
subaccount : object, optional
Any indicator of a suba... | [
"def",
"add_transaction",
"(",
"self",
",",
"amount",
",",
"subaccount",
"=",
"None",
",",
"metadata",
"=",
"None",
")",
":",
"metadata",
"=",
"metadata",
"or",
"{",
"}",
"self",
".",
"transactions",
".",
"append",
"(",
"Transaction",
"(",
"amount",
",",... | Add a new transaction to the account.
Parameters
----------
amount : float
Negative for withdrawls, positive for deposits.
subaccount : object, optional
Any indicator of a subaccount to which this transaction applies.
metadata : dict, optional
... | [
"Add",
"a",
"new",
"transaction",
"to",
"the",
"account",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/accounts.py#L57-L75 | train |
UDST/urbansim | urbansim/accounts.py | Account.total_transactions_by_subacct | def total_transactions_by_subacct(self, subaccount):
"""
Get the sum of all transactions for a given subaccount.
Parameters
----------
subaccount : object
Identifier of subaccount.
Returns
-------
total : float
"""
return sum... | python | def total_transactions_by_subacct(self, subaccount):
"""
Get the sum of all transactions for a given subaccount.
Parameters
----------
subaccount : object
Identifier of subaccount.
Returns
-------
total : float
"""
return sum... | [
"def",
"total_transactions_by_subacct",
"(",
"self",
",",
"subaccount",
")",
":",
"return",
"sum",
"(",
"t",
".",
"amount",
"for",
"t",
"in",
"self",
".",
"transactions",
"if",
"t",
".",
"subaccount",
"==",
"subaccount",
")"
] | Get the sum of all transactions for a given subaccount.
Parameters
----------
subaccount : object
Identifier of subaccount.
Returns
-------
total : float | [
"Get",
"the",
"sum",
"of",
"all",
"transactions",
"for",
"a",
"given",
"subaccount",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/accounts.py#L102-L117 | train |
UDST/urbansim | urbansim/accounts.py | Account.to_frame | def to_frame(self):
"""
Return transactions as a pandas DataFrame.
"""
col_names = _column_names_from_metadata(
t.metadata for t in self.transactions)
def trow(t):
return tz.concatv(
(t.amount, t.subaccount),
(t.metadata.g... | python | def to_frame(self):
"""
Return transactions as a pandas DataFrame.
"""
col_names = _column_names_from_metadata(
t.metadata for t in self.transactions)
def trow(t):
return tz.concatv(
(t.amount, t.subaccount),
(t.metadata.g... | [
"def",
"to_frame",
"(",
"self",
")",
":",
"col_names",
"=",
"_column_names_from_metadata",
"(",
"t",
".",
"metadata",
"for",
"t",
"in",
"self",
".",
"transactions",
")",
"def",
"trow",
"(",
"t",
")",
":",
"return",
"tz",
".",
"concatv",
"(",
"(",
"t",
... | Return transactions as a pandas DataFrame. | [
"Return",
"transactions",
"as",
"a",
"pandas",
"DataFrame",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/accounts.py#L136-L153 | train |
UDST/urbansim | urbansim/models/util.py | apply_filter_query | def apply_filter_query(df, filters=None):
"""
Use the DataFrame.query method to filter a table down to the
desired rows.
Parameters
----------
df : pandas.DataFrame
filters : list of str or str, optional
List of filters to apply. Will be joined together with
' and ' and pass... | python | def apply_filter_query(df, filters=None):
"""
Use the DataFrame.query method to filter a table down to the
desired rows.
Parameters
----------
df : pandas.DataFrame
filters : list of str or str, optional
List of filters to apply. Will be joined together with
' and ' and pass... | [
"def",
"apply_filter_query",
"(",
"df",
",",
"filters",
"=",
"None",
")",
":",
"with",
"log_start_finish",
"(",
"'apply filter query: {!r}'",
".",
"format",
"(",
"filters",
")",
",",
"logger",
")",
":",
"if",
"filters",
":",
"if",
"isinstance",
"(",
"filters... | Use the DataFrame.query method to filter a table down to the
desired rows.
Parameters
----------
df : pandas.DataFrame
filters : list of str or str, optional
List of filters to apply. Will be joined together with
' and ' and passed to DataFrame.query. A string will be passed
... | [
"Use",
"the",
"DataFrame",
".",
"query",
"method",
"to",
"filter",
"a",
"table",
"down",
"to",
"the",
"desired",
"rows",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L24-L51 | train |
UDST/urbansim | urbansim/models/util.py | _filterize | def _filterize(name, value):
"""
Turn a `name` and `value` into a string expression compatible
the ``DataFrame.query`` method.
Parameters
----------
name : str
Should be the name of a column in the table to which the
filter will be applied.
A suffix of '_max' will resul... | python | def _filterize(name, value):
"""
Turn a `name` and `value` into a string expression compatible
the ``DataFrame.query`` method.
Parameters
----------
name : str
Should be the name of a column in the table to which the
filter will be applied.
A suffix of '_max' will resul... | [
"def",
"_filterize",
"(",
"name",
",",
"value",
")",
":",
"if",
"name",
".",
"endswith",
"(",
"'_min'",
")",
":",
"name",
"=",
"name",
"[",
":",
"-",
"4",
"]",
"comp",
"=",
"'>='",
"elif",
"name",
".",
"endswith",
"(",
"'_max'",
")",
":",
"name",... | Turn a `name` and `value` into a string expression compatible
the ``DataFrame.query`` method.
Parameters
----------
name : str
Should be the name of a column in the table to which the
filter will be applied.
A suffix of '_max' will result in a "less than" filter,
a suff... | [
"Turn",
"a",
"name",
"and",
"value",
"into",
"a",
"string",
"expression",
"compatible",
"the",
"DataFrame",
".",
"query",
"method",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L54-L89 | train |
UDST/urbansim | urbansim/models/util.py | str_model_expression | def str_model_expression(expr, add_constant=True):
"""
We support specifying model expressions as strings, lists, or dicts;
but for use with patsy and statsmodels we need a string.
This function will take any of those as input and return a string.
Parameters
----------
expr : str, iterable,... | python | def str_model_expression(expr, add_constant=True):
"""
We support specifying model expressions as strings, lists, or dicts;
but for use with patsy and statsmodels we need a string.
This function will take any of those as input and return a string.
Parameters
----------
expr : str, iterable,... | [
"def",
"str_model_expression",
"(",
"expr",
",",
"add_constant",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"expr",
",",
"str",
")",
":",
"if",
"isinstance",
"(",
"expr",
",",
"collections",
".",
"Mapping",
")",
":",
"left_side",
"=",
"expr",... | We support specifying model expressions as strings, lists, or dicts;
but for use with patsy and statsmodels we need a string.
This function will take any of those as input and return a string.
Parameters
----------
expr : str, iterable, or dict
A string will be returned unmodified except to... | [
"We",
"support",
"specifying",
"model",
"expressions",
"as",
"strings",
"lists",
"or",
"dicts",
";",
"but",
"for",
"use",
"with",
"patsy",
"and",
"statsmodels",
"we",
"need",
"a",
"string",
".",
"This",
"function",
"will",
"take",
"any",
"of",
"those",
"as... | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L174-L227 | train |
UDST/urbansim | urbansim/models/util.py | sorted_groupby | def sorted_groupby(df, groupby):
"""
Perform a groupby on a DataFrame using a specific column
and assuming that that column is sorted.
Parameters
----------
df : pandas.DataFrame
groupby : object
Column name on which to groupby. This column must be sorted.
Returns
-------
... | python | def sorted_groupby(df, groupby):
"""
Perform a groupby on a DataFrame using a specific column
and assuming that that column is sorted.
Parameters
----------
df : pandas.DataFrame
groupby : object
Column name on which to groupby. This column must be sorted.
Returns
-------
... | [
"def",
"sorted_groupby",
"(",
"df",
",",
"groupby",
")",
":",
"start",
"=",
"0",
"prev",
"=",
"df",
"[",
"groupby",
"]",
".",
"iloc",
"[",
"start",
"]",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"df",
"[",
"groupby",
"]",
")",
":",
"if",
"x... | Perform a groupby on a DataFrame using a specific column
and assuming that that column is sorted.
Parameters
----------
df : pandas.DataFrame
groupby : object
Column name on which to groupby. This column must be sorted.
Returns
-------
generator
Yields pairs of group_na... | [
"Perform",
"a",
"groupby",
"on",
"a",
"DataFrame",
"using",
"a",
"specific",
"column",
"and",
"assuming",
"that",
"that",
"column",
"is",
"sorted",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L230-L255 | train |
UDST/urbansim | urbansim/models/util.py | columns_in_filters | def columns_in_filters(filters):
"""
Returns a list of the columns used in a set of query filters.
Parameters
----------
filters : list of str or str
List of the filters as passed passed to ``apply_filter_query``.
Returns
-------
columns : list of str
List of all the st... | python | def columns_in_filters(filters):
"""
Returns a list of the columns used in a set of query filters.
Parameters
----------
filters : list of str or str
List of the filters as passed passed to ``apply_filter_query``.
Returns
-------
columns : list of str
List of all the st... | [
"def",
"columns_in_filters",
"(",
"filters",
")",
":",
"if",
"not",
"filters",
":",
"return",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"filters",
",",
"str",
")",
":",
"filters",
"=",
"' '",
".",
"join",
"(",
"filters",
")",
"columns",
"=",
"[",
"]"... | Returns a list of the columns used in a set of query filters.
Parameters
----------
filters : list of str or str
List of the filters as passed passed to ``apply_filter_query``.
Returns
-------
columns : list of str
List of all the strings mentioned in the filters. | [
"Returns",
"a",
"list",
"of",
"the",
"columns",
"used",
"in",
"a",
"set",
"of",
"query",
"filters",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L258-L286 | train |
UDST/urbansim | urbansim/models/util.py | _tokens_from_patsy | def _tokens_from_patsy(node):
"""
Yields all the individual tokens from within a patsy formula
as parsed by patsy.parse_formula.parse_formula.
Parameters
----------
node : patsy.parse_formula.ParseNode
"""
for n in node.args:
for t in _tokens_from_patsy(n):
yield t
... | python | def _tokens_from_patsy(node):
"""
Yields all the individual tokens from within a patsy formula
as parsed by patsy.parse_formula.parse_formula.
Parameters
----------
node : patsy.parse_formula.ParseNode
"""
for n in node.args:
for t in _tokens_from_patsy(n):
yield t
... | [
"def",
"_tokens_from_patsy",
"(",
"node",
")",
":",
"for",
"n",
"in",
"node",
".",
"args",
":",
"for",
"t",
"in",
"_tokens_from_patsy",
"(",
"n",
")",
":",
"yield",
"t",
"if",
"node",
".",
"token",
":",
"yield",
"node",
".",
"token"
] | Yields all the individual tokens from within a patsy formula
as parsed by patsy.parse_formula.parse_formula.
Parameters
----------
node : patsy.parse_formula.ParseNode | [
"Yields",
"all",
"the",
"individual",
"tokens",
"from",
"within",
"a",
"patsy",
"formula",
"as",
"parsed",
"by",
"patsy",
".",
"parse_formula",
".",
"parse_formula",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L289-L304 | train |
UDST/urbansim | urbansim/models/util.py | columns_in_formula | def columns_in_formula(formula):
"""
Returns the names of all the columns used in a patsy formula.
Parameters
----------
formula : str, iterable, or dict
Any formula construction supported by ``str_model_expression``.
Returns
-------
columns : list of str
"""
if formul... | python | def columns_in_formula(formula):
"""
Returns the names of all the columns used in a patsy formula.
Parameters
----------
formula : str, iterable, or dict
Any formula construction supported by ``str_model_expression``.
Returns
-------
columns : list of str
"""
if formul... | [
"def",
"columns_in_formula",
"(",
"formula",
")",
":",
"if",
"formula",
"is",
"None",
":",
"return",
"[",
"]",
"formula",
"=",
"str_model_expression",
"(",
"formula",
",",
"add_constant",
"=",
"False",
")",
"columns",
"=",
"[",
"]",
"tokens",
"=",
"map",
... | Returns the names of all the columns used in a patsy formula.
Parameters
----------
formula : str, iterable, or dict
Any formula construction supported by ``str_model_expression``.
Returns
-------
columns : list of str | [
"Returns",
"the",
"names",
"of",
"all",
"the",
"columns",
"used",
"in",
"a",
"patsy",
"formula",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/util.py#L307-L347 | train |
UDST/urbansim | urbansim/models/regression.py | fit_model | def fit_model(df, filters, model_expression):
"""
Use statsmodels OLS to construct a model relation.
Parameters
----------
df : pandas.DataFrame
Data to use for fit. Should contain all the columns
referenced in the `model_expression`.
filters : list of str
Any filters to... | python | def fit_model(df, filters, model_expression):
"""
Use statsmodels OLS to construct a model relation.
Parameters
----------
df : pandas.DataFrame
Data to use for fit. Should contain all the columns
referenced in the `model_expression`.
filters : list of str
Any filters to... | [
"def",
"fit_model",
"(",
"df",
",",
"filters",
",",
"model_expression",
")",
":",
"df",
"=",
"util",
".",
"apply_filter_query",
"(",
"df",
",",
"filters",
")",
"model",
"=",
"smf",
".",
"ols",
"(",
"formula",
"=",
"model_expression",
",",
"data",
"=",
... | Use statsmodels OLS to construct a model relation.
Parameters
----------
df : pandas.DataFrame
Data to use for fit. Should contain all the columns
referenced in the `model_expression`.
filters : list of str
Any filters to apply before doing the model fit.
model_expression : ... | [
"Use",
"statsmodels",
"OLS",
"to",
"construct",
"a",
"model",
"relation",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L25-L55 | train |
UDST/urbansim | urbansim/models/regression.py | predict | def predict(df, filters, model_fit, ytransform=None):
"""
Apply model to new data to predict new dependent values.
Parameters
----------
df : pandas.DataFrame
filters : list of str
Any filters to apply before doing prediction.
model_fit : statsmodels.regression.linear_model.OLSResul... | python | def predict(df, filters, model_fit, ytransform=None):
"""
Apply model to new data to predict new dependent values.
Parameters
----------
df : pandas.DataFrame
filters : list of str
Any filters to apply before doing prediction.
model_fit : statsmodels.regression.linear_model.OLSResul... | [
"def",
"predict",
"(",
"df",
",",
"filters",
",",
"model_fit",
",",
"ytransform",
"=",
"None",
")",
":",
"df",
"=",
"util",
".",
"apply_filter_query",
"(",
"df",
",",
"filters",
")",
"with",
"log_start_finish",
"(",
"'statsmodels predict'",
",",
"logger",
... | Apply model to new data to predict new dependent values.
Parameters
----------
df : pandas.DataFrame
filters : list of str
Any filters to apply before doing prediction.
model_fit : statsmodels.regression.linear_model.OLSResults
Result of model estimation.
ytransform : callable, ... | [
"Apply",
"model",
"to",
"new",
"data",
"to",
"predict",
"new",
"dependent",
"values",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L58-L97 | train |
UDST/urbansim | urbansim/models/regression.py | _model_fit_to_table | def _model_fit_to_table(fit):
"""
Produce a pandas DataFrame of model fit results from a statsmodels
fit result object.
Parameters
----------
fit : statsmodels.regression.linear_model.RegressionResults
Returns
-------
fit_parameters : pandas.DataFrame
Will have columns 'Coe... | python | def _model_fit_to_table(fit):
"""
Produce a pandas DataFrame of model fit results from a statsmodels
fit result object.
Parameters
----------
fit : statsmodels.regression.linear_model.RegressionResults
Returns
-------
fit_parameters : pandas.DataFrame
Will have columns 'Coe... | [
"def",
"_model_fit_to_table",
"(",
"fit",
")",
":",
"fit_parameters",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"'Coefficient'",
":",
"fit",
".",
"params",
",",
"'Std. Error'",
":",
"fit",
".",
"bse",
",",
"'T-Score'",
":",
"fit",
".",
"tvalues",
"}",
")",
... | Produce a pandas DataFrame of model fit results from a statsmodels
fit result object.
Parameters
----------
fit : statsmodels.regression.linear_model.RegressionResults
Returns
-------
fit_parameters : pandas.DataFrame
Will have columns 'Coefficient', 'Std. Error', and 'T-Score'.
... | [
"Produce",
"a",
"pandas",
"DataFrame",
"of",
"model",
"fit",
"results",
"from",
"a",
"statsmodels",
"fit",
"result",
"object",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L178-L204 | train |
UDST/urbansim | urbansim/models/regression.py | _FakeRegressionResults.predict | def predict(self, data):
"""
Predict new values by running data through the fit model.
Parameters
----------
data : pandas.DataFrame
Table with columns corresponding to the RHS of `model_expression`.
Returns
-------
predicted : ndarray
... | python | def predict(self, data):
"""
Predict new values by running data through the fit model.
Parameters
----------
data : pandas.DataFrame
Table with columns corresponding to the RHS of `model_expression`.
Returns
-------
predicted : ndarray
... | [
"def",
"predict",
"(",
"self",
",",
"data",
")",
":",
"with",
"log_start_finish",
"(",
"'_FakeRegressionResults prediction'",
",",
"logger",
")",
":",
"model_design",
"=",
"dmatrix",
"(",
"self",
".",
"_rhs",
",",
"data",
"=",
"data",
",",
"return_type",
"="... | Predict new values by running data through the fit model.
Parameters
----------
data : pandas.DataFrame
Table with columns corresponding to the RHS of `model_expression`.
Returns
-------
predicted : ndarray
Array of predicted values. | [
"Predict",
"new",
"values",
"by",
"running",
"data",
"through",
"the",
"fit",
"model",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L157-L175 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModel.from_yaml | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a RegressionModel instance from a saved YAML configuration.
Arguments are mutually exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
str_... | python | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a RegressionModel instance from a saved YAML configuration.
Arguments are mutually exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
str_... | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_str",
"=",
"None",
",",
"str_or_buffer",
"=",
"None",
")",
":",
"cfg",
"=",
"yamlio",
".",
"yaml_to_dict",
"(",
"yaml_str",
",",
"str_or_buffer",
")",
"model",
"=",
"cls",
"(",
"cfg",
"[",
"'fit_filters'",
"]",
... | Create a RegressionModel instance from a saved YAML configuration.
Arguments are mutually exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
str_or_buffer : str or file like, optional
File name or buffer from... | [
"Create",
"a",
"RegressionModel",
"instance",
"from",
"a",
"saved",
"YAML",
"configuration",
".",
"Arguments",
"are",
"mutually",
"exclusive",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L260-L298 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModel.predict | def predict(self, data):
"""
Predict a new data set based on an estimated model.
Parameters
----------
data : pandas.DataFrame
Data to use for prediction. Must contain all the columns
referenced by the right-hand side of the `model_expression`.
R... | python | def predict(self, data):
"""
Predict a new data set based on an estimated model.
Parameters
----------
data : pandas.DataFrame
Data to use for prediction. Must contain all the columns
referenced by the right-hand side of the `model_expression`.
R... | [
"def",
"predict",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"assert_fitted",
"(",
")",
"with",
"log_start_finish",
"(",
"'predicting model {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
",",
"logger",
")",
":",
"return",
"predict",
"(",
"data... | Predict a new data set based on an estimated model.
Parameters
----------
data : pandas.DataFrame
Data to use for prediction. Must contain all the columns
referenced by the right-hand side of the `model_expression`.
Returns
-------
result : panda... | [
"Predict",
"a",
"new",
"data",
"set",
"based",
"on",
"an",
"estimated",
"model",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L390-L410 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModel.to_dict | def to_dict(self):
"""
Returns a dictionary representation of a RegressionModel instance.
"""
d = {
'model_type': 'regression',
'name': self.name,
'fit_filters': self.fit_filters,
'predict_filters': self.predict_filters,
'model... | python | def to_dict(self):
"""
Returns a dictionary representation of a RegressionModel instance.
"""
d = {
'model_type': 'regression',
'name': self.name,
'fit_filters': self.fit_filters,
'predict_filters': self.predict_filters,
'model... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"'model_type'",
":",
"'regression'",
",",
"'name'",
":",
"self",
".",
"name",
",",
"'fit_filters'",
":",
"self",
".",
"fit_filters",
",",
"'predict_filters'",
":",
"self",
".",
"predict_filters",
",",... | Returns a dictionary representation of a RegressionModel instance. | [
"Returns",
"a",
"dictionary",
"representation",
"of",
"a",
"RegressionModel",
"instance",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L412-L436 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModel.columns_used | def columns_used(self):
"""
Returns all the columns used in this model for filtering
and in the model expression.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.fit_filters),
util.columns_in_filters(self.predict_filters),
u... | python | def columns_used(self):
"""
Returns all the columns used in this model for filtering
and in the model expression.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.fit_filters),
util.columns_in_filters(self.predict_filters),
u... | [
"def",
"columns_used",
"(",
"self",
")",
":",
"return",
"list",
"(",
"tz",
".",
"unique",
"(",
"tz",
".",
"concatv",
"(",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
"fit_filters",
")",
",",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
... | Returns all the columns used in this model for filtering
and in the model expression. | [
"Returns",
"all",
"the",
"columns",
"used",
"in",
"this",
"model",
"for",
"filtering",
"and",
"in",
"the",
"model",
"expression",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L460-L469 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModelGroup.add_model | def add_model(self, model):
"""
Add a `RegressionModel` instance.
Parameters
----------
model : `RegressionModel`
Should have a ``.name`` attribute matching one of
the groupby segments.
"""
logger.debug(
'adding model {} to gr... | python | def add_model(self, model):
"""
Add a `RegressionModel` instance.
Parameters
----------
model : `RegressionModel`
Should have a ``.name`` attribute matching one of
the groupby segments.
"""
logger.debug(
'adding model {} to gr... | [
"def",
"add_model",
"(",
"self",
",",
"model",
")",
":",
"logger",
".",
"debug",
"(",
"'adding model {} to group {}'",
".",
"format",
"(",
"model",
".",
"name",
",",
"self",
".",
"name",
")",
")",
"self",
".",
"models",
"[",
"model",
".",
"name",
"]",
... | Add a `RegressionModel` instance.
Parameters
----------
model : `RegressionModel`
Should have a ``.name`` attribute matching one of
the groupby segments. | [
"Add",
"a",
"RegressionModel",
"instance",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L546-L559 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModelGroup.add_model_from_params | def add_model_from_params(self, name, fit_filters, predict_filters,
model_expression, ytransform=None):
"""
Add a model by passing arguments through to `RegressionModel`.
Parameters
----------
name : any
Must match a groupby segment name... | python | def add_model_from_params(self, name, fit_filters, predict_filters,
model_expression, ytransform=None):
"""
Add a model by passing arguments through to `RegressionModel`.
Parameters
----------
name : any
Must match a groupby segment name... | [
"def",
"add_model_from_params",
"(",
"self",
",",
"name",
",",
"fit_filters",
",",
"predict_filters",
",",
"model_expression",
",",
"ytransform",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'adding model {} to group {}'",
".",
"format",
"(",
"name",
","... | Add a model by passing arguments through to `RegressionModel`.
Parameters
----------
name : any
Must match a groupby segment name.
fit_filters : list of str
Filters applied before fitting the model.
predict_filters : list of str
Filters applie... | [
"Add",
"a",
"model",
"by",
"passing",
"arguments",
"through",
"to",
"RegressionModel",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L561-L590 | train |
UDST/urbansim | urbansim/models/regression.py | RegressionModelGroup.fit | def fit(self, data, debug=False):
"""
Fit each of the models in the group.
Parameters
----------
data : pandas.DataFrame
Must have a column with the same name as `segmentation_col`.
debug : bool
If set to true (default false) will pass the debug p... | python | def fit(self, data, debug=False):
"""
Fit each of the models in the group.
Parameters
----------
data : pandas.DataFrame
Must have a column with the same name as `segmentation_col`.
debug : bool
If set to true (default false) will pass the debug p... | [
"def",
"fit",
"(",
"self",
",",
"data",
",",
"debug",
"=",
"False",
")",
":",
"with",
"log_start_finish",
"(",
"'fitting models in group {}'",
".",
"format",
"(",
"self",
".",
"name",
")",
",",
"logger",
")",
":",
"return",
"{",
"name",
":",
"self",
".... | Fit each of the models in the group.
Parameters
----------
data : pandas.DataFrame
Must have a column with the same name as `segmentation_col`.
debug : bool
If set to true (default false) will pass the debug parameter
to model estimation.
Ret... | [
"Fit",
"each",
"of",
"the",
"models",
"in",
"the",
"group",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L612-L633 | train |
UDST/urbansim | urbansim/models/regression.py | SegmentedRegressionModel.from_yaml | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a SegmentedRegressionModel instance from a saved YAML
configuration. Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
... | python | def from_yaml(cls, yaml_str=None, str_or_buffer=None):
"""
Create a SegmentedRegressionModel instance from a saved YAML
configuration. Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
... | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_str",
"=",
"None",
",",
"str_or_buffer",
"=",
"None",
")",
":",
"cfg",
"=",
"yamlio",
".",
"yaml_to_dict",
"(",
"yaml_str",
",",
"str_or_buffer",
")",
"default_model_expr",
"=",
"cfg",
"[",
"'default_config'",
"]",
... | Create a SegmentedRegressionModel instance from a saved YAML
configuration. Arguments are mutally exclusive.
Parameters
----------
yaml_str : str, optional
A YAML string from which to load model.
str_or_buffer : str or file like, optional
File name or buf... | [
"Create",
"a",
"SegmentedRegressionModel",
"instance",
"from",
"a",
"saved",
"YAML",
"configuration",
".",
"Arguments",
"are",
"mutally",
"exclusive",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L726-L768 | train |
UDST/urbansim | urbansim/models/regression.py | SegmentedRegressionModel.add_segment | def add_segment(self, name, model_expression=None, ytransform='default'):
"""
Add a new segment with its own model expression and ytransform.
Parameters
----------
name :
Segment name. Must match a segment in the groupby of the data.
model_expression : str or... | python | def add_segment(self, name, model_expression=None, ytransform='default'):
"""
Add a new segment with its own model expression and ytransform.
Parameters
----------
name :
Segment name. Must match a segment in the groupby of the data.
model_expression : str or... | [
"def",
"add_segment",
"(",
"self",
",",
"name",
",",
"model_expression",
"=",
"None",
",",
"ytransform",
"=",
"'default'",
")",
":",
"if",
"not",
"model_expression",
":",
"if",
"self",
".",
"default_model_expr",
"is",
"None",
":",
"raise",
"ValueError",
"(",... | Add a new segment with its own model expression and ytransform.
Parameters
----------
name :
Segment name. Must match a segment in the groupby of the data.
model_expression : str or dict, optional
A patsy model expression that can be used with statsmodels.
... | [
"Add",
"a",
"new",
"segment",
"with",
"its",
"own",
"model",
"expression",
"and",
"ytransform",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L770-L806 | train |
UDST/urbansim | urbansim/models/regression.py | SegmentedRegressionModel.fit | def fit(self, data, debug=False):
"""
Fit each segment. Segments that have not already been explicitly
added will be automatically added with default model and ytransform.
Parameters
----------
data : pandas.DataFrame
Must have a column with the same name as ... | python | def fit(self, data, debug=False):
"""
Fit each segment. Segments that have not already been explicitly
added will be automatically added with default model and ytransform.
Parameters
----------
data : pandas.DataFrame
Must have a column with the same name as ... | [
"def",
"fit",
"(",
"self",
",",
"data",
",",
"debug",
"=",
"False",
")",
":",
"data",
"=",
"util",
".",
"apply_filter_query",
"(",
"data",
",",
"self",
".",
"fit_filters",
")",
"unique",
"=",
"data",
"[",
"self",
".",
"segmentation_col",
"]",
".",
"u... | Fit each segment. Segments that have not already been explicitly
added will be automatically added with default model and ytransform.
Parameters
----------
data : pandas.DataFrame
Must have a column with the same name as `segmentation_col`.
debug : bool
I... | [
"Fit",
"each",
"segment",
".",
"Segments",
"that",
"have",
"not",
"already",
"been",
"explicitly",
"added",
"will",
"be",
"automatically",
"added",
"with",
"default",
"model",
"and",
"ytransform",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L808-L847 | train |
UDST/urbansim | urbansim/models/regression.py | SegmentedRegressionModel.columns_used | def columns_used(self):
"""
Returns all the columns used across all models in the group
for filtering and in the model expression.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.fit_filters),
util.columns_in_filters(self.predict_filter... | python | def columns_used(self):
"""
Returns all the columns used across all models in the group
for filtering and in the model expression.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.fit_filters),
util.columns_in_filters(self.predict_filter... | [
"def",
"columns_used",
"(",
"self",
")",
":",
"return",
"list",
"(",
"tz",
".",
"unique",
"(",
"tz",
".",
"concatv",
"(",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
"fit_filters",
")",
",",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
... | Returns all the columns used across all models in the group
for filtering and in the model expression. | [
"Returns",
"all",
"the",
"columns",
"used",
"across",
"all",
"models",
"in",
"the",
"group",
"for",
"filtering",
"and",
"in",
"the",
"model",
"expression",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L956-L967 | train |
UDST/urbansim | urbansim/models/relocation.py | find_movers | def find_movers(choosers, rates, rate_column):
"""
Returns an array of the indexes of the `choosers` that are slated
to move.
Parameters
----------
choosers : pandas.DataFrame
Table of agents from which to find movers.
rates : pandas.DataFrame
Table of relocation rates. Inde... | python | def find_movers(choosers, rates, rate_column):
"""
Returns an array of the indexes of the `choosers` that are slated
to move.
Parameters
----------
choosers : pandas.DataFrame
Table of agents from which to find movers.
rates : pandas.DataFrame
Table of relocation rates. Inde... | [
"def",
"find_movers",
"(",
"choosers",
",",
"rates",
",",
"rate_column",
")",
":",
"logger",
".",
"debug",
"(",
"'start: find movers for relocation'",
")",
"relocation_rates",
"=",
"pd",
".",
"Series",
"(",
"np",
".",
"zeros",
"(",
"len",
"(",
"choosers",
")... | Returns an array of the indexes of the `choosers` that are slated
to move.
Parameters
----------
choosers : pandas.DataFrame
Table of agents from which to find movers.
rates : pandas.DataFrame
Table of relocation rates. Index is unused.
Other columns describe filters on the... | [
"Returns",
"an",
"array",
"of",
"the",
"indexes",
"of",
"the",
"choosers",
"that",
"are",
"slated",
"to",
"move",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/relocation.py#L16-L67 | train |
UDST/urbansim | urbansim/models/supplydemand.py | _calculate_adjustment | def _calculate_adjustment(
lcm, choosers, alternatives, alt_segmenter,
clip_change_low, clip_change_high, multiplier_func=None):
"""
Calculate adjustments to prices to compensate for
supply and demand effects.
Parameters
----------
lcm : LocationChoiceModel
Used to calcu... | python | def _calculate_adjustment(
lcm, choosers, alternatives, alt_segmenter,
clip_change_low, clip_change_high, multiplier_func=None):
"""
Calculate adjustments to prices to compensate for
supply and demand effects.
Parameters
----------
lcm : LocationChoiceModel
Used to calcu... | [
"def",
"_calculate_adjustment",
"(",
"lcm",
",",
"choosers",
",",
"alternatives",
",",
"alt_segmenter",
",",
"clip_change_low",
",",
"clip_change_high",
",",
"multiplier_func",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'start: calculate supply and demand pr... | Calculate adjustments to prices to compensate for
supply and demand effects.
Parameters
----------
lcm : LocationChoiceModel
Used to calculate the probability of agents choosing among
alternatives. Must be fully configured and fitted.
choosers : pandas.DataFrame
alternatives : p... | [
"Calculate",
"adjustments",
"to",
"prices",
"to",
"compensate",
"for",
"supply",
"and",
"demand",
"effects",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/supplydemand.py#L15-L81 | train |
UDST/urbansim | urbansim/models/supplydemand.py | supply_and_demand | def supply_and_demand(
lcm, choosers, alternatives, alt_segmenter, price_col,
base_multiplier=None, clip_change_low=0.75, clip_change_high=1.25,
iterations=5, multiplier_func=None):
"""
Adjust real estate prices to compensate for supply and demand effects.
Parameters
----------
... | python | def supply_and_demand(
lcm, choosers, alternatives, alt_segmenter, price_col,
base_multiplier=None, clip_change_low=0.75, clip_change_high=1.25,
iterations=5, multiplier_func=None):
"""
Adjust real estate prices to compensate for supply and demand effects.
Parameters
----------
... | [
"def",
"supply_and_demand",
"(",
"lcm",
",",
"choosers",
",",
"alternatives",
",",
"alt_segmenter",
",",
"price_col",
",",
"base_multiplier",
"=",
"None",
",",
"clip_change_low",
"=",
"0.75",
",",
"clip_change_high",
"=",
"1.25",
",",
"iterations",
"=",
"5",
"... | Adjust real estate prices to compensate for supply and demand effects.
Parameters
----------
lcm : LocationChoiceModel
Used to calculate the probability of agents choosing among
alternatives. Must be fully configured and fitted.
choosers : pandas.DataFrame
alternatives : pandas.Data... | [
"Adjust",
"real",
"estate",
"prices",
"to",
"compensate",
"for",
"supply",
"and",
"demand",
"effects",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/supplydemand.py#L84-L173 | train |
UDST/urbansim | urbansim/developer/developer.py | Developer._max_form | def _max_form(f, colname):
"""
Assumes dataframe with hierarchical columns with first index equal to the
use and second index equal to the attribute.
e.g. f.columns equal to::
mixedoffice building_cost
building_revenue
b... | python | def _max_form(f, colname):
"""
Assumes dataframe with hierarchical columns with first index equal to the
use and second index equal to the attribute.
e.g. f.columns equal to::
mixedoffice building_cost
building_revenue
b... | [
"def",
"_max_form",
"(",
"f",
",",
"colname",
")",
":",
"df",
"=",
"f",
".",
"stack",
"(",
"level",
"=",
"0",
")",
"[",
"[",
"colname",
"]",
"]",
".",
"stack",
"(",
")",
".",
"unstack",
"(",
"level",
"=",
"1",
")",
".",
"reset_index",
"(",
"l... | Assumes dataframe with hierarchical columns with first index equal to the
use and second index equal to the attribute.
e.g. f.columns equal to::
mixedoffice building_cost
building_revenue
building_size
max_prof... | [
"Assumes",
"dataframe",
"with",
"hierarchical",
"columns",
"with",
"first",
"index",
"equal",
"to",
"the",
"use",
"and",
"second",
"index",
"equal",
"to",
"the",
"attribute",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/developer.py#L23-L44 | train |
UDST/urbansim | urbansim/developer/developer.py | Developer.keep_form_with_max_profit | def keep_form_with_max_profit(self, forms=None):
"""
This converts the dataframe, which shows all profitable forms,
to the form with the greatest profit, so that more profitable
forms outcompete less profitable forms.
Parameters
----------
forms: list of strings
... | python | def keep_form_with_max_profit(self, forms=None):
"""
This converts the dataframe, which shows all profitable forms,
to the form with the greatest profit, so that more profitable
forms outcompete less profitable forms.
Parameters
----------
forms: list of strings
... | [
"def",
"keep_form_with_max_profit",
"(",
"self",
",",
"forms",
"=",
"None",
")",
":",
"f",
"=",
"self",
".",
"feasibility",
"if",
"forms",
"is",
"not",
"None",
":",
"f",
"=",
"f",
"[",
"forms",
"]",
"if",
"len",
"(",
"f",
")",
">",
"0",
":",
"mu"... | This converts the dataframe, which shows all profitable forms,
to the form with the greatest profit, so that more profitable
forms outcompete less profitable forms.
Parameters
----------
forms: list of strings
List of forms which compete which other. Can leave some ... | [
"This",
"converts",
"the",
"dataframe",
"which",
"shows",
"all",
"profitable",
"forms",
"to",
"the",
"form",
"with",
"the",
"greatest",
"profit",
"so",
"that",
"more",
"profitable",
"forms",
"outcompete",
"less",
"profitable",
"forms",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/developer.py#L46-L75 | train |
UDST/urbansim | urbansim/developer/developer.py | Developer.compute_units_to_build | def compute_units_to_build(num_agents, num_units, target_vacancy):
"""
Compute number of units to build to match target vacancy.
Parameters
----------
num_agents : int
number of agents that need units in the region
num_units : int
number of units ... | python | def compute_units_to_build(num_agents, num_units, target_vacancy):
"""
Compute number of units to build to match target vacancy.
Parameters
----------
num_agents : int
number of agents that need units in the region
num_units : int
number of units ... | [
"def",
"compute_units_to_build",
"(",
"num_agents",
",",
"num_units",
",",
"target_vacancy",
")",
":",
"print",
"(",
"\"Number of agents: {:,}\"",
".",
"format",
"(",
"num_agents",
")",
")",
"print",
"(",
"\"Number of agent spaces: {:,}\"",
".",
"format",
"(",
"int"... | Compute number of units to build to match target vacancy.
Parameters
----------
num_agents : int
number of agents that need units in the region
num_units : int
number of units in buildings
target_vacancy : float (0-1.0)
target vacancy rate
... | [
"Compute",
"number",
"of",
"units",
"to",
"build",
"to",
"match",
"target",
"vacancy",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/developer.py#L78-L104 | train |
UDST/urbansim | urbansim/developer/developer.py | Developer.pick | def pick(self, form, target_units, parcel_size, ave_unit_size,
current_units, max_parcel_size=200000, min_unit_size=400,
drop_after_build=True, residential=True, bldg_sqft_per_job=400.0,
profit_to_prob_func=None):
"""
Choose the buildings from the list that are fea... | python | def pick(self, form, target_units, parcel_size, ave_unit_size,
current_units, max_parcel_size=200000, min_unit_size=400,
drop_after_build=True, residential=True, bldg_sqft_per_job=400.0,
profit_to_prob_func=None):
"""
Choose the buildings from the list that are fea... | [
"def",
"pick",
"(",
"self",
",",
"form",
",",
"target_units",
",",
"parcel_size",
",",
"ave_unit_size",
",",
"current_units",
",",
"max_parcel_size",
"=",
"200000",
",",
"min_unit_size",
"=",
"400",
",",
"drop_after_build",
"=",
"True",
",",
"residential",
"="... | Choose the buildings from the list that are feasible to build in
order to match the specified demand.
Parameters
----------
form : string or list
One or more of the building forms from the pro forma specification -
e.g. "residential" or "mixedresidential" - these... | [
"Choose",
"the",
"buildings",
"from",
"the",
"list",
"that",
"are",
"feasible",
"to",
"build",
"in",
"order",
"to",
"match",
"the",
"specified",
"demand",
"."
] | 79f815a6503e109f50be270cee92d0f4a34f49ef | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/developer.py#L106-L231 | train |
linkedin/luminol | src/luminol/__init__.py | Luminol._analyze_root_causes | def _analyze_root_causes(self):
"""
Conduct root cause analysis.
The first metric of the list is taken as the root cause right now.
"""
causes = {}
for a in self.anomalies:
try:
causes[a] = self.correlations[a][0]
except IndexError:... | python | def _analyze_root_causes(self):
"""
Conduct root cause analysis.
The first metric of the list is taken as the root cause right now.
"""
causes = {}
for a in self.anomalies:
try:
causes[a] = self.correlations[a][0]
except IndexError:... | [
"def",
"_analyze_root_causes",
"(",
"self",
")",
":",
"causes",
"=",
"{",
"}",
"for",
"a",
"in",
"self",
".",
"anomalies",
":",
"try",
":",
"causes",
"[",
"a",
"]",
"=",
"self",
".",
"correlations",
"[",
"a",
"]",
"[",
"0",
"]",
"except",
"IndexErr... | Conduct root cause analysis.
The first metric of the list is taken as the root cause right now. | [
"Conduct",
"root",
"cause",
"analysis",
".",
"The",
"first",
"metric",
"of",
"the",
"list",
"is",
"taken",
"as",
"the",
"root",
"cause",
"right",
"now",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/__init__.py#L32-L43 | train |
linkedin/luminol | src/luminol/correlator.py | Correlator._sanity_check | def _sanity_check(self):
"""
Check if the time series have more than two data points.
"""
if len(self.time_series_a) < 2 or len(self.time_series_b) < 2:
raise exceptions.NotEnoughDataPoints('luminol.Correlator: Too few data points!') | python | def _sanity_check(self):
"""
Check if the time series have more than two data points.
"""
if len(self.time_series_a) < 2 or len(self.time_series_b) < 2:
raise exceptions.NotEnoughDataPoints('luminol.Correlator: Too few data points!') | [
"def",
"_sanity_check",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"time_series_a",
")",
"<",
"2",
"or",
"len",
"(",
"self",
".",
"time_series_b",
")",
"<",
"2",
":",
"raise",
"exceptions",
".",
"NotEnoughDataPoints",
"(",
"'luminol.Correlator: ... | Check if the time series have more than two data points. | [
"Check",
"if",
"the",
"time",
"series",
"have",
"more",
"than",
"two",
"data",
"points",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/correlator.py#L92-L97 | train |
linkedin/luminol | src/luminol/correlator.py | Correlator._correlate | def _correlate(self):
"""
Run correlation algorithm.
"""
a = self.algorithm(**self.algorithm_params)
self.correlation_result = a.run() | python | def _correlate(self):
"""
Run correlation algorithm.
"""
a = self.algorithm(**self.algorithm_params)
self.correlation_result = a.run() | [
"def",
"_correlate",
"(",
"self",
")",
":",
"a",
"=",
"self",
".",
"algorithm",
"(",
"**",
"self",
".",
"algorithm_params",
")",
"self",
".",
"correlation_result",
"=",
"a",
".",
"run",
"(",
")"
] | Run correlation algorithm. | [
"Run",
"correlation",
"algorithm",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/correlator.py#L99-L104 | train |
linkedin/luminol | demo/src/rca.py | RCA._analyze | def _analyze(self):
"""
Analyzes if a matrix has anomalies.
If any anomaly is found, determine if the matrix correlates with any other matrixes.
To be implemented.
"""
output = defaultdict(list)
output_by_name = defaultdict(list)
scores = self.anomaly_detector.get_all_scores()
if se... | python | def _analyze(self):
"""
Analyzes if a matrix has anomalies.
If any anomaly is found, determine if the matrix correlates with any other matrixes.
To be implemented.
"""
output = defaultdict(list)
output_by_name = defaultdict(list)
scores = self.anomaly_detector.get_all_scores()
if se... | [
"def",
"_analyze",
"(",
"self",
")",
":",
"output",
"=",
"defaultdict",
"(",
"list",
")",
"output_by_name",
"=",
"defaultdict",
"(",
"list",
")",
"scores",
"=",
"self",
".",
"anomaly_detector",
".",
"get_all_scores",
"(",
")",
"if",
"self",
".",
"anomalies... | Analyzes if a matrix has anomalies.
If any anomaly is found, determine if the matrix correlates with any other matrixes.
To be implemented. | [
"Analyzes",
"if",
"a",
"matrix",
"has",
"anomalies",
".",
"If",
"any",
"anomaly",
"is",
"found",
"determine",
"if",
"the",
"matrix",
"correlates",
"with",
"any",
"other",
"matrixes",
".",
"To",
"be",
"implemented",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/demo/src/rca.py#L49-L92 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/default_detector.py | DefaultDetector._set_scores | def _set_scores(self):
"""
Set anomaly scores using a weighted sum.
"""
anom_scores_ema = self.exp_avg_detector.run()
anom_scores_deri = self.derivative_detector.run()
anom_scores = {}
for timestamp in anom_scores_ema.timestamps:
# Compute a weighted a... | python | def _set_scores(self):
"""
Set anomaly scores using a weighted sum.
"""
anom_scores_ema = self.exp_avg_detector.run()
anom_scores_deri = self.derivative_detector.run()
anom_scores = {}
for timestamp in anom_scores_ema.timestamps:
# Compute a weighted a... | [
"def",
"_set_scores",
"(",
"self",
")",
":",
"anom_scores_ema",
"=",
"self",
".",
"exp_avg_detector",
".",
"run",
"(",
")",
"anom_scores_deri",
"=",
"self",
".",
"derivative_detector",
".",
"run",
"(",
")",
"anom_scores",
"=",
"{",
"}",
"for",
"timestamp",
... | Set anomaly scores using a weighted sum. | [
"Set",
"anomaly",
"scores",
"using",
"a",
"weighted",
"sum",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/default_detector.py#L35-L49 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/derivative_detector.py | DerivativeDetector._compute_derivatives | def _compute_derivatives(self):
"""
Compute derivatives of the time series.
"""
derivatives = []
for i, (timestamp, value) in enumerate(self.time_series_items):
if i > 0:
pre_item = self.time_series_items[i - 1]
pre_timestamp = pre_item... | python | def _compute_derivatives(self):
"""
Compute derivatives of the time series.
"""
derivatives = []
for i, (timestamp, value) in enumerate(self.time_series_items):
if i > 0:
pre_item = self.time_series_items[i - 1]
pre_timestamp = pre_item... | [
"def",
"_compute_derivatives",
"(",
"self",
")",
":",
"derivatives",
"=",
"[",
"]",
"for",
"i",
",",
"(",
"timestamp",
",",
"value",
")",
"in",
"enumerate",
"(",
"self",
".",
"time_series_items",
")",
":",
"if",
"i",
">",
"0",
":",
"pre_item",
"=",
"... | Compute derivatives of the time series. | [
"Compute",
"derivatives",
"of",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/derivative_detector.py#L38-L55 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/bitmap_detector.py | BitmapDetector._sanity_check | def _sanity_check(self):
"""
Check if there are enough data points.
"""
windows = self.lag_window_size + self.future_window_size
if (not self.lag_window_size or not self.future_window_size or self.time_series_length < windows or windows < DEFAULT_BITMAP_MINIMAL_POINTS_IN_WINDOWS)... | python | def _sanity_check(self):
"""
Check if there are enough data points.
"""
windows = self.lag_window_size + self.future_window_size
if (not self.lag_window_size or not self.future_window_size or self.time_series_length < windows or windows < DEFAULT_BITMAP_MINIMAL_POINTS_IN_WINDOWS)... | [
"def",
"_sanity_check",
"(",
"self",
")",
":",
"windows",
"=",
"self",
".",
"lag_window_size",
"+",
"self",
".",
"future_window_size",
"if",
"(",
"not",
"self",
".",
"lag_window_size",
"or",
"not",
"self",
".",
"future_window_size",
"or",
"self",
".",
"time_... | Check if there are enough data points. | [
"Check",
"if",
"there",
"are",
"enough",
"data",
"points",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/bitmap_detector.py#L60-L73 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/bitmap_detector.py | BitmapDetector._generate_SAX | def _generate_SAX(self):
"""
Generate SAX representation for all values of the time series.
"""
sections = {}
self.value_min = self.time_series.min()
self.value_max = self.time_series.max()
# Break the whole value range into different sections.
section_hei... | python | def _generate_SAX(self):
"""
Generate SAX representation for all values of the time series.
"""
sections = {}
self.value_min = self.time_series.min()
self.value_max = self.time_series.max()
# Break the whole value range into different sections.
section_hei... | [
"def",
"_generate_SAX",
"(",
"self",
")",
":",
"sections",
"=",
"{",
"}",
"self",
".",
"value_min",
"=",
"self",
".",
"time_series",
".",
"min",
"(",
")",
"self",
".",
"value_max",
"=",
"self",
".",
"time_series",
".",
"max",
"(",
")",
"section_height"... | Generate SAX representation for all values of the time series. | [
"Generate",
"SAX",
"representation",
"for",
"all",
"values",
"of",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/bitmap_detector.py#L92-L104 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/bitmap_detector.py | BitmapDetector._set_scores | def _set_scores(self):
"""
Compute anomaly scores for the time series by sliding both lagging window and future window.
"""
anom_scores = {}
self._generate_SAX()
self._construct_all_SAX_chunk_dict()
length = self.time_series_length
lws = self.lag_window_si... | python | def _set_scores(self):
"""
Compute anomaly scores for the time series by sliding both lagging window and future window.
"""
anom_scores = {}
self._generate_SAX()
self._construct_all_SAX_chunk_dict()
length = self.time_series_length
lws = self.lag_window_si... | [
"def",
"_set_scores",
"(",
"self",
")",
":",
"anom_scores",
"=",
"{",
"}",
"self",
".",
"_generate_SAX",
"(",
")",
"self",
".",
"_construct_all_SAX_chunk_dict",
"(",
")",
"length",
"=",
"self",
".",
"time_series_length",
"lws",
"=",
"self",
".",
"lag_window_... | Compute anomaly scores for the time series by sliding both lagging window and future window. | [
"Compute",
"anomaly",
"scores",
"for",
"the",
"time",
"series",
"by",
"sliding",
"both",
"lagging",
"window",
"and",
"future",
"window",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/bitmap_detector.py#L196-L212 | train |
linkedin/luminol | src/luminol/algorithms/correlator_algorithms/cross_correlator.py | CrossCorrelator._detect_correlation | def _detect_correlation(self):
"""
Detect correlation by computing correlation coefficients for all allowed shift steps,
then take the maximum.
"""
correlations = []
shifted_correlations = []
self.time_series_a.normalize()
self.time_series_b.normalize()
... | python | def _detect_correlation(self):
"""
Detect correlation by computing correlation coefficients for all allowed shift steps,
then take the maximum.
"""
correlations = []
shifted_correlations = []
self.time_series_a.normalize()
self.time_series_b.normalize()
... | [
"def",
"_detect_correlation",
"(",
"self",
")",
":",
"correlations",
"=",
"[",
"]",
"shifted_correlations",
"=",
"[",
"]",
"self",
".",
"time_series_a",
".",
"normalize",
"(",
")",
"self",
".",
"time_series_b",
".",
"normalize",
"(",
")",
"a",
",",
"b",
... | Detect correlation by computing correlation coefficients for all allowed shift steps,
then take the maximum. | [
"Detect",
"correlation",
"by",
"computing",
"correlation",
"coefficients",
"for",
"all",
"allowed",
"shift",
"steps",
"then",
"take",
"the",
"maximum",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/correlator_algorithms/cross_correlator.py#L39-L83 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/exp_avg_detector.py | ExpAvgDetector._compute_anom_data_using_window | def _compute_anom_data_using_window(self):
"""
Compute anomaly scores using a lagging window.
"""
anom_scores = {}
values = self.time_series.values
stdev = numpy.std(values)
for i, (timestamp, value) in enumerate(self.time_series_items):
if i < self.la... | python | def _compute_anom_data_using_window(self):
"""
Compute anomaly scores using a lagging window.
"""
anom_scores = {}
values = self.time_series.values
stdev = numpy.std(values)
for i, (timestamp, value) in enumerate(self.time_series_items):
if i < self.la... | [
"def",
"_compute_anom_data_using_window",
"(",
"self",
")",
":",
"anom_scores",
"=",
"{",
"}",
"values",
"=",
"self",
".",
"time_series",
".",
"values",
"stdev",
"=",
"numpy",
".",
"std",
"(",
"values",
")",
"for",
"i",
",",
"(",
"timestamp",
",",
"value... | Compute anomaly scores using a lagging window. | [
"Compute",
"anomaly",
"scores",
"using",
"a",
"lagging",
"window",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/exp_avg_detector.py#L53-L69 | train |
linkedin/luminol | src/luminol/algorithms/anomaly_detector_algorithms/exp_avg_detector.py | ExpAvgDetector._compute_anom_data_decay_all | def _compute_anom_data_decay_all(self):
"""
Compute anomaly scores using a lagging window covering all the data points before.
"""
anom_scores = {}
values = self.time_series.values
ema = utils.compute_ema(self.smoothing_factor, values)
stdev = numpy.std(values)
... | python | def _compute_anom_data_decay_all(self):
"""
Compute anomaly scores using a lagging window covering all the data points before.
"""
anom_scores = {}
values = self.time_series.values
ema = utils.compute_ema(self.smoothing_factor, values)
stdev = numpy.std(values)
... | [
"def",
"_compute_anom_data_decay_all",
"(",
"self",
")",
":",
"anom_scores",
"=",
"{",
"}",
"values",
"=",
"self",
".",
"time_series",
".",
"values",
"ema",
"=",
"utils",
".",
"compute_ema",
"(",
"self",
".",
"smoothing_factor",
",",
"values",
")",
"stdev",
... | Compute anomaly scores using a lagging window covering all the data points before. | [
"Compute",
"anomaly",
"scores",
"using",
"a",
"lagging",
"window",
"covering",
"all",
"the",
"data",
"points",
"before",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/algorithms/anomaly_detector_algorithms/exp_avg_detector.py#L71-L82 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries._generic_binary_op | def _generic_binary_op(self, other, op):
"""
Perform the method operation specified in the op parameter on the values
within the instance's time series values and either another time series
or a constant number value.
:param other: Time series of values or a constant number to u... | python | def _generic_binary_op(self, other, op):
"""
Perform the method operation specified in the op parameter on the values
within the instance's time series values and either another time series
or a constant number value.
:param other: Time series of values or a constant number to u... | [
"def",
"_generic_binary_op",
"(",
"self",
",",
"other",
",",
"op",
")",
":",
"output",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"other",
",",
"TimeSeries",
")",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"key",... | Perform the method operation specified in the op parameter on the values
within the instance's time series values and either another time series
or a constant number value.
:param other: Time series of values or a constant number to use in calculations with instance's time series.
:para... | [
"Perform",
"the",
"method",
"operation",
"specified",
"in",
"the",
"op",
"parameter",
"on",
"the",
"values",
"within",
"the",
"instance",
"s",
"time",
"series",
"values",
"and",
"either",
"another",
"time",
"series",
"or",
"a",
"constant",
"number",
"value",
... | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L150-L192 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries._get_value_type | def _get_value_type(self, other):
"""
Get the object type of the value within the values portion of the time series.
:return: `type` of object
"""
if self.values:
return type(self.values[0])
elif isinstance(other, TimeSeries) and other.values:
ret... | python | def _get_value_type(self, other):
"""
Get the object type of the value within the values portion of the time series.
:return: `type` of object
"""
if self.values:
return type(self.values[0])
elif isinstance(other, TimeSeries) and other.values:
ret... | [
"def",
"_get_value_type",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"values",
":",
"return",
"type",
"(",
"self",
".",
"values",
"[",
"0",
"]",
")",
"elif",
"isinstance",
"(",
"other",
",",
"TimeSeries",
")",
"and",
"other",
".",
"value... | Get the object type of the value within the values portion of the time series.
:return: `type` of object | [
"Get",
"the",
"object",
"type",
"of",
"the",
"value",
"within",
"the",
"values",
"portion",
"of",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L194-L205 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.smooth | def smooth(self, smoothing_factor):
"""
return a new time series which is a exponential smoothed version of the original data series.
soomth forward once, backward once, and then take the average.
:param float smoothing_factor: smoothing factor
:return: :class:`TimeSeries` objec... | python | def smooth(self, smoothing_factor):
"""
return a new time series which is a exponential smoothed version of the original data series.
soomth forward once, backward once, and then take the average.
:param float smoothing_factor: smoothing factor
:return: :class:`TimeSeries` objec... | [
"def",
"smooth",
"(",
"self",
",",
"smoothing_factor",
")",
":",
"forward_smooth",
"=",
"{",
"}",
"backward_smooth",
"=",
"{",
"}",
"output",
"=",
"{",
"}",
"if",
"self",
":",
"pre",
"=",
"self",
".",
"values",
"[",
"0",
"]",
"next",
"=",
"self",
"... | return a new time series which is a exponential smoothed version of the original data series.
soomth forward once, backward once, and then take the average.
:param float smoothing_factor: smoothing factor
:return: :class:`TimeSeries` object. | [
"return",
"a",
"new",
"time",
"series",
"which",
"is",
"a",
"exponential",
"smoothed",
"version",
"of",
"the",
"original",
"data",
"series",
".",
"soomth",
"forward",
"once",
"backward",
"once",
"and",
"then",
"take",
"the",
"average",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L248-L272 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.add_offset | def add_offset(self, offset):
"""
Return a new time series with all timestamps incremented by some offset.
:param int offset: The number of seconds to offset the time series.
:return: `None`
"""
self.timestamps = [ts + offset for ts in self.timestamps] | python | def add_offset(self, offset):
"""
Return a new time series with all timestamps incremented by some offset.
:param int offset: The number of seconds to offset the time series.
:return: `None`
"""
self.timestamps = [ts + offset for ts in self.timestamps] | [
"def",
"add_offset",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"timestamps",
"=",
"[",
"ts",
"+",
"offset",
"for",
"ts",
"in",
"self",
".",
"timestamps",
"]"
] | Return a new time series with all timestamps incremented by some offset.
:param int offset: The number of seconds to offset the time series.
:return: `None` | [
"Return",
"a",
"new",
"time",
"series",
"with",
"all",
"timestamps",
"incremented",
"by",
"some",
"offset",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L274-L281 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.normalize | def normalize(self):
"""
Return a new time series with all values normalized to 0 to 1.
:return: `None`
"""
maximum = self.max()
if maximum:
self.values = [value / maximum for value in self.values] | python | def normalize(self):
"""
Return a new time series with all values normalized to 0 to 1.
:return: `None`
"""
maximum = self.max()
if maximum:
self.values = [value / maximum for value in self.values] | [
"def",
"normalize",
"(",
"self",
")",
":",
"maximum",
"=",
"self",
".",
"max",
"(",
")",
"if",
"maximum",
":",
"self",
".",
"values",
"=",
"[",
"value",
"/",
"maximum",
"for",
"value",
"in",
"self",
".",
"values",
"]"
] | Return a new time series with all values normalized to 0 to 1.
:return: `None` | [
"Return",
"a",
"new",
"time",
"series",
"with",
"all",
"values",
"normalized",
"to",
"0",
"to",
"1",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L283-L291 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.crop | def crop(self, start_timestamp, end_timestamp):
"""
Return a new TimeSeries object contains all the timstamps and values within
the specified range.
:param int start_timestamp: the start timestamp value
:param int end_timestamp: the end timestamp value
:return: :class:`T... | python | def crop(self, start_timestamp, end_timestamp):
"""
Return a new TimeSeries object contains all the timstamps and values within
the specified range.
:param int start_timestamp: the start timestamp value
:param int end_timestamp: the end timestamp value
:return: :class:`T... | [
"def",
"crop",
"(",
"self",
",",
"start_timestamp",
",",
"end_timestamp",
")",
":",
"output",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"key",
">=",
"start_timestamp",
"and",
"key",
"<=",
"end_timestamp... | Return a new TimeSeries object contains all the timstamps and values within
the specified range.
:param int start_timestamp: the start timestamp value
:param int end_timestamp: the end timestamp value
:return: :class:`TimeSeries` object. | [
"Return",
"a",
"new",
"TimeSeries",
"object",
"contains",
"all",
"the",
"timstamps",
"and",
"values",
"within",
"the",
"specified",
"range",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L293-L310 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.average | def average(self, default=None):
"""
Calculate the average value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the average value or `None`.
"""
return numpy.asscalar(numpy.average(se... | python | def average(self, default=None):
"""
Calculate the average value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the average value or `None`.
"""
return numpy.asscalar(numpy.average(se... | [
"def",
"average",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"average",
"(",
"self",
".",
"values",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the average value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the average value or `None`. | [
"Calculate",
"the",
"average",
"value",
"over",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L312-L319 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.median | def median(self, default=None):
"""
Calculate the median value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the median value or `None`.
"""
return numpy.asscalar(numpy.median(self.v... | python | def median(self, default=None):
"""
Calculate the median value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the median value or `None`.
"""
return numpy.asscalar(numpy.median(self.v... | [
"def",
"median",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"median",
"(",
"self",
".",
"values",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the median value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the median value or `None`. | [
"Calculate",
"the",
"median",
"value",
"over",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L321-L328 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.max | def max(self, default=None):
"""
Calculate the maximum value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the maximum value or `None`.
"""
return numpy.asscalar(numpy.max(self.value... | python | def max(self, default=None):
"""
Calculate the maximum value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the maximum value or `None`.
"""
return numpy.asscalar(numpy.max(self.value... | [
"def",
"max",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"max",
"(",
"self",
".",
"values",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the maximum value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the maximum value or `None`. | [
"Calculate",
"the",
"maximum",
"value",
"over",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L330-L337 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.min | def min(self, default=None):
"""
Calculate the minimum value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the maximum value or `None`.
"""
return numpy.asscalar(numpy.min(self.value... | python | def min(self, default=None):
"""
Calculate the minimum value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the maximum value or `None`.
"""
return numpy.asscalar(numpy.min(self.value... | [
"def",
"min",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"min",
"(",
"self",
".",
"values",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the minimum value over the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the maximum value or `None`. | [
"Calculate",
"the",
"minimum",
"value",
"over",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L339-L346 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.percentile | def percentile(self, n, default=None):
"""
Calculate the Nth Percentile value over the time series.
:param int n: Integer value of the percentile to calculate.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the Nt... | python | def percentile(self, n, default=None):
"""
Calculate the Nth Percentile value over the time series.
:param int n: Integer value of the percentile to calculate.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the Nt... | [
"def",
"percentile",
"(",
"self",
",",
"n",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"percentile",
"(",
"self",
".",
"values",
",",
"n",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the Nth Percentile value over the time series.
:param int n: Integer value of the percentile to calculate.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the Nth percentile value or `None`. | [
"Calculate",
"the",
"Nth",
"Percentile",
"value",
"over",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L348-L356 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.stdev | def stdev(self, default=None):
"""
Calculate the standard deviation of the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the standard deviation value or `None`.
"""
return numpy.asscalar(nump... | python | def stdev(self, default=None):
"""
Calculate the standard deviation of the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the standard deviation value or `None`.
"""
return numpy.asscalar(nump... | [
"def",
"stdev",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"std",
"(",
"self",
".",
"values",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the standard deviation of the time series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the standard deviation value or `None`. | [
"Calculate",
"the",
"standard",
"deviation",
"of",
"the",
"time",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L358-L365 | train |
linkedin/luminol | src/luminol/modules/time_series.py | TimeSeries.sum | def sum(self, default=None):
"""
Calculate the sum of all the values in the times series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the sum or `None`.
"""
return numpy.asscalar(numpy.sum(self.values))... | python | def sum(self, default=None):
"""
Calculate the sum of all the values in the times series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the sum or `None`.
"""
return numpy.asscalar(numpy.sum(self.values))... | [
"def",
"sum",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"asscalar",
"(",
"numpy",
".",
"sum",
"(",
"self",
".",
"values",
")",
")",
"if",
"self",
".",
"values",
"else",
"default"
] | Calculate the sum of all the values in the times series.
:param default: Value to return as a default should the calculation not be possible.
:return: Float representing the sum or `None`. | [
"Calculate",
"the",
"sum",
"of",
"all",
"the",
"values",
"in",
"the",
"times",
"series",
"."
] | 42e4ab969b774ff98f902d064cb041556017f635 | https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/modules/time_series.py#L367-L374 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.