repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
pennersr/django-allauth
allauth/socialaccount/providers/dataporten/provider.py
DataportenProvider.extract_common_fields
def extract_common_fields(self, data): ''' This function extracts information from the /userinfo endpoint which will be consumed by allauth.socialaccount.adapter.populate_user(). Look there to find which key-value pairs that should be saved in the returned dict. Typical ...
python
def extract_common_fields(self, data): ''' This function extracts information from the /userinfo endpoint which will be consumed by allauth.socialaccount.adapter.populate_user(). Look there to find which key-value pairs that should be saved in the returned dict. Typical ...
[ "def", "extract_common_fields", "(", "self", ",", "data", ")", ":", "# Make shallow copy to prevent possible mutability issues", "data", "=", "dict", "(", "data", ")", "# If a Feide username is available, use it. If not, use the \"username\"", "# of the email-address", "for", "us...
This function extracts information from the /userinfo endpoint which will be consumed by allauth.socialaccount.adapter.populate_user(). Look there to find which key-value pairs that should be saved in the returned dict. Typical return dict: { "userid": "76a7a061-3c55...
[ "This", "function", "extracts", "information", "from", "the", "/", "userinfo", "endpoint", "which", "will", "be", "consumed", "by", "allauth", ".", "socialaccount", ".", "adapter", ".", "populate_user", "()", ".", "Look", "there", "to", "find", "which", "key",...
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/dataporten/provider.py#L60-L91
train
pennersr/django-allauth
allauth/account/decorators.py
verified_email_required
def verified_email_required(function=None, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Even when email verification is not mandatory during signup, there may be circumstances during which you really want to prevent unverified user...
python
def verified_email_required(function=None, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Even when email verification is not mandatory during signup, there may be circumstances during which you really want to prevent unverified user...
[ "def", "verified_email_required", "(", "function", "=", "None", ",", "login_url", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "def", "decorator", "(", "view_func", ")", ":", "@", "login_required", "(", "redirect_field_name", "=",...
Even when email verification is not mandatory during signup, there may be circumstances during which you really want to prevent unverified users to proceed. This decorator ensures the user is authenticated and has a verified email address. If the former is not the case then the behavior is identical to ...
[ "Even", "when", "email", "verification", "is", "not", "mandatory", "during", "signup", "there", "may", "be", "circumstances", "during", "which", "you", "really", "want", "to", "prevent", "unverified", "users", "to", "proceed", ".", "This", "decorator", "ensures"...
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/decorators.py#L9-L37
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth2/client.py
OAuth2Client._strip_empty_keys
def _strip_empty_keys(self, params): """Added because the Dropbox OAuth2 flow doesn't work when scope is passed in, which is empty. """ keys = [k for k, v in params.items() if v == ''] for key in keys: del params[key]
python
def _strip_empty_keys(self, params): """Added because the Dropbox OAuth2 flow doesn't work when scope is passed in, which is empty. """ keys = [k for k, v in params.items() if v == ''] for key in keys: del params[key]
[ "def", "_strip_empty_keys", "(", "self", ",", "params", ")", ":", "keys", "=", "[", "k", "for", "k", ",", "v", "in", "params", ".", "items", "(", ")", "if", "v", "==", "''", "]", "for", "key", "in", "keys", ":", "del", "params", "[", "key", "]"...
Added because the Dropbox OAuth2 flow doesn't work when scope is passed in, which is empty.
[ "Added", "because", "the", "Dropbox", "OAuth2", "flow", "doesn", "t", "work", "when", "scope", "is", "passed", "in", "which", "is", "empty", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth2/client.py#L88-L94
train
pennersr/django-allauth
allauth/compat.py
int_to_base36
def int_to_base36(i): """ Django on py2 raises ValueError on large values. """ if six.PY2: char_set = '0123456789abcdefghijklmnopqrstuvwxyz' if i < 0: raise ValueError("Negative base36 conversion input.") if not isinstance(i, six.integer_types): raise Type...
python
def int_to_base36(i): """ Django on py2 raises ValueError on large values. """ if six.PY2: char_set = '0123456789abcdefghijklmnopqrstuvwxyz' if i < 0: raise ValueError("Negative base36 conversion input.") if not isinstance(i, six.integer_types): raise Type...
[ "def", "int_to_base36", "(", "i", ")", ":", "if", "six", ".", "PY2", ":", "char_set", "=", "'0123456789abcdefghijklmnopqrstuvwxyz'", "if", "i", "<", "0", ":", "raise", "ValueError", "(", "\"Negative base36 conversion input.\"", ")", "if", "not", "isinstance", "(...
Django on py2 raises ValueError on large values.
[ "Django", "on", "py2", "raises", "ValueError", "on", "large", "values", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/compat.py#L41-L60
train
pennersr/django-allauth
allauth/socialaccount/models.py
SocialLogin.save
def save(self, request, connect=False): """ Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts) """ assert not self.is_existing user = self.user user.save() self.account.user = user se...
python
def save(self, request, connect=False): """ Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts) """ assert not self.is_existing user = self.user user.save() self.account.user = user se...
[ "def", "save", "(", "self", ",", "request", ",", "connect", "=", "False", ")", ":", "assert", "not", "self", ".", "is_existing", "user", "=", "self", ".", "user", "user", ".", "save", "(", ")", "self", ".", "account", ".", "user", "=", "user", "sel...
Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts)
[ "Saves", "a", "new", "account", ".", "Note", "that", "while", "the", "account", "is", "new", "the", "user", "may", "be", "an", "existing", "one", "(", "when", "connecting", "accounts", ")" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/models.py#L228-L245
train
pennersr/django-allauth
allauth/socialaccount/models.py
SocialLogin.lookup
def lookup(self): """ Lookup existing account, if any. """ assert not self.is_existing try: a = SocialAccount.objects.get(provider=self.account.provider, uid=self.account.uid) # Update account a.extra_d...
python
def lookup(self): """ Lookup existing account, if any. """ assert not self.is_existing try: a = SocialAccount.objects.get(provider=self.account.provider, uid=self.account.uid) # Update account a.extra_d...
[ "def", "lookup", "(", "self", ")", ":", "assert", "not", "self", ".", "is_existing", "try", ":", "a", "=", "SocialAccount", ".", "objects", ".", "get", "(", "provider", "=", "self", ".", "account", ".", "provider", ",", "uid", "=", "self", ".", "acco...
Lookup existing account, if any.
[ "Lookup", "existing", "account", "if", "any", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/models.py#L254-L285
train
pennersr/django-allauth
allauth/socialaccount/providers/base.py
Provider.sociallogin_from_response
def sociallogin_from_response(self, request, response): """ Instantiates and populates a `SocialLogin` model based on the data retrieved in `response`. The method does NOT save the model to the DB. Data for `SocialLogin` will be extracted from `response` with the help of...
python
def sociallogin_from_response(self, request, response): """ Instantiates and populates a `SocialLogin` model based on the data retrieved in `response`. The method does NOT save the model to the DB. Data for `SocialLogin` will be extracted from `response` with the help of...
[ "def", "sociallogin_from_response", "(", "self", ",", "request", ",", "response", ")", ":", "# NOTE: Avoid loading models at top due to registry boot...", "from", "allauth", ".", "socialaccount", ".", "models", "import", "SocialLogin", ",", "SocialAccount", "adapter", "="...
Instantiates and populates a `SocialLogin` model based on the data retrieved in `response`. The method does NOT save the model to the DB. Data for `SocialLogin` will be extracted from `response` with the help of the `.extract_uid()`, `.extract_extra_data()`, `.extract_common_fie...
[ "Instantiates", "and", "populates", "a", "SocialLogin", "model", "based", "on", "the", "data", "retrieved", "in", "response", ".", "The", "method", "does", "NOT", "save", "the", "model", "to", "the", "DB", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/base.py#L65-L99
train
pennersr/django-allauth
allauth/socialaccount/providers/eventbrite/provider.py
EventbriteProvider.extract_common_fields
def extract_common_fields(self, data): """Extract fields from a basic user query.""" email = None for curr_email in data.get("emails", []): email = email or curr_email.get("email") if curr_email.get("verified", False) and \ curr_email.get("primary", Fa...
python
def extract_common_fields(self, data): """Extract fields from a basic user query.""" email = None for curr_email in data.get("emails", []): email = email or curr_email.get("email") if curr_email.get("verified", False) and \ curr_email.get("primary", Fa...
[ "def", "extract_common_fields", "(", "self", ",", "data", ")", ":", "email", "=", "None", "for", "curr_email", "in", "data", ".", "get", "(", "\"emails\"", ",", "[", "]", ")", ":", "email", "=", "email", "or", "curr_email", ".", "get", "(", "\"email\""...
Extract fields from a basic user query.
[ "Extract", "fields", "from", "a", "basic", "user", "query", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/eventbrite/provider.py#L32-L48
train
pennersr/django-allauth
allauth/socialaccount/providers/dataporten/views.py
DataportenAdapter.complete_login
def complete_login(self, request, app, token, **kwargs): ''' Arguments: request - The get request to the callback URL /accounts/dataporten/login/callback. app - The corresponding SocialApp model instance token - A token object with access token...
python
def complete_login(self, request, app, token, **kwargs): ''' Arguments: request - The get request to the callback URL /accounts/dataporten/login/callback. app - The corresponding SocialApp model instance token - A token object with access token...
[ "def", "complete_login", "(", "self", ",", "request", ",", "app", ",", "token", ",", "*", "*", "kwargs", ")", ":", "# The athentication header", "headers", "=", "{", "'Authorization'", ":", "'Bearer '", "+", "token", ".", "token", "}", "# Userinfo endpoint, fo...
Arguments: request - The get request to the callback URL /accounts/dataporten/login/callback. app - The corresponding SocialApp model instance token - A token object with access token given in token.token Returns: Should return a dict with ...
[ "Arguments", ":", "request", "-", "The", "get", "request", "to", "the", "callback", "URL", "/", "accounts", "/", "dataporten", "/", "login", "/", "callback", ".", "app", "-", "The", "corresponding", "SocialApp", "model", "instance", "token", "-", "A", "tok...
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/dataporten/views.py#L20-L60
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth/views.py
OAuthCallbackView.dispatch
def dispatch(self, request): """ View to handle final steps of OAuth based authentication where the user gets redirected back to from the service provider """ login_done_url = reverse(self.adapter.provider_id + "_callback") client = self._get_client(request, login_done_ur...
python
def dispatch(self, request): """ View to handle final steps of OAuth based authentication where the user gets redirected back to from the service provider """ login_done_url = reverse(self.adapter.provider_id + "_callback") client = self._get_client(request, login_done_ur...
[ "def", "dispatch", "(", "self", ",", "request", ")", ":", "login_done_url", "=", "reverse", "(", "self", ".", "adapter", ".", "provider_id", "+", "\"_callback\"", ")", "client", "=", "self", ".", "_get_client", "(", "request", ",", "login_done_url", ")", "...
View to handle final steps of OAuth based authentication where the user gets redirected back to from the service provider
[ "View", "to", "handle", "final", "steps", "of", "OAuth", "based", "authentication", "where", "the", "user", "gets", "redirected", "back", "to", "from", "the", "service", "provider" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/views.py#L78-L115
train
pennersr/django-allauth
allauth/account/views.py
ConfirmEmailView.login_on_confirm
def login_on_confirm(self, confirmation): """ Simply logging in the user may become a security issue. If you do not take proper care (e.g. don't purge used email confirmations), a malicious person that got hold of the link will be able to login over and over again and the user is...
python
def login_on_confirm(self, confirmation): """ Simply logging in the user may become a security issue. If you do not take proper care (e.g. don't purge used email confirmations), a malicious person that got hold of the link will be able to login over and over again and the user is...
[ "def", "login_on_confirm", "(", "self", ",", "confirmation", ")", ":", "user_pk", "=", "None", "user_pk_str", "=", "get_adapter", "(", "self", ".", "request", ")", ".", "unstash_user", "(", "self", ".", "request", ")", "if", "user_pk_str", ":", "user_pk", ...
Simply logging in the user may become a security issue. If you do not take proper care (e.g. don't purge used email confirmations), a malicious person that got hold of the link will be able to login over and over again and the user is unable to do anything about it. Even restoring their ...
[ "Simply", "logging", "in", "the", "user", "may", "become", "a", "security", "issue", ".", "If", "you", "do", "not", "take", "proper", "care", "(", "e", ".", "g", ".", "don", "t", "purge", "used", "email", "confirmations", ")", "a", "malicious", "person...
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/views.py#L302-L338
train
pennersr/django-allauth
allauth/socialaccount/providers/orcid/provider.py
extract_from_dict
def extract_from_dict(data, path): """ Navigate `data`, a multidimensional array (list or dictionary), and returns the object at `path`. """ value = data try: for key in path: value = value[key] return value except (KeyError, IndexError, TypeError): return...
python
def extract_from_dict(data, path): """ Navigate `data`, a multidimensional array (list or dictionary), and returns the object at `path`. """ value = data try: for key in path: value = value[key] return value except (KeyError, IndexError, TypeError): return...
[ "def", "extract_from_dict", "(", "data", ",", "path", ")", ":", "value", "=", "data", "try", ":", "for", "key", "in", "path", ":", "value", "=", "value", "[", "key", "]", "return", "value", "except", "(", "KeyError", ",", "IndexError", ",", "TypeError"...
Navigate `data`, a multidimensional array (list or dictionary), and returns the object at `path`.
[ "Navigate", "data", "a", "multidimensional", "array", "(", "list", "or", "dictionary", ")", "and", "returns", "the", "object", "at", "path", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/orcid/provider.py#L44-L55
train
pennersr/django-allauth
allauth/socialaccount/providers/linkedin_oauth2/provider.py
_extract_email
def _extract_email(data): """ {'elements': [{'handle': 'urn:li:emailAddress:319371470', 'handle~': {'emailAddress': 'raymond.penners@intenct.nl'}}]} """ ret = '' elements = data.get('elements', []) if len(elements) > 0: ret = elements[0].get('handle~', {}).get('emailAddres...
python
def _extract_email(data): """ {'elements': [{'handle': 'urn:li:emailAddress:319371470', 'handle~': {'emailAddress': 'raymond.penners@intenct.nl'}}]} """ ret = '' elements = data.get('elements', []) if len(elements) > 0: ret = elements[0].get('handle~', {}).get('emailAddres...
[ "def", "_extract_email", "(", "data", ")", ":", "ret", "=", "''", "elements", "=", "data", ".", "get", "(", "'elements'", ",", "[", "]", ")", "if", "len", "(", "elements", ")", ">", "0", ":", "ret", "=", "elements", "[", "0", "]", ".", "get", "...
{'elements': [{'handle': 'urn:li:emailAddress:319371470', 'handle~': {'emailAddress': 'raymond.penners@intenct.nl'}}]}
[ "{", "elements", ":", "[", "{", "handle", ":", "urn", ":", "li", ":", "emailAddress", ":", "319371470", "handle~", ":", "{", "emailAddress", ":", "raymond", ".", "penners" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/linkedin_oauth2/provider.py#L31-L40
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth/client.py
OAuthClient._get_request_token
def _get_request_token(self): """ Obtain a temporary request token to authorize an access token and to sign the request to obtain the access token """ if self.request_token is None: get_params = {} if self.parameters: get_params.update(self...
python
def _get_request_token(self): """ Obtain a temporary request token to authorize an access token and to sign the request to obtain the access token """ if self.request_token is None: get_params = {} if self.parameters: get_params.update(self...
[ "def", "_get_request_token", "(", "self", ")", ":", "if", "self", ".", "request_token", "is", "None", ":", "get_params", "=", "{", "}", "if", "self", ".", "parameters", ":", "get_params", ".", "update", "(", "self", ".", "parameters", ")", "get_params", ...
Obtain a temporary request token to authorize an access token and to sign the request to obtain the access token
[ "Obtain", "a", "temporary", "request", "token", "to", "authorize", "an", "access", "token", "and", "to", "sign", "the", "request", "to", "obtain", "the", "access", "token" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L61-L84
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth/client.py
OAuthClient.get_access_token
def get_access_token(self): """ Obtain the access token to access private resources at the API endpoint. """ if self.access_token is None: request_token = self._get_rt_from_session() oauth = OAuth1( self.consumer_key, client...
python
def get_access_token(self): """ Obtain the access token to access private resources at the API endpoint. """ if self.access_token is None: request_token = self._get_rt_from_session() oauth = OAuth1( self.consumer_key, client...
[ "def", "get_access_token", "(", "self", ")", ":", "if", "self", ".", "access_token", "is", "None", ":", "request_token", "=", "self", ".", "_get_rt_from_session", "(", ")", "oauth", "=", "OAuth1", "(", "self", ".", "consumer_key", ",", "client_secret", "=", ...
Obtain the access token to access private resources at the API endpoint.
[ "Obtain", "the", "access", "token", "to", "access", "private", "resources", "at", "the", "API", "endpoint", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L86-L116
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth/client.py
OAuthClient.get_redirect
def get_redirect(self, authorization_url, extra_params): """ Returns a ``HttpResponseRedirect`` object to redirect the user to the URL the OAuth provider handles authorization. """ request_token = self._get_request_token() params = {'oauth_token': request_token['oauth_tok...
python
def get_redirect(self, authorization_url, extra_params): """ Returns a ``HttpResponseRedirect`` object to redirect the user to the URL the OAuth provider handles authorization. """ request_token = self._get_request_token() params = {'oauth_token': request_token['oauth_tok...
[ "def", "get_redirect", "(", "self", ",", "authorization_url", ",", "extra_params", ")", ":", "request_token", "=", "self", ".", "_get_request_token", "(", ")", "params", "=", "{", "'oauth_token'", ":", "request_token", "[", "'oauth_token'", "]", ",", "'oauth_cal...
Returns a ``HttpResponseRedirect`` object to redirect the user to the URL the OAuth provider handles authorization.
[ "Returns", "a", "HttpResponseRedirect", "object", "to", "redirect", "the", "user", "to", "the", "URL", "the", "OAuth", "provider", "handles", "authorization", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L140-L151
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth/client.py
OAuth._get_at_from_session
def _get_at_from_session(self): """ Get the saved access token for private resources from the session. """ try: return self.request.session['oauth_%s_access_token' % get_token_prefix( self.req...
python
def _get_at_from_session(self): """ Get the saved access token for private resources from the session. """ try: return self.request.session['oauth_%s_access_token' % get_token_prefix( self.req...
[ "def", "_get_at_from_session", "(", "self", ")", ":", "try", ":", "return", "self", ".", "request", ".", "session", "[", "'oauth_%s_access_token'", "%", "get_token_prefix", "(", "self", ".", "request_token_url", ")", "]", "except", "KeyError", ":", "raise", "O...
Get the saved access token for private resources from the session.
[ "Get", "the", "saved", "access", "token", "for", "private", "resources", "from", "the", "session", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L167-L178
train
pennersr/django-allauth
allauth/socialaccount/providers/oauth/client.py
OAuth.query
def query(self, url, method="GET", params=dict(), headers=dict()): """ Request a API endpoint at ``url`` with ``params`` being either the POST or GET data. """ access_token = self._get_at_from_session() oauth = OAuth1( self.consumer_key, client_sec...
python
def query(self, url, method="GET", params=dict(), headers=dict()): """ Request a API endpoint at ``url`` with ``params`` being either the POST or GET data. """ access_token = self._get_at_from_session() oauth = OAuth1( self.consumer_key, client_sec...
[ "def", "query", "(", "self", ",", "url", ",", "method", "=", "\"GET\"", ",", "params", "=", "dict", "(", ")", ",", "headers", "=", "dict", "(", ")", ")", ":", "access_token", "=", "self", ".", "_get_at_from_session", "(", ")", "oauth", "=", "OAuth1",...
Request a API endpoint at ``url`` with ``params`` being either the POST or GET data.
[ "Request", "a", "API", "endpoint", "at", "url", "with", "params", "being", "either", "the", "POST", "or", "GET", "data", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L180-L200
train
pennersr/django-allauth
allauth/account/utils.py
get_next_redirect_url
def get_next_redirect_url(request, redirect_field_name="next"): """ Returns the next URL to redirect to, if it was explicitly passed via the request. """ redirect_to = get_request_param(request, redirect_field_name) if not get_adapter(request).is_safe_url(redirect_to): redirect_to = None...
python
def get_next_redirect_url(request, redirect_field_name="next"): """ Returns the next URL to redirect to, if it was explicitly passed via the request. """ redirect_to = get_request_param(request, redirect_field_name) if not get_adapter(request).is_safe_url(redirect_to): redirect_to = None...
[ "def", "get_next_redirect_url", "(", "request", ",", "redirect_field_name", "=", "\"next\"", ")", ":", "redirect_to", "=", "get_request_param", "(", "request", ",", "redirect_field_name", ")", "if", "not", "get_adapter", "(", "request", ")", ".", "is_safe_url", "(...
Returns the next URL to redirect to, if it was explicitly passed via the request.
[ "Returns", "the", "next", "URL", "to", "redirect", "to", "if", "it", "was", "explicitly", "passed", "via", "the", "request", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L28-L36
train
pennersr/django-allauth
allauth/account/utils.py
user_field
def user_field(user, field, *args): """ Gets or sets (optional) user model fields. No-op if fields do not exist. """ if not field: return User = get_user_model() try: field_meta = User._meta.get_field(field) max_length = field_meta.max_length except FieldDoesNotExist:...
python
def user_field(user, field, *args): """ Gets or sets (optional) user model fields. No-op if fields do not exist. """ if not field: return User = get_user_model() try: field_meta = User._meta.get_field(field) max_length = field_meta.max_length except FieldDoesNotExist:...
[ "def", "user_field", "(", "user", ",", "field", ",", "*", "args", ")", ":", "if", "not", "field", ":", "return", "User", "=", "get_user_model", "(", ")", "try", ":", "field_meta", "=", "User", ".", "_meta", ".", "get_field", "(", "field", ")", "max_l...
Gets or sets (optional) user model fields. No-op if fields do not exist.
[ "Gets", "or", "sets", "(", "optional", ")", "user", "model", "fields", ".", "No", "-", "op", "if", "fields", "do", "not", "exist", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L80-L102
train
pennersr/django-allauth
allauth/account/utils.py
perform_login
def perform_login(request, user, email_verification, redirect_url=None, signal_kwargs=None, signup=False): """ Keyword arguments: signup -- Indicates whether or not sending the email is essential (during signup), or if it can be skipped (e.g. in case email verifi...
python
def perform_login(request, user, email_verification, redirect_url=None, signal_kwargs=None, signup=False): """ Keyword arguments: signup -- Indicates whether or not sending the email is essential (during signup), or if it can be skipped (e.g. in case email verifi...
[ "def", "perform_login", "(", "request", ",", "user", ",", "email_verification", ",", "redirect_url", "=", "None", ",", "signal_kwargs", "=", "None", ",", "signup", "=", "False", ")", ":", "# Local users are stopped due to form validation checking", "# is_active, yet, ad...
Keyword arguments: signup -- Indicates whether or not sending the email is essential (during signup), or if it can be skipped (e.g. in case email verification is optional and we are only logging in).
[ "Keyword", "arguments", ":" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L115-L166
train
pennersr/django-allauth
allauth/account/utils.py
cleanup_email_addresses
def cleanup_email_addresses(request, addresses): """ Takes a list of EmailAddress instances and cleans it up, making sure only valid ones remain, without multiple primaries etc. Order is important: e.g. if multiple primary e-mail addresses exist, the first one encountered will be kept as primary. ...
python
def cleanup_email_addresses(request, addresses): """ Takes a list of EmailAddress instances and cleans it up, making sure only valid ones remain, without multiple primaries etc. Order is important: e.g. if multiple primary e-mail addresses exist, the first one encountered will be kept as primary. ...
[ "def", "cleanup_email_addresses", "(", "request", ",", "addresses", ")", ":", "from", ".", "models", "import", "EmailAddress", "adapter", "=", "get_adapter", "(", "request", ")", "# Let's group by `email`", "e2a", "=", "OrderedDict", "(", ")", "# maps email to Email...
Takes a list of EmailAddress instances and cleans it up, making sure only valid ones remain, without multiple primaries etc. Order is important: e.g. if multiple primary e-mail addresses exist, the first one encountered will be kept as primary.
[ "Takes", "a", "list", "of", "EmailAddress", "instances", "and", "cleans", "it", "up", "making", "sure", "only", "valid", "ones", "remain", "without", "multiple", "primaries", "etc", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L184-L241
train
pennersr/django-allauth
allauth/account/utils.py
setup_user_email
def setup_user_email(request, user, addresses): """ Creates proper EmailAddress for the user that was just signed up. Only sets up, doesn't do any other handling such as sending out email confirmation mails etc. """ from .models import EmailAddress assert not EmailAddress.objects.filter(use...
python
def setup_user_email(request, user, addresses): """ Creates proper EmailAddress for the user that was just signed up. Only sets up, doesn't do any other handling such as sending out email confirmation mails etc. """ from .models import EmailAddress assert not EmailAddress.objects.filter(use...
[ "def", "setup_user_email", "(", "request", ",", "user", ",", "addresses", ")", ":", "from", ".", "models", "import", "EmailAddress", "assert", "not", "EmailAddress", ".", "objects", ".", "filter", "(", "user", "=", "user", ")", ".", "exists", "(", ")", "...
Creates proper EmailAddress for the user that was just signed up. Only sets up, doesn't do any other handling such as sending out email confirmation mails etc.
[ "Creates", "proper", "EmailAddress", "for", "the", "user", "that", "was", "just", "signed", "up", ".", "Only", "sets", "up", "doesn", "t", "do", "any", "other", "handling", "such", "as", "sending", "out", "email", "confirmation", "mails", "etc", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L244-L278
train
pennersr/django-allauth
allauth/account/utils.py
send_email_confirmation
def send_email_confirmation(request, user, signup=False): """ E-mail verification mails are sent: a) Explicitly: when a user signs up b) Implicitly: when a user attempts to log in using an unverified e-mail while EMAIL_VERIFICATION is mandatory. Especially in case of b), we want to limit the nu...
python
def send_email_confirmation(request, user, signup=False): """ E-mail verification mails are sent: a) Explicitly: when a user signs up b) Implicitly: when a user attempts to log in using an unverified e-mail while EMAIL_VERIFICATION is mandatory. Especially in case of b), we want to limit the nu...
[ "def", "send_email_confirmation", "(", "request", ",", "user", ",", "signup", "=", "False", ")", ":", "from", ".", "models", "import", "EmailAddress", ",", "EmailConfirmation", "cooldown_period", "=", "timedelta", "(", "seconds", "=", "app_settings", ".", "EMAIL...
E-mail verification mails are sent: a) Explicitly: when a user signs up b) Implicitly: when a user attempts to log in using an unverified e-mail while EMAIL_VERIFICATION is mandatory. Especially in case of b), we want to limit the number of mails sent (consider a user retrying a few times), which i...
[ "E", "-", "mail", "verification", "mails", "are", "sent", ":", "a", ")", "Explicitly", ":", "when", "a", "user", "signs", "up", "b", ")", "Implicitly", ":", "when", "a", "user", "attempts", "to", "log", "in", "using", "an", "unverified", "e", "-", "m...
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L281-L332
train
pennersr/django-allauth
allauth/account/utils.py
sync_user_email_addresses
def sync_user_email_addresses(user): """ Keep user.email in sync with user.emailaddress_set. Under some circumstances the user.email may not have ended up as an EmailAddress record, e.g. in the case of manually created admin users. """ from .models import EmailAddress email = user_email...
python
def sync_user_email_addresses(user): """ Keep user.email in sync with user.emailaddress_set. Under some circumstances the user.email may not have ended up as an EmailAddress record, e.g. in the case of manually created admin users. """ from .models import EmailAddress email = user_email...
[ "def", "sync_user_email_addresses", "(", "user", ")", ":", "from", ".", "models", "import", "EmailAddress", "email", "=", "user_email", "(", "user", ")", "if", "email", "and", "not", "EmailAddress", ".", "objects", ".", "filter", "(", "user", "=", "user", ...
Keep user.email in sync with user.emailaddress_set. Under some circumstances the user.email may not have ended up as an EmailAddress record, e.g. in the case of manually created admin users.
[ "Keep", "user", ".", "email", "in", "sync", "with", "user", ".", "emailaddress_set", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L335-L354
train
pennersr/django-allauth
allauth/account/utils.py
filter_users_by_email
def filter_users_by_email(email): """Return list of users by email address Typically one, at most just a few in length. First we look through EmailAddress table, than customisable User model table. Add results together avoiding SQL joins and deduplicate. """ from .models import EmailAddress ...
python
def filter_users_by_email(email): """Return list of users by email address Typically one, at most just a few in length. First we look through EmailAddress table, than customisable User model table. Add results together avoiding SQL joins and deduplicate. """ from .models import EmailAddress ...
[ "def", "filter_users_by_email", "(", "email", ")", ":", "from", ".", "models", "import", "EmailAddress", "User", "=", "get_user_model", "(", ")", "mails", "=", "EmailAddress", ".", "objects", ".", "filter", "(", "email__iexact", "=", "email", ")", "users", "...
Return list of users by email address Typically one, at most just a few in length. First we look through EmailAddress table, than customisable User model table. Add results together avoiding SQL joins and deduplicate.
[ "Return", "list", "of", "users", "by", "email", "address" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L373-L387
train
pennersr/django-allauth
allauth/account/utils.py
user_pk_to_url_str
def user_pk_to_url_str(user): """ This should return a string. """ User = get_user_model() if issubclass(type(User._meta.pk), models.UUIDField): if isinstance(user.pk, six.string_types): return user.pk return user.pk.hex ret = user.pk if isinstance(ret, six.integ...
python
def user_pk_to_url_str(user): """ This should return a string. """ User = get_user_model() if issubclass(type(User._meta.pk), models.UUIDField): if isinstance(user.pk, six.string_types): return user.pk return user.pk.hex ret = user.pk if isinstance(ret, six.integ...
[ "def", "user_pk_to_url_str", "(", "user", ")", ":", "User", "=", "get_user_model", "(", ")", "if", "issubclass", "(", "type", "(", "User", ".", "_meta", ".", "pk", ")", ",", "models", ".", "UUIDField", ")", ":", "if", "isinstance", "(", "user", ".", ...
This should return a string.
[ "This", "should", "return", "a", "string", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L398-L411
train
pennersr/django-allauth
example/example/demo/apps.py
setup_dummy_social_apps
def setup_dummy_social_apps(sender, **kwargs): """ `allauth` needs tokens for OAuth based providers. So let's setup some dummy tokens """ from allauth.socialaccount.providers import registry from allauth.socialaccount.models import SocialApp from allauth.socialaccount.providers.oauth.provide...
python
def setup_dummy_social_apps(sender, **kwargs): """ `allauth` needs tokens for OAuth based providers. So let's setup some dummy tokens """ from allauth.socialaccount.providers import registry from allauth.socialaccount.models import SocialApp from allauth.socialaccount.providers.oauth.provide...
[ "def", "setup_dummy_social_apps", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "from", "allauth", ".", "socialaccount", ".", "providers", "import", "registry", "from", "allauth", ".", "socialaccount", ".", "models", "import", "SocialApp", "from", "allauth",...
`allauth` needs tokens for OAuth based providers. So let's setup some dummy tokens
[ "allauth", "needs", "tokens", "for", "OAuth", "based", "providers", ".", "So", "let", "s", "setup", "some", "dummy", "tokens" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/example/example/demo/apps.py#L7-L35
train
pennersr/django-allauth
allauth/socialaccount/fields.py
JSONField.value_from_object
def value_from_object(self, obj): """Return value dumped to string.""" val = super(JSONField, self).value_from_object(obj) return self.get_prep_value(val)
python
def value_from_object(self, obj): """Return value dumped to string.""" val = super(JSONField, self).value_from_object(obj) return self.get_prep_value(val)
[ "def", "value_from_object", "(", "self", ",", "obj", ")", ":", "val", "=", "super", "(", "JSONField", ",", "self", ")", ".", "value_from_object", "(", "obj", ")", "return", "self", ".", "get_prep_value", "(", "val", ")" ]
Return value dumped to string.
[ "Return", "value", "dumped", "to", "string", "." ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/fields.py#L54-L57
train
pennersr/django-allauth
allauth/account/app_settings.py
AppSettings.EMAIL_VERIFICATION
def EMAIL_VERIFICATION(self): """ See e-mail verification method """ ret = self._setting("EMAIL_VERIFICATION", self.EmailVerificationMethod.OPTIONAL) # Deal with legacy (boolean based) setting if ret is True: ret = self.EmailVerific...
python
def EMAIL_VERIFICATION(self): """ See e-mail verification method """ ret = self._setting("EMAIL_VERIFICATION", self.EmailVerificationMethod.OPTIONAL) # Deal with legacy (boolean based) setting if ret is True: ret = self.EmailVerific...
[ "def", "EMAIL_VERIFICATION", "(", "self", ")", ":", "ret", "=", "self", ".", "_setting", "(", "\"EMAIL_VERIFICATION\"", ",", "self", ".", "EmailVerificationMethod", ".", "OPTIONAL", ")", "# Deal with legacy (boolean based) setting", "if", "ret", "is", "True", ":", ...
See e-mail verification method
[ "See", "e", "-", "mail", "verification", "method" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/app_settings.py#L91-L102
train
pennersr/django-allauth
allauth/account/app_settings.py
AppSettings.PASSWORD_MIN_LENGTH
def PASSWORD_MIN_LENGTH(self): """ Minimum password Length """ from django.conf import settings ret = None if not settings.AUTH_PASSWORD_VALIDATORS: ret = self._setting("PASSWORD_MIN_LENGTH", 6) return ret
python
def PASSWORD_MIN_LENGTH(self): """ Minimum password Length """ from django.conf import settings ret = None if not settings.AUTH_PASSWORD_VALIDATORS: ret = self._setting("PASSWORD_MIN_LENGTH", 6) return ret
[ "def", "PASSWORD_MIN_LENGTH", "(", "self", ")", ":", "from", "django", ".", "conf", "import", "settings", "ret", "=", "None", "if", "not", "settings", ".", "AUTH_PASSWORD_VALIDATORS", ":", "ret", "=", "self", ".", "_setting", "(", "\"PASSWORD_MIN_LENGTH\"", ",...
Minimum password Length
[ "Minimum", "password", "Length" ]
f70cb3d622f992f15fe9b57098e0b328445b664e
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/app_settings.py#L140-L148
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
_function_with_partly_reduce
def _function_with_partly_reduce(chunk_list, map_function, kwargs): """ Small helper function to call a function (map_function) on a list of data chunks (chunk_list) and convert the results into a flattened list. This function is used to send chunks of data with a size larger than 1 to the ...
python
def _function_with_partly_reduce(chunk_list, map_function, kwargs): """ Small helper function to call a function (map_function) on a list of data chunks (chunk_list) and convert the results into a flattened list. This function is used to send chunks of data with a size larger than 1 to the ...
[ "def", "_function_with_partly_reduce", "(", "chunk_list", ",", "map_function", ",", "kwargs", ")", ":", "kwargs", "=", "kwargs", "or", "{", "}", "results", "=", "(", "map_function", "(", "chunk", ",", "*", "*", "kwargs", ")", "for", "chunk", "in", "chunk_l...
Small helper function to call a function (map_function) on a list of data chunks (chunk_list) and convert the results into a flattened list. This function is used to send chunks of data with a size larger than 1 to the workers in parallel and process these on the worker. :param chunk_list: A l...
[ "Small", "helper", "function", "to", "call", "a", "function", "(", "map_function", ")", "on", "a", "list", "of", "data", "chunks", "(", "chunk_list", ")", "and", "convert", "the", "results", "into", "a", "flattened", "list", ".", "This", "function", "is", ...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L19-L39
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
DistributorBaseClass.partition
def partition(data, chunk_size): """ This generator chunks a list of data into slices of length chunk_size. If the chunk_size is not a divider of the data length, the last slice will be shorter than chunk_size. :param data: The data to chunk. :type data: list :param chun...
python
def partition(data, chunk_size): """ This generator chunks a list of data into slices of length chunk_size. If the chunk_size is not a divider of the data length, the last slice will be shorter than chunk_size. :param data: The data to chunk. :type data: list :param chun...
[ "def", "partition", "(", "data", ",", "chunk_size", ")", ":", "iterable", "=", "iter", "(", "data", ")", "while", "True", ":", "next_chunk", "=", "list", "(", "itertools", ".", "islice", "(", "iterable", ",", "chunk_size", ")", ")", "if", "not", "next_...
This generator chunks a list of data into slices of length chunk_size. If the chunk_size is not a divider of the data length, the last slice will be shorter than chunk_size. :param data: The data to chunk. :type data: list :param chunk_size: Each chunks size. The last chunk may be small...
[ "This", "generator", "chunks", "a", "list", "of", "data", "into", "slices", "of", "length", "chunk_size", ".", "If", "the", "chunk_size", "is", "not", "a", "divider", "of", "the", "data", "length", "the", "last", "slice", "will", "be", "shorter", "than", ...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L57-L77
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
DistributorBaseClass.calculate_best_chunk_size
def calculate_best_chunk_size(self, data_length): """ Calculates the best chunk size for a list of length data_length. The current implemented formula is more or less an empirical result for multiprocessing case on one machine. :param data_length: A length which defines how man...
python
def calculate_best_chunk_size(self, data_length): """ Calculates the best chunk size for a list of length data_length. The current implemented formula is more or less an empirical result for multiprocessing case on one machine. :param data_length: A length which defines how man...
[ "def", "calculate_best_chunk_size", "(", "self", ",", "data_length", ")", ":", "chunk_size", ",", "extra", "=", "divmod", "(", "data_length", ",", "self", ".", "n_workers", "*", "5", ")", "if", "extra", ":", "chunk_size", "+=", "1", "return", "chunk_size" ]
Calculates the best chunk size for a list of length data_length. The current implemented formula is more or less an empirical result for multiprocessing case on one machine. :param data_length: A length which defines how many calculations there need to be. :type data_length: int ...
[ "Calculates", "the", "best", "chunk", "size", "for", "a", "list", "of", "length", "data_length", ".", "The", "current", "implemented", "formula", "is", "more", "or", "less", "an", "empirical", "result", "for", "multiprocessing", "case", "on", "one", "machine",...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L85-L100
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
DistributorBaseClass.map_reduce
def map_reduce(self, map_function, data, function_kwargs=None, chunk_size=None, data_length=None): """ This method contains the core functionality of the DistributorBaseClass class. It maps the map_function to each element of the data and reduces the results to return a flattened list. ...
python
def map_reduce(self, map_function, data, function_kwargs=None, chunk_size=None, data_length=None): """ This method contains the core functionality of the DistributorBaseClass class. It maps the map_function to each element of the data and reduces the results to return a flattened list. ...
[ "def", "map_reduce", "(", "self", ",", "map_function", ",", "data", ",", "function_kwargs", "=", "None", ",", "chunk_size", "=", "None", ",", "data_length", "=", "None", ")", ":", "if", "data_length", "is", "None", ":", "data_length", "=", "len", "(", "d...
This method contains the core functionality of the DistributorBaseClass class. It maps the map_function to each element of the data and reduces the results to return a flattened list. How the jobs are calculated, is determined by the classes :func:`tsfresh.utilities.distribution.Distr...
[ "This", "method", "contains", "the", "core", "functionality", "of", "the", "DistributorBaseClass", "class", ".", "It", "maps", "the", "map_function", "to", "each", "element", "of", "the", "data", "and", "reduces", "the", "results", "to", "return", "a", "flatte...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L102-L151
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
MapDistributor.distribute
def distribute(self, func, partitioned_chunks, kwargs): """ Calculates the features in a sequential fashion by pythons map command :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - each element is again ...
python
def distribute(self, func, partitioned_chunks, kwargs): """ Calculates the features in a sequential fashion by pythons map command :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - each element is again ...
[ "def", "distribute", "(", "self", ",", "func", ",", "partitioned_chunks", ",", "kwargs", ")", ":", "return", "map", "(", "partial", "(", "func", ",", "*", "*", "kwargs", ")", ",", "partitioned_chunks", ")" ]
Calculates the features in a sequential fashion by pythons map command :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - each element is again a list of chunks - and should be processed by one worker. ...
[ "Calculates", "the", "features", "in", "a", "sequential", "fashion", "by", "pythons", "map", "command" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L195-L210
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
LocalDaskDistributor.distribute
def distribute(self, func, partitioned_chunks, kwargs): """ Calculates the features in a parallel fashion by distributing the map command to the dask workers on a local machine :param func: the function to send to each worker. :type func: callable :param partitioned_chun...
python
def distribute(self, func, partitioned_chunks, kwargs): """ Calculates the features in a parallel fashion by distributing the map command to the dask workers on a local machine :param func: the function to send to each worker. :type func: callable :param partitioned_chun...
[ "def", "distribute", "(", "self", ",", "func", ",", "partitioned_chunks", ",", "kwargs", ")", ":", "result", "=", "self", ".", "client", ".", "gather", "(", "self", ".", "client", ".", "map", "(", "partial", "(", "func", ",", "*", "*", "kwargs", ")",...
Calculates the features in a parallel fashion by distributing the map command to the dask workers on a local machine :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - each element is again a list of ch...
[ "Calculates", "the", "features", "in", "a", "parallel", "fashion", "by", "distributing", "the", "map", "command", "to", "the", "dask", "workers", "on", "a", "local", "machine" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L246-L263
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
ClusterDaskDistributor.calculate_best_chunk_size
def calculate_best_chunk_size(self, data_length): """ Uses the number of dask workers in the cluster (during execution time, meaning when you start the extraction) to find the optimal chunk_size. :param data_length: A length which defines how many calculations there need to be. ...
python
def calculate_best_chunk_size(self, data_length): """ Uses the number of dask workers in the cluster (during execution time, meaning when you start the extraction) to find the optimal chunk_size. :param data_length: A length which defines how many calculations there need to be. ...
[ "def", "calculate_best_chunk_size", "(", "self", ",", "data_length", ")", ":", "n_workers", "=", "len", "(", "self", ".", "client", ".", "scheduler_info", "(", ")", "[", "\"workers\"", "]", ")", "chunk_size", ",", "extra", "=", "divmod", "(", "data_length", ...
Uses the number of dask workers in the cluster (during execution time, meaning when you start the extraction) to find the optimal chunk_size. :param data_length: A length which defines how many calculations there need to be. :type data_length: int
[ "Uses", "the", "number", "of", "dask", "workers", "in", "the", "cluster", "(", "during", "execution", "time", "meaning", "when", "you", "start", "the", "extraction", ")", "to", "find", "the", "optimal", "chunk_size", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L289-L301
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
MultiprocessingDistributor.distribute
def distribute(self, func, partitioned_chunks, kwargs): """ Calculates the features in a parallel fashion by distributing the map command to a thread pool :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - ...
python
def distribute(self, func, partitioned_chunks, kwargs): """ Calculates the features in a parallel fashion by distributing the map command to a thread pool :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - ...
[ "def", "distribute", "(", "self", ",", "func", ",", "partitioned_chunks", ",", "kwargs", ")", ":", "return", "self", ".", "pool", ".", "imap_unordered", "(", "partial", "(", "func", ",", "*", "*", "kwargs", ")", ",", "partitioned_chunks", ")" ]
Calculates the features in a parallel fashion by distributing the map command to a thread pool :param func: the function to send to each worker. :type func: callable :param partitioned_chunks: The list of data chunks - each element is again a list of chunks - and should be processed...
[ "Calculates", "the", "features", "in", "a", "parallel", "fashion", "by", "distributing", "the", "map", "command", "to", "a", "thread", "pool" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L350-L365
train
blue-yonder/tsfresh
tsfresh/utilities/distribution.py
MultiprocessingDistributor.close
def close(self): """ Collects the result from the workers and closes the thread pool. """ self.pool.close() self.pool.terminate() self.pool.join()
python
def close(self): """ Collects the result from the workers and closes the thread pool. """ self.pool.close() self.pool.terminate() self.pool.join()
[ "def", "close", "(", "self", ")", ":", "self", ".", "pool", ".", "close", "(", ")", "self", ".", "pool", ".", "terminate", "(", ")", "self", ".", "pool", ".", "join", "(", ")" ]
Collects the result from the workers and closes the thread pool.
[ "Collects", "the", "result", "from", "the", "workers", "and", "closes", "the", "thread", "pool", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/distribution.py#L367-L373
train
blue-yonder/tsfresh
tsfresh/feature_extraction/settings.py
from_columns
def from_columns(columns, columns_to_ignore=None): """ Creates a mapping from kind names to fc_parameters objects (which are itself mappings from feature calculators to settings) to extract only the features contained in the columns. To do so, for every feature name in columns this method 1. sp...
python
def from_columns(columns, columns_to_ignore=None): """ Creates a mapping from kind names to fc_parameters objects (which are itself mappings from feature calculators to settings) to extract only the features contained in the columns. To do so, for every feature name in columns this method 1. sp...
[ "def", "from_columns", "(", "columns", ",", "columns_to_ignore", "=", "None", ")", ":", "kind_to_fc_parameters", "=", "{", "}", "if", "columns_to_ignore", "is", "None", ":", "columns_to_ignore", "=", "[", "]", "for", "col", "in", "columns", ":", "if", "col",...
Creates a mapping from kind names to fc_parameters objects (which are itself mappings from feature calculators to settings) to extract only the features contained in the columns. To do so, for every feature name in columns this method 1. split the column name into col, feature, params part 2. decid...
[ "Creates", "a", "mapping", "from", "kind", "names", "to", "fc_parameters", "objects", "(", "which", "are", "itself", "mappings", "from", "feature", "calculators", "to", "settings", ")", "to", "extract", "only", "the", "features", "contained", "in", "the", "col...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/settings.py#L24-L82
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
_roll
def _roll(a, shift): """ Roll 1D array elements. Improves the performance of numpy.roll() by reducing the overhead introduced from the flexibility of the numpy.roll() method such as the support for rolling over multiple dimensions. Elements that roll beyond the last position are re-introduced at ...
python
def _roll(a, shift): """ Roll 1D array elements. Improves the performance of numpy.roll() by reducing the overhead introduced from the flexibility of the numpy.roll() method such as the support for rolling over multiple dimensions. Elements that roll beyond the last position are re-introduced at ...
[ "def", "_roll", "(", "a", ",", "shift", ")", ":", "if", "not", "isinstance", "(", "a", ",", "np", ".", "ndarray", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "idx", "=", "shift", "%", "len", "(", "a", ")", "return", "np", ".", ...
Roll 1D array elements. Improves the performance of numpy.roll() by reducing the overhead introduced from the flexibility of the numpy.roll() method such as the support for rolling over multiple dimensions. Elements that roll beyond the last position are re-introduced at the beginning. Similarly, element...
[ "Roll", "1D", "array", "elements", ".", "Improves", "the", "performance", "of", "numpy", ".", "roll", "()", "by", "reducing", "the", "overhead", "introduced", "from", "the", "flexibility", "of", "the", "numpy", ".", "roll", "()", "method", "such", "as", "t...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L35-L78
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
_get_length_sequences_where
def _get_length_sequences_where(x): """ This method calculates the length of all sub-sequences where the array x is either True or 1. Examples -------- >>> x = [0,1,0,0,1,1,1,0,0,1,0,1,1] >>> _get_length_sequences_where(x) >>> [1, 3, 1, 2] >>> x = [0,True,0,0,True,True,True,0,0,True,0,...
python
def _get_length_sequences_where(x): """ This method calculates the length of all sub-sequences where the array x is either True or 1. Examples -------- >>> x = [0,1,0,0,1,1,1,0,0,1,0,1,1] >>> _get_length_sequences_where(x) >>> [1, 3, 1, 2] >>> x = [0,True,0,0,True,True,True,0,0,True,0,...
[ "def", "_get_length_sequences_where", "(", "x", ")", ":", "if", "len", "(", "x", ")", "==", "0", ":", "return", "[", "0", "]", "else", ":", "res", "=", "[", "len", "(", "list", "(", "group", ")", ")", "for", "value", ",", "group", "in", "itertool...
This method calculates the length of all sub-sequences where the array x is either True or 1. Examples -------- >>> x = [0,1,0,0,1,1,1,0,0,1,0,1,1] >>> _get_length_sequences_where(x) >>> [1, 3, 1, 2] >>> x = [0,True,0,0,True,True,True,0,0,True,0,True,True] >>> _get_length_sequences_where(x...
[ "This", "method", "calculates", "the", "length", "of", "all", "sub", "-", "sequences", "where", "the", "array", "x", "is", "either", "True", "or", "1", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L81-L107
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
_estimate_friedrich_coefficients
def _estimate_friedrich_coefficients(x, m, r): """ Coefficients of polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot{x}(t) = h(x(t)) + \mathcal{N}(0,R) As described by Friedrich et al. (2000): Physics Letters A 271, p. 217...
python
def _estimate_friedrich_coefficients(x, m, r): """ Coefficients of polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot{x}(t) = h(x(t)) + \mathcal{N}(0,R) As described by Friedrich et al. (2000): Physics Letters A 271, p. 217...
[ "def", "_estimate_friedrich_coefficients", "(", "x", ",", "m", ",", "r", ")", ":", "assert", "m", ">", "0", ",", "\"Order of polynomial need to be positive integer, found {}\"", ".", "format", "(", "m", ")", "df", "=", "pd", ".", "DataFrame", "(", "{", "'signa...
Coefficients of polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot{x}(t) = h(x(t)) + \mathcal{N}(0,R) As described by Friedrich et al. (2000): Physics Letters A 271, p. 217-222 *Extracting model equations from experimental ...
[ "Coefficients", "of", "polynomial", ":", "math", ":", "h", "(", "x", ")", "which", "has", "been", "fitted", "to", "the", "deterministic", "dynamics", "of", "Langevin", "model", "..", "math", "::", "\\", "dot", "{", "x", "}", "(", "t", ")", "=", "h", ...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L110-L150
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
_aggregate_on_chunks
def _aggregate_on_chunks(x, f_agg, chunk_len): """ Takes the time series x and constructs a lower sampled version of it by applying the aggregation function f_agg on consecutive chunks of length chunk_len :param x: the time series to calculate the aggregation of :type x: numpy.ndarray :param f_...
python
def _aggregate_on_chunks(x, f_agg, chunk_len): """ Takes the time series x and constructs a lower sampled version of it by applying the aggregation function f_agg on consecutive chunks of length chunk_len :param x: the time series to calculate the aggregation of :type x: numpy.ndarray :param f_...
[ "def", "_aggregate_on_chunks", "(", "x", ",", "f_agg", ",", "chunk_len", ")", ":", "return", "[", "getattr", "(", "x", "[", "i", "*", "chunk_len", ":", "(", "i", "+", "1", ")", "*", "chunk_len", "]", ",", "f_agg", ")", "(", ")", "for", "i", "in",...
Takes the time series x and constructs a lower sampled version of it by applying the aggregation function f_agg on consecutive chunks of length chunk_len :param x: the time series to calculate the aggregation of :type x: numpy.ndarray :param f_agg: The name of the aggregation function that should be an...
[ "Takes", "the", "time", "series", "x", "and", "constructs", "a", "lower", "sampled", "version", "of", "it", "by", "applying", "the", "aggregation", "function", "f_agg", "on", "consecutive", "chunks", "of", "length", "chunk_len" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L153-L167
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
set_property
def set_property(key, value): """ This method returns a decorator that sets the property key of the function to value """ def decorate_func(func): setattr(func, key, value) if func.__doc__ and key == "fctype": func.__doc__ = func.__doc__ + "\n\n *This function is of type: ...
python
def set_property(key, value): """ This method returns a decorator that sets the property key of the function to value """ def decorate_func(func): setattr(func, key, value) if func.__doc__ and key == "fctype": func.__doc__ = func.__doc__ + "\n\n *This function is of type: ...
[ "def", "set_property", "(", "key", ",", "value", ")", ":", "def", "decorate_func", "(", "func", ")", ":", "setattr", "(", "func", ",", "key", ",", "value", ")", "if", "func", ".", "__doc__", "and", "key", "==", "\"fctype\"", ":", "func", ".", "__doc_...
This method returns a decorator that sets the property key of the function to value
[ "This", "method", "returns", "a", "decorator", "that", "sets", "the", "property", "key", "of", "the", "function", "to", "value" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L170-L179
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
variance_larger_than_standard_deviation
def variance_larger_than_standard_deviation(x): """ Boolean variable denoting if the variance of x is greater than its standard deviation. Is equal to variance of x being larger than 1 :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this featur...
python
def variance_larger_than_standard_deviation(x): """ Boolean variable denoting if the variance of x is greater than its standard deviation. Is equal to variance of x being larger than 1 :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this featur...
[ "def", "variance_larger_than_standard_deviation", "(", "x", ")", ":", "y", "=", "np", ".", "var", "(", "x", ")", "return", "y", ">", "np", ".", "sqrt", "(", "y", ")" ]
Boolean variable denoting if the variance of x is greater than its standard deviation. Is equal to variance of x being larger than 1 :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool
[ "Boolean", "variable", "denoting", "if", "the", "variance", "of", "x", "is", "greater", "than", "its", "standard", "deviation", ".", "Is", "equal", "to", "variance", "of", "x", "being", "larger", "than", "1" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L183-L194
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
ratio_beyond_r_sigma
def ratio_beyond_r_sigma(x, r): """ Ratio of values that are more than r*std(x) (so r sigma) away from the mean of x. :param x: the time series to calculate the feature of :type x: iterable :return: the value of this feature :return type: float """ if not isinstance(x, (np.ndarray, pd.S...
python
def ratio_beyond_r_sigma(x, r): """ Ratio of values that are more than r*std(x) (so r sigma) away from the mean of x. :param x: the time series to calculate the feature of :type x: iterable :return: the value of this feature :return type: float """ if not isinstance(x, (np.ndarray, pd.S...
[ "def", "ratio_beyond_r_sigma", "(", "x", ",", "r", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "sum"...
Ratio of values that are more than r*std(x) (so r sigma) away from the mean of x. :param x: the time series to calculate the feature of :type x: iterable :return: the value of this feature :return type: float
[ "Ratio", "of", "values", "that", "are", "more", "than", "r", "*", "std", "(", "x", ")", "(", "so", "r", "sigma", ")", "away", "from", "the", "mean", "of", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L198-L209
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
large_standard_deviation
def large_standard_deviation(x, r): """ Boolean variable denoting if the standard dev of x is higher than 'r' times the range = difference between max and min of x. Hence it checks if .. math:: std(x) > r * (max(X)-min(X)) According to a rule of the thumb, the standard deviation shoul...
python
def large_standard_deviation(x, r): """ Boolean variable denoting if the standard dev of x is higher than 'r' times the range = difference between max and min of x. Hence it checks if .. math:: std(x) > r * (max(X)-min(X)) According to a rule of the thumb, the standard deviation shoul...
[ "def", "large_standard_deviation", "(", "x", ",", "r", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "...
Boolean variable denoting if the standard dev of x is higher than 'r' times the range = difference between max and min of x. Hence it checks if .. math:: std(x) > r * (max(X)-min(X)) According to a rule of the thumb, the standard deviation should be a forth of the range of the values. :p...
[ "Boolean", "variable", "denoting", "if", "the", "standard", "dev", "of", "x", "is", "higher", "than", "r", "times", "the", "range", "=", "difference", "between", "max", "and", "min", "of", "x", ".", "Hence", "it", "checks", "if" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L213-L234
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
symmetry_looking
def symmetry_looking(x, param): """ Boolean variable denoting if the distribution of x *looks symmetric*. This is the case if .. math:: | mean(X)-median(X)| < r * (max(X)-min(X)) :param x: the time series to calculate the feature of :type x: numpy.ndarray :param r: the percentage of t...
python
def symmetry_looking(x, param): """ Boolean variable denoting if the distribution of x *looks symmetric*. This is the case if .. math:: | mean(X)-median(X)| < r * (max(X)-min(X)) :param x: the time series to calculate the feature of :type x: numpy.ndarray :param r: the percentage of t...
[ "def", "symmetry_looking", "(", "x", ",", "param", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "mean_median_difference", "=",...
Boolean variable denoting if the distribution of x *looks symmetric*. This is the case if .. math:: | mean(X)-median(X)| < r * (max(X)-min(X)) :param x: the time series to calculate the feature of :type x: numpy.ndarray :param r: the percentage of the range to compare with :type r: float ...
[ "Boolean", "variable", "denoting", "if", "the", "distribution", "of", "x", "*", "looks", "symmetric", "*", ".", "This", "is", "the", "case", "if" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L238-L258
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
has_duplicate_max
def has_duplicate_max(x): """ Checks if the maximum value of x is observed more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool """ if not isinstance(x, (np.ndarray, pd.Series)): x = np....
python
def has_duplicate_max(x): """ Checks if the maximum value of x is observed more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool """ if not isinstance(x, (np.ndarray, pd.Series)): x = np....
[ "def", "has_duplicate_max", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "sum", "(", "x", ...
Checks if the maximum value of x is observed more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool
[ "Checks", "if", "the", "maximum", "value", "of", "x", "is", "observed", "more", "than", "once" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L262-L273
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
has_duplicate_min
def has_duplicate_min(x): """ Checks if the minimal value of x is observed more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool """ if not isinstance(x, (np.ndarray, pd.Series)): x = np....
python
def has_duplicate_min(x): """ Checks if the minimal value of x is observed more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool """ if not isinstance(x, (np.ndarray, pd.Series)): x = np....
[ "def", "has_duplicate_min", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "sum", "(", "x", ...
Checks if the minimal value of x is observed more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool
[ "Checks", "if", "the", "minimal", "value", "of", "x", "is", "observed", "more", "than", "once" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L277-L288
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
has_duplicate
def has_duplicate(x): """ Checks if any value in x occurs more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool """ if not isinstance(x, (np.ndarray, pd.Series)): x = np.asarray(x) re...
python
def has_duplicate(x): """ Checks if any value in x occurs more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool """ if not isinstance(x, (np.ndarray, pd.Series)): x = np.asarray(x) re...
[ "def", "has_duplicate", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "x", ".", "size", "!=", "np", "...
Checks if any value in x occurs more than once :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: bool
[ "Checks", "if", "any", "value", "in", "x", "occurs", "more", "than", "once" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L292-L303
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
agg_autocorrelation
def agg_autocorrelation(x, param): r""" Calculates the value of an aggregation function :math:`f_{agg}` (e.g. the variance or the mean) over the autocorrelation :math:`R(l)` for different lags. The autocorrelation :math:`R(l)` for lag :math:`l` is defined as .. math:: R(l) = \frac{1}{(n-l)\sig...
python
def agg_autocorrelation(x, param): r""" Calculates the value of an aggregation function :math:`f_{agg}` (e.g. the variance or the mean) over the autocorrelation :math:`R(l)` for different lags. The autocorrelation :math:`R(l)` for lag :math:`l` is defined as .. math:: R(l) = \frac{1}{(n-l)\sig...
[ "def", "agg_autocorrelation", "(", "x", ",", "param", ")", ":", "# if the time series is longer than the following threshold, we use fft to calculate the acf", "THRESHOLD_TO_USE_FFT", "=", "1250", "var", "=", "np", ".", "var", "(", "x", ")", "n", "=", "len", "(", "x",...
r""" Calculates the value of an aggregation function :math:`f_{agg}` (e.g. the variance or the mean) over the autocorrelation :math:`R(l)` for different lags. The autocorrelation :math:`R(l)` for lag :math:`l` is defined as .. math:: R(l) = \frac{1}{(n-l)\sigma^{2}} \sum_{t=1}^{n-l}(X_{t}-\mu )(X_...
[ "r", "Calculates", "the", "value", "of", "an", "aggregation", "function", ":", "math", ":", "f_", "{", "agg", "}", "(", "e", ".", "g", ".", "the", "variance", "or", "the", "mean", ")", "over", "the", "autocorrelation", ":", "math", ":", "R", "(", "...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L324-L366
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
partial_autocorrelation
def partial_autocorrelation(x, param): """ Calculates the value of the partial autocorrelation function at the given lag. The lag `k` partial autocorrelation of a time series :math:`\\lbrace x_t, t = 1 \\ldots T \\rbrace` equals the partial correlation of :math:`x_t` and :math:`x_{t-k}`, adjusted for th...
python
def partial_autocorrelation(x, param): """ Calculates the value of the partial autocorrelation function at the given lag. The lag `k` partial autocorrelation of a time series :math:`\\lbrace x_t, t = 1 \\ldots T \\rbrace` equals the partial correlation of :math:`x_t` and :math:`x_{t-k}`, adjusted for th...
[ "def", "partial_autocorrelation", "(", "x", ",", "param", ")", ":", "# Check the difference between demanded lags by param and possible lags to calculate (depends on len(x))", "max_demanded_lag", "=", "max", "(", "[", "lag", "[", "\"lag\"", "]", "for", "lag", "in", "param",...
Calculates the value of the partial autocorrelation function at the given lag. The lag `k` partial autocorrelation of a time series :math:`\\lbrace x_t, t = 1 \\ldots T \\rbrace` equals the partial correlation of :math:`x_t` and :math:`x_{t-k}`, adjusted for the intermediate variables :math:`\\lbrace x_{t-1...
[ "Calculates", "the", "value", "of", "the", "partial", "autocorrelation", "function", "at", "the", "given", "lag", ".", "The", "lag", "k", "partial", "autocorrelation", "of", "a", "time", "series", ":", "math", ":", "\\\\", "lbrace", "x_t", "t", "=", "1", ...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L370-L418
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
augmented_dickey_fuller
def augmented_dickey_fuller(x, param): """ The Augmented Dickey-Fuller test is a hypothesis test which checks whether a unit root is present in a time series sample. This feature calculator returns the value of the respective test statistic. See the statsmodels implementation for references and more de...
python
def augmented_dickey_fuller(x, param): """ The Augmented Dickey-Fuller test is a hypothesis test which checks whether a unit root is present in a time series sample. This feature calculator returns the value of the respective test statistic. See the statsmodels implementation for references and more de...
[ "def", "augmented_dickey_fuller", "(", "x", ",", "param", ")", ":", "res", "=", "None", "try", ":", "res", "=", "adfuller", "(", "x", ")", "except", "LinAlgError", ":", "res", "=", "np", ".", "NaN", ",", "np", ".", "NaN", ",", "np", ".", "NaN", "...
The Augmented Dickey-Fuller test is a hypothesis test which checks whether a unit root is present in a time series sample. This feature calculator returns the value of the respective test statistic. See the statsmodels implementation for references and more details. :param x: the time series to calculate ...
[ "The", "Augmented", "Dickey", "-", "Fuller", "test", "is", "a", "hypothesis", "test", "which", "checks", "whether", "a", "unit", "root", "is", "present", "in", "a", "time", "series", "sample", ".", "This", "feature", "calculator", "returns", "the", "value", ...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L422-L450
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
abs_energy
def abs_energy(x): """ Returns the absolute energy of the time series which is the sum over the squared values .. math:: E = \\sum_{i=1,\ldots, n} x_i^2 :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: fl...
python
def abs_energy(x): """ Returns the absolute energy of the time series which is the sum over the squared values .. math:: E = \\sum_{i=1,\ldots, n} x_i^2 :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: fl...
[ "def", "abs_energy", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "dot", "(", "x", ",", ...
Returns the absolute energy of the time series which is the sum over the squared values .. math:: E = \\sum_{i=1,\ldots, n} x_i^2 :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "absolute", "energy", "of", "the", "time", "series", "which", "is", "the", "sum", "over", "the", "squared", "values" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L454-L469
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
cid_ce
def cid_ce(x, normalize): """ This function calculator is an estimate for a time series complexity [1] (A more complex time series has more peaks, valleys etc.). It calculates the value of .. math:: \\sqrt{ \\sum_{i=0}^{n-2lag} ( x_{i} - x_{i+1})^2 } .. rubric:: References | [1] Bat...
python
def cid_ce(x, normalize): """ This function calculator is an estimate for a time series complexity [1] (A more complex time series has more peaks, valleys etc.). It calculates the value of .. math:: \\sqrt{ \\sum_{i=0}^{n-2lag} ( x_{i} - x_{i+1})^2 } .. rubric:: References | [1] Bat...
[ "def", "cid_ce", "(", "x", ",", "normalize", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "if", "normalize", ":", "s", "...
This function calculator is an estimate for a time series complexity [1] (A more complex time series has more peaks, valleys etc.). It calculates the value of .. math:: \\sqrt{ \\sum_{i=0}^{n-2lag} ( x_{i} - x_{i+1})^2 } .. rubric:: References | [1] Batista, Gustavo EAPA, et al (2014). ...
[ "This", "function", "calculator", "is", "an", "estimate", "for", "a", "time", "series", "complexity", "[", "1", "]", "(", "A", "more", "complex", "time", "series", "has", "more", "peaks", "valleys", "etc", ".", ")", ".", "It", "calculates", "the", "value...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L473-L506
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
mean_second_derivative_central
def mean_second_derivative_central(x): """ Returns the mean value of a central approximation of the second derivative .. math:: \\frac{1}{n} \\sum_{i=1,\ldots, n-1} \\frac{1}{2} (x_{i+2} - 2 \\cdot x_{i+1} + x_i) :param x: the time series to calculate the feature of :type x: numpy.ndarra...
python
def mean_second_derivative_central(x): """ Returns the mean value of a central approximation of the second derivative .. math:: \\frac{1}{n} \\sum_{i=1,\ldots, n-1} \\frac{1}{2} (x_{i+2} - 2 \\cdot x_{i+1} + x_i) :param x: the time series to calculate the feature of :type x: numpy.ndarra...
[ "def", "mean_second_derivative_central", "(", "x", ")", ":", "diff", "=", "(", "_roll", "(", "x", ",", "1", ")", "-", "2", "*", "np", ".", "array", "(", "x", ")", "+", "_roll", "(", "x", ",", "-", "1", ")", ")", "/", "2.0", "return", "np", "....
Returns the mean value of a central approximation of the second derivative .. math:: \\frac{1}{n} \\sum_{i=1,\ldots, n-1} \\frac{1}{2} (x_{i+2} - 2 \\cdot x_{i+1} + x_i) :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :retur...
[ "Returns", "the", "mean", "value", "of", "a", "central", "approximation", "of", "the", "second", "derivative" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L545-L560
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
skewness
def skewness(x): """ Returns the sample skewness of x (calculated with the adjusted Fisher-Pearson standardized moment coefficient G1). :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ if not isin...
python
def skewness(x): """ Returns the sample skewness of x (calculated with the adjusted Fisher-Pearson standardized moment coefficient G1). :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ if not isin...
[ "def", "skewness", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "pd", ".", "Series", ")", ":", "x", "=", "pd", ".", "Series", "(", "x", ")", "return", "pd", ".", "Series", ".", "skew", "(", "x", ")" ]
Returns the sample skewness of x (calculated with the adjusted Fisher-Pearson standardized moment coefficient G1). :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "sample", "skewness", "of", "x", "(", "calculated", "with", "the", "adjusted", "Fisher", "-", "Pearson", "standardized", "moment", "coefficient", "G1", ")", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L634-L646
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
kurtosis
def kurtosis(x): """ Returns the kurtosis of x (calculated with the adjusted Fisher-Pearson standardized moment coefficient G2). :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ if not isinstance(...
python
def kurtosis(x): """ Returns the kurtosis of x (calculated with the adjusted Fisher-Pearson standardized moment coefficient G2). :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ if not isinstance(...
[ "def", "kurtosis", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "pd", ".", "Series", ")", ":", "x", "=", "pd", ".", "Series", "(", "x", ")", "return", "pd", ".", "Series", ".", "kurtosis", "(", "x", ")" ]
Returns the kurtosis of x (calculated with the adjusted Fisher-Pearson standardized moment coefficient G2). :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "kurtosis", "of", "x", "(", "calculated", "with", "the", "adjusted", "Fisher", "-", "Pearson", "standardized", "moment", "coefficient", "G2", ")", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L650-L662
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
longest_strike_below_mean
def longest_strike_below_mean(x): """ Returns the length of the longest consecutive subsequence in x that is smaller than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ if not isinstan...
python
def longest_strike_below_mean(x): """ Returns the length of the longest consecutive subsequence in x that is smaller than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ if not isinstan...
[ "def", "longest_strike_below_mean", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "max", "(", ...
Returns the length of the longest consecutive subsequence in x that is smaller than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "length", "of", "the", "longest", "consecutive", "subsequence", "in", "x", "that", "is", "smaller", "than", "the", "mean", "of", "x" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L683-L694
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
count_above_mean
def count_above_mean(x): """ Returns the number of values in x that are higher than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ m = np.mean(x) return np.where(x > m)[0].size
python
def count_above_mean(x): """ Returns the number of values in x that are higher than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ m = np.mean(x) return np.where(x > m)[0].size
[ "def", "count_above_mean", "(", "x", ")", ":", "m", "=", "np", ".", "mean", "(", "x", ")", "return", "np", ".", "where", "(", "x", ">", "m", ")", "[", "0", "]", ".", "size" ]
Returns the number of values in x that are higher than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "number", "of", "values", "in", "x", "that", "are", "higher", "than", "the", "mean", "of", "x" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L713-L723
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
count_below_mean
def count_below_mean(x): """ Returns the number of values in x that are lower than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ m = np.mean(x) return np.where(x < m)[0].size
python
def count_below_mean(x): """ Returns the number of values in x that are lower than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ m = np.mean(x) return np.where(x < m)[0].size
[ "def", "count_below_mean", "(", "x", ")", ":", "m", "=", "np", ".", "mean", "(", "x", ")", "return", "np", ".", "where", "(", "x", "<", "m", ")", "[", "0", "]", ".", "size" ]
Returns the number of values in x that are lower than the mean of x :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "number", "of", "values", "in", "x", "that", "are", "lower", "than", "the", "mean", "of", "x" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L727-L737
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
last_location_of_maximum
def last_location_of_maximum(x): """ Returns the relative last location of the maximum value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float ...
python
def last_location_of_maximum(x): """ Returns the relative last location of the maximum value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float ...
[ "def", "last_location_of_maximum", "(", "x", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "1.0", "-", "np", ".", "argmax", "(", "x", "[", ":", ":", "-", "1", "]", ")", "/", "len", "(", "x", ")", "if", "len", "(", "x", ...
Returns the relative last location of the maximum value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "relative", "last", "location", "of", "the", "maximum", "value", "of", "x", ".", "The", "position", "is", "calculated", "relatively", "to", "the", "length", "of", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L741-L752
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
first_location_of_maximum
def first_location_of_maximum(x): """ Returns the first location of the maximum value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ ...
python
def first_location_of_maximum(x): """ Returns the first location of the maximum value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ ...
[ "def", "first_location_of_maximum", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "argmax", "(...
Returns the first location of the maximum value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "first", "location", "of", "the", "maximum", "value", "of", "x", ".", "The", "position", "is", "calculated", "relatively", "to", "the", "length", "of", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L756-L768
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
last_location_of_minimum
def last_location_of_minimum(x): """ Returns the last location of the minimal value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ ...
python
def last_location_of_minimum(x): """ Returns the last location of the minimal value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ ...
[ "def", "last_location_of_minimum", "(", "x", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "1.0", "-", "np", ".", "argmin", "(", "x", "[", ":", ":", "-", "1", "]", ")", "/", "len", "(", "x", ")", "if", "len", "(", "x", ...
Returns the last location of the minimal value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "last", "location", "of", "the", "minimal", "value", "of", "x", ".", "The", "position", "is", "calculated", "relatively", "to", "the", "length", "of", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L772-L783
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
first_location_of_minimum
def first_location_of_minimum(x): """ Returns the first location of the minimal value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ ...
python
def first_location_of_minimum(x): """ Returns the first location of the minimal value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ ...
[ "def", "first_location_of_minimum", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "return", "np", ".", "argmin", "(...
Returns the first location of the minimal value of x. The position is calculated relatively to the length of x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "first", "location", "of", "the", "minimal", "value", "of", "x", ".", "The", "position", "is", "calculated", "relatively", "to", "the", "length", "of", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L787-L799
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
percentage_of_reoccurring_datapoints_to_all_datapoints
def percentage_of_reoccurring_datapoints_to_all_datapoints(x): """ Returns the percentage of unique values, that are present in the time series more than once. len(different values occurring more than once) / len(different values) This means the percentage is normalized to the number of unique...
python
def percentage_of_reoccurring_datapoints_to_all_datapoints(x): """ Returns the percentage of unique values, that are present in the time series more than once. len(different values occurring more than once) / len(different values) This means the percentage is normalized to the number of unique...
[ "def", "percentage_of_reoccurring_datapoints_to_all_datapoints", "(", "x", ")", ":", "if", "len", "(", "x", ")", "==", "0", ":", "return", "np", ".", "nan", "unique", ",", "counts", "=", "np", ".", "unique", "(", "x", ",", "return_counts", "=", "True", "...
Returns the percentage of unique values, that are present in the time series more than once. len(different values occurring more than once) / len(different values) This means the percentage is normalized to the number of unique values, in contrast to the percentage_of_reoccurring_values_to_all_val...
[ "Returns", "the", "percentage", "of", "unique", "values", "that", "are", "present", "in", "the", "time", "series", "more", "than", "once", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L803-L826
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
percentage_of_reoccurring_values_to_all_values
def percentage_of_reoccurring_values_to_all_values(x): """ Returns the ratio of unique values, that are present in the time series more than once. # of data points occurring more than once / # of all data points This means the ratio is normalized to the number of data points in the time series...
python
def percentage_of_reoccurring_values_to_all_values(x): """ Returns the ratio of unique values, that are present in the time series more than once. # of data points occurring more than once / # of all data points This means the ratio is normalized to the number of data points in the time series...
[ "def", "percentage_of_reoccurring_values_to_all_values", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "pd", ".", "Series", ")", ":", "x", "=", "pd", ".", "Series", "(", "x", ")", "if", "x", ".", "size", "==", "0", ":", "return", "np"...
Returns the ratio of unique values, that are present in the time series more than once. # of data points occurring more than once / # of all data points This means the ratio is normalized to the number of data points in the time series, in contrast to the percentage_of_reoccurring_datapoints_to_al...
[ "Returns", "the", "ratio", "of", "unique", "values", "that", "are", "present", "in", "the", "time", "series", "more", "than", "once", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L830-L857
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
sum_of_reoccurring_values
def sum_of_reoccurring_values(x): """ Returns the sum of all values, that are present in the time series more than once. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ unique, counts = np.unique...
python
def sum_of_reoccurring_values(x): """ Returns the sum of all values, that are present in the time series more than once. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ unique, counts = np.unique...
[ "def", "sum_of_reoccurring_values", "(", "x", ")", ":", "unique", ",", "counts", "=", "np", ".", "unique", "(", "x", ",", "return_counts", "=", "True", ")", "counts", "[", "counts", "<", "2", "]", "=", "0", "counts", "[", "counts", ">", "1", "]", "...
Returns the sum of all values, that are present in the time series more than once. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "sum", "of", "all", "values", "that", "are", "present", "in", "the", "time", "series", "more", "than", "once", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L861-L874
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
sum_of_reoccurring_data_points
def sum_of_reoccurring_data_points(x): """ Returns the sum of all data points, that are present in the time series more than once. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ unique, counts =...
python
def sum_of_reoccurring_data_points(x): """ Returns the sum of all data points, that are present in the time series more than once. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float """ unique, counts =...
[ "def", "sum_of_reoccurring_data_points", "(", "x", ")", ":", "unique", ",", "counts", "=", "np", ".", "unique", "(", "x", ",", "return_counts", "=", "True", ")", "counts", "[", "counts", "<", "2", "]", "=", "0", "return", "np", ".", "sum", "(", "coun...
Returns the sum of all data points, that are present in the time series more than once. :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature :return type: float
[ "Returns", "the", "sum", "of", "all", "data", "points", "that", "are", "present", "in", "the", "time", "series", "more", "than", "once", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L878-L890
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
ratio_value_number_to_time_series_length
def ratio_value_number_to_time_series_length(x): """ Returns a factor which is 1 if all values in the time series occur only once, and below one if this is not the case. In principle, it just returns # unique values / # values :param x: the time series to calculate the feature of :type...
python
def ratio_value_number_to_time_series_length(x): """ Returns a factor which is 1 if all values in the time series occur only once, and below one if this is not the case. In principle, it just returns # unique values / # values :param x: the time series to calculate the feature of :type...
[ "def", "ratio_value_number_to_time_series_length", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "if", "x", ".", "siz...
Returns a factor which is 1 if all values in the time series occur only once, and below one if this is not the case. In principle, it just returns # unique values / # values :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this feature ...
[ "Returns", "a", "factor", "which", "is", "1", "if", "all", "values", "in", "the", "time", "series", "occur", "only", "once", "and", "below", "one", "if", "this", "is", "not", "the", "case", ".", "In", "principle", "it", "just", "returns" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L894-L912
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
fft_coefficient
def fft_coefficient(x, param): """ Calculates the fourier coefficients of the one-dimensional discrete Fourier Transform for real input by fast fourier transformation algorithm .. math:: A_k = \\sum_{m=0}^{n-1} a_m \\exp \\left \\{ -2 \\pi i \\frac{m k}{n} \\right \\}, \\qquad k = 0, \...
python
def fft_coefficient(x, param): """ Calculates the fourier coefficients of the one-dimensional discrete Fourier Transform for real input by fast fourier transformation algorithm .. math:: A_k = \\sum_{m=0}^{n-1} a_m \\exp \\left \\{ -2 \\pi i \\frac{m k}{n} \\right \\}, \\qquad k = 0, \...
[ "def", "fft_coefficient", "(", "x", ",", "param", ")", ":", "assert", "min", "(", "[", "config", "[", "\"coeff\"", "]", "for", "config", "in", "param", "]", ")", ">=", "0", ",", "\"Coefficients must be positive or zero.\"", "assert", "set", "(", "[", "conf...
Calculates the fourier coefficients of the one-dimensional discrete Fourier Transform for real input by fast fourier transformation algorithm .. math:: A_k = \\sum_{m=0}^{n-1} a_m \\exp \\left \\{ -2 \\pi i \\frac{m k}{n} \\right \\}, \\qquad k = 0, \\ldots , n-1. The resulting coefficien...
[ "Calculates", "the", "fourier", "coefficients", "of", "the", "one", "-", "dimensional", "discrete", "Fourier", "Transform", "for", "real", "input", "by", "fast", "fourier", "transformation", "algorithm" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L916-L956
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
fft_aggregated
def fft_aggregated(x, param): """ Returns the spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform spectrum. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param param: contains dictionaries {"aggtype": s} where s str and in ["centr...
python
def fft_aggregated(x, param): """ Returns the spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform spectrum. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param param: contains dictionaries {"aggtype": s} where s str and in ["centr...
[ "def", "fft_aggregated", "(", "x", ",", "param", ")", ":", "assert", "set", "(", "[", "config", "[", "\"aggtype\"", "]", "for", "config", "in", "param", "]", ")", "<=", "set", "(", "[", "\"centroid\"", ",", "\"variance\"", ",", "\"skew\"", ",", "\"kurt...
Returns the spectral centroid (mean), variance, skew, and kurtosis of the absolute fourier transform spectrum. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param param: contains dictionaries {"aggtype": s} where s str and in ["centroid", "variance", "skew", "kurtosi...
[ "Returns", "the", "spectral", "centroid", "(", "mean", ")", "variance", "skew", "and", "kurtosis", "of", "the", "absolute", "fourier", "transform", "spectrum", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L960-L1063
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
number_peaks
def number_peaks(x, n): """ Calculates the number of peaks of at least support n in the time series x. A peak of support n is defined as a subsequence of x where a value occurs, which is bigger than its n neighbours to the left and to the right. Hence in the sequence >>> x = [3, 0, 0, 4, 0, 0, 13]...
python
def number_peaks(x, n): """ Calculates the number of peaks of at least support n in the time series x. A peak of support n is defined as a subsequence of x where a value occurs, which is bigger than its n neighbours to the left and to the right. Hence in the sequence >>> x = [3, 0, 0, 4, 0, 0, 13]...
[ "def", "number_peaks", "(", "x", ",", "n", ")", ":", "x_reduced", "=", "x", "[", "n", ":", "-", "n", "]", "res", "=", "None", "for", "i", "in", "range", "(", "1", ",", "n", "+", "1", ")", ":", "result_first", "=", "(", "x_reduced", ">", "_rol...
Calculates the number of peaks of at least support n in the time series x. A peak of support n is defined as a subsequence of x where a value occurs, which is bigger than its n neighbours to the left and to the right. Hence in the sequence >>> x = [3, 0, 0, 4, 0, 0, 13] 4 is a peak of support 1 and 2...
[ "Calculates", "the", "number", "of", "peaks", "of", "at", "least", "support", "n", "in", "the", "time", "series", "x", ".", "A", "peak", "of", "support", "n", "is", "defined", "as", "a", "subsequence", "of", "x", "where", "a", "value", "occurs", "which...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1067-L1103
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
index_mass_quantile
def index_mass_quantile(x, param): """ Those apply features calculate the relative index i where q% of the mass of the time series x lie left of i. For example for q = 50% this feature calculator will return the mass center of the time series :param x: the time series to calculate the feature of :t...
python
def index_mass_quantile(x, param): """ Those apply features calculate the relative index i where q% of the mass of the time series x lie left of i. For example for q = 50% this feature calculator will return the mass center of the time series :param x: the time series to calculate the feature of :t...
[ "def", "index_mass_quantile", "(", "x", ",", "param", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "abs_x", "=", "np", ".", "abs", "(", "x", ")", "s", "=", "sum", "(", "abs_x", ")", "if", "s", "==", "0", ":", "# all values in x are ze...
Those apply features calculate the relative index i where q% of the mass of the time series x lie left of i. For example for q = 50% this feature calculator will return the mass center of the time series :param x: the time series to calculate the feature of :type x: numpy.ndarray :param param: contains...
[ "Those", "apply", "features", "calculate", "the", "relative", "index", "i", "where", "q%", "of", "the", "mass", "of", "the", "time", "series", "x", "lie", "left", "of", "i", ".", "For", "example", "for", "q", "=", "50%", "this", "feature", "calculator", ...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1107-L1131
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
number_cwt_peaks
def number_cwt_peaks(x, n): """ This feature calculator searches for different peaks in x. To do so, x is smoothed by a ricker wavelet and for widths ranging from 1 to n. This feature calculator returns the number of peaks that occur at enough width scales and with sufficiently high Signal-to-Noise-Rati...
python
def number_cwt_peaks(x, n): """ This feature calculator searches for different peaks in x. To do so, x is smoothed by a ricker wavelet and for widths ranging from 1 to n. This feature calculator returns the number of peaks that occur at enough width scales and with sufficiently high Signal-to-Noise-Rati...
[ "def", "number_cwt_peaks", "(", "x", ",", "n", ")", ":", "return", "len", "(", "find_peaks_cwt", "(", "vector", "=", "x", ",", "widths", "=", "np", ".", "array", "(", "list", "(", "range", "(", "1", ",", "n", "+", "1", ")", ")", ")", ",", "wave...
This feature calculator searches for different peaks in x. To do so, x is smoothed by a ricker wavelet and for widths ranging from 1 to n. This feature calculator returns the number of peaks that occur at enough width scales and with sufficiently high Signal-to-Noise-Ratio (SNR) :param x: the time series t...
[ "This", "feature", "calculator", "searches", "for", "different", "peaks", "in", "x", ".", "To", "do", "so", "x", "is", "smoothed", "by", "a", "ricker", "wavelet", "and", "for", "widths", "ranging", "from", "1", "to", "n", ".", "This", "feature", "calcula...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1135-L1148
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
linear_trend
def linear_trend(x, param): """ Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one. This feature assumes the signal to be uniformly sampled. It will not use the time stamps to fit the model. The parameters c...
python
def linear_trend(x, param): """ Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one. This feature assumes the signal to be uniformly sampled. It will not use the time stamps to fit the model. The parameters c...
[ "def", "linear_trend", "(", "x", ",", "param", ")", ":", "# todo: we could use the index of the DataFrame here", "linReg", "=", "linregress", "(", "range", "(", "len", "(", "x", ")", ")", ",", "x", ")", "return", "[", "(", "\"attr_\\\"{}\\\"\"", ".", "format",...
Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one. This feature assumes the signal to be uniformly sampled. It will not use the time stamps to fit the model. The parameters control which of the characteristics are ...
[ "Calculate", "a", "linear", "least", "-", "squares", "regression", "for", "the", "values", "of", "the", "time", "series", "versus", "the", "sequence", "from", "0", "to", "length", "of", "the", "time", "series", "minus", "one", ".", "This", "feature", "assu...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1152-L1173
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
cwt_coefficients
def cwt_coefficients(x, param): """ Calculates a Continuous wavelet transform for the Ricker wavelet, also known as the "Mexican hat wavelet" which is defined by .. math:: \\frac{2}{\\sqrt{3a} \\pi^{\\frac{1}{4}}} (1 - \\frac{x^2}{a^2}) exp(-\\frac{x^2}{2a^2}) where :math:`a` is the width ...
python
def cwt_coefficients(x, param): """ Calculates a Continuous wavelet transform for the Ricker wavelet, also known as the "Mexican hat wavelet" which is defined by .. math:: \\frac{2}{\\sqrt{3a} \\pi^{\\frac{1}{4}}} (1 - \\frac{x^2}{a^2}) exp(-\\frac{x^2}{2a^2}) where :math:`a` is the width ...
[ "def", "cwt_coefficients", "(", "x", ",", "param", ")", ":", "calculated_cwt", "=", "{", "}", "res", "=", "[", "]", "indices", "=", "[", "]", "for", "parameter_combination", "in", "param", ":", "widths", "=", "parameter_combination", "[", "\"widths\"", "]"...
Calculates a Continuous wavelet transform for the Ricker wavelet, also known as the "Mexican hat wavelet" which is defined by .. math:: \\frac{2}{\\sqrt{3a} \\pi^{\\frac{1}{4}}} (1 - \\frac{x^2}{a^2}) exp(-\\frac{x^2}{2a^2}) where :math:`a` is the width parameter of the wavelet function. This...
[ "Calculates", "a", "Continuous", "wavelet", "transform", "for", "the", "Ricker", "wavelet", "also", "known", "as", "the", "Mexican", "hat", "wavelet", "which", "is", "defined", "by" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1177-L1221
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
spkt_welch_density
def spkt_welch_density(x, param): """ This feature calculator estimates the cross power spectral density of the time series x at different frequencies. To do so, the time series is first shifted from the time domain to the frequency domain. The feature calculators returns the power spectrum of the diff...
python
def spkt_welch_density(x, param): """ This feature calculator estimates the cross power spectral density of the time series x at different frequencies. To do so, the time series is first shifted from the time domain to the frequency domain. The feature calculators returns the power spectrum of the diff...
[ "def", "spkt_welch_density", "(", "x", ",", "param", ")", ":", "freq", ",", "pxx", "=", "welch", "(", "x", ",", "nperseg", "=", "min", "(", "len", "(", "x", ")", ",", "256", ")", ")", "coeff", "=", "[", "config", "[", "\"coeff\"", "]", "for", "...
This feature calculator estimates the cross power spectral density of the time series x at different frequencies. To do so, the time series is first shifted from the time domain to the frequency domain. The feature calculators returns the power spectrum of the different frequencies. :param x: the time ser...
[ "This", "feature", "calculator", "estimates", "the", "cross", "power", "spectral", "density", "of", "the", "time", "series", "x", "at", "different", "frequencies", ".", "To", "do", "so", "the", "time", "series", "is", "first", "shifted", "from", "the", "time...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1225-L1254
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
ar_coefficient
def ar_coefficient(x, param): """ This feature calculator fits the unconditional maximum likelihood of an autoregressive AR(k) process. The k parameter is the maximum lag of the process .. math:: X_{t}=\\varphi_0 +\\sum _{{i=1}}^{k}\\varphi_{i}X_{{t-i}}+\\varepsilon_{t} For the config...
python
def ar_coefficient(x, param): """ This feature calculator fits the unconditional maximum likelihood of an autoregressive AR(k) process. The k parameter is the maximum lag of the process .. math:: X_{t}=\\varphi_0 +\\sum _{{i=1}}^{k}\\varphi_{i}X_{{t-i}}+\\varepsilon_{t} For the config...
[ "def", "ar_coefficient", "(", "x", ",", "param", ")", ":", "calculated_ar_params", "=", "{", "}", "x_as_list", "=", "list", "(", "x", ")", "calculated_AR", "=", "AR", "(", "x_as_list", ")", "res", "=", "{", "}", "for", "parameter_combination", "in", "par...
This feature calculator fits the unconditional maximum likelihood of an autoregressive AR(k) process. The k parameter is the maximum lag of the process .. math:: X_{t}=\\varphi_0 +\\sum _{{i=1}}^{k}\\varphi_{i}X_{{t-i}}+\\varepsilon_{t} For the configurations from param which should contain t...
[ "This", "feature", "calculator", "fits", "the", "unconditional", "maximum", "likelihood", "of", "an", "autoregressive", "AR", "(", "k", ")", "process", ".", "The", "k", "parameter", "is", "the", "maximum", "lag", "of", "the", "process" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1258-L1307
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
change_quantiles
def change_quantiles(x, ql, qh, isabs, f_agg): """ First fixes a corridor given by the quantiles ql and qh of the distribution of x. Then calculates the average, absolute value of consecutive changes of the series x inside this corridor. Think about selecting a corridor on the y-Axis and only calcu...
python
def change_quantiles(x, ql, qh, isabs, f_agg): """ First fixes a corridor given by the quantiles ql and qh of the distribution of x. Then calculates the average, absolute value of consecutive changes of the series x inside this corridor. Think about selecting a corridor on the y-Axis and only calcu...
[ "def", "change_quantiles", "(", "x", ",", "ql", ",", "qh", ",", "isabs", ",", "f_agg", ")", ":", "if", "ql", ">=", "qh", ":", "ValueError", "(", "\"ql={} should be lower than qh={}\"", ".", "format", "(", "ql", ",", "qh", ")", ")", "div", "=", "np", ...
First fixes a corridor given by the quantiles ql and qh of the distribution of x. Then calculates the average, absolute value of consecutive changes of the series x inside this corridor. Think about selecting a corridor on the y-Axis and only calculating the mean of the absolute change of the time series i...
[ "First", "fixes", "a", "corridor", "given", "by", "the", "quantiles", "ql", "and", "qh", "of", "the", "distribution", "of", "x", ".", "Then", "calculates", "the", "average", "absolute", "value", "of", "consecutive", "changes", "of", "the", "series", "x", "...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1311-L1353
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
time_reversal_asymmetry_statistic
def time_reversal_asymmetry_statistic(x, lag): """ This function calculates the value of .. math:: \\frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_{i + lag} - x_{i + lag} \cdot x_{i}^2 which is .. math:: \\mathbb{E}[L^2(X)^2 \cdot L(X) - L(X) \cdot X^2] ...
python
def time_reversal_asymmetry_statistic(x, lag): """ This function calculates the value of .. math:: \\frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_{i + lag} - x_{i + lag} \cdot x_{i}^2 which is .. math:: \\mathbb{E}[L^2(X)^2 \cdot L(X) - L(X) \cdot X^2] ...
[ "def", "time_reversal_asymmetry_statistic", "(", "x", ",", "lag", ")", ":", "n", "=", "len", "(", "x", ")", "x", "=", "np", ".", "asarray", "(", "x", ")", "if", "2", "*", "lag", ">=", "n", ":", "return", "0", "else", ":", "one_lag", "=", "_roll",...
This function calculates the value of .. math:: \\frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_{i + lag} - x_{i + lag} \cdot x_{i}^2 which is .. math:: \\mathbb{E}[L^2(X)^2 \cdot L(X) - L(X) \cdot X^2] where :math:`\\mathbb{E}` is the mean and :math:`L` is the...
[ "This", "function", "calculates", "the", "value", "of" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1358-L1395
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
c3
def c3(x, lag): """ This function calculates the value of .. math:: \\frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_{i + lag} \cdot x_{i} which is .. math:: \\mathbb{E}[L^2(X)^2 \cdot L(X) \cdot X] where :math:`\\mathbb{E}` is the mean and :math:`L` is t...
python
def c3(x, lag): """ This function calculates the value of .. math:: \\frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_{i + lag} \cdot x_{i} which is .. math:: \\mathbb{E}[L^2(X)^2 \cdot L(X) \cdot X] where :math:`\\mathbb{E}` is the mean and :math:`L` is t...
[ "def", "c3", "(", "x", ",", "lag", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "n", "=", "x", ".", "size", "if", "2...
This function calculates the value of .. math:: \\frac{1}{n-2lag} \sum_{i=0}^{n-2lag} x_{i + 2 \cdot lag}^2 \cdot x_{i + lag} \cdot x_{i} which is .. math:: \\mathbb{E}[L^2(X)^2 \cdot L(X) \cdot X] where :math:`\\mathbb{E}` is the mean and :math:`L` is the lag operator. It was prop...
[ "This", "function", "calculates", "the", "value", "of" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1399-L1435
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
binned_entropy
def binned_entropy(x, max_bins): """ First bins the values of x into max_bins equidistant bins. Then calculates the value of .. math:: - \\sum_{k=0}^{min(max\\_bins, len(x))} p_k log(p_k) \\cdot \\mathbf{1}_{(p_k > 0)} where :math:`p_k` is the percentage of samples in bin :math:`k`. ...
python
def binned_entropy(x, max_bins): """ First bins the values of x into max_bins equidistant bins. Then calculates the value of .. math:: - \\sum_{k=0}^{min(max\\_bins, len(x))} p_k log(p_k) \\cdot \\mathbf{1}_{(p_k > 0)} where :math:`p_k` is the percentage of samples in bin :math:`k`. ...
[ "def", "binned_entropy", "(", "x", ",", "max_bins", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "hist", ",", "bin_edges", ...
First bins the values of x into max_bins equidistant bins. Then calculates the value of .. math:: - \\sum_{k=0}^{min(max\\_bins, len(x))} p_k log(p_k) \\cdot \\mathbf{1}_{(p_k > 0)} where :math:`p_k` is the percentage of samples in bin :math:`k`. :param x: the time series to calculate the fe...
[ "First", "bins", "the", "values", "of", "x", "into", "max_bins", "equidistant", "bins", ".", "Then", "calculates", "the", "value", "of" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1439-L1461
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
sample_entropy
def sample_entropy(x): """ Calculate and return sample entropy of x. .. rubric:: References | [1] http://en.wikipedia.org/wiki/Sample_Entropy | [2] https://www.ncbi.nlm.nih.gov/pubmed/10843903?dopt=Abstract :param x: the time series to calculate the feature of :type x: numpy.ndarray ...
python
def sample_entropy(x): """ Calculate and return sample entropy of x. .. rubric:: References | [1] http://en.wikipedia.org/wiki/Sample_Entropy | [2] https://www.ncbi.nlm.nih.gov/pubmed/10843903?dopt=Abstract :param x: the time series to calculate the feature of :type x: numpy.ndarray ...
[ "def", "sample_entropy", "(", "x", ")", ":", "x", "=", "np", ".", "array", "(", "x", ")", "sample_length", "=", "1", "# number of sequential points of the time series", "tolerance", "=", "0.2", "*", "np", ".", "std", "(", "x", ")", "# 0.2 is a common value for...
Calculate and return sample entropy of x. .. rubric:: References | [1] http://en.wikipedia.org/wiki/Sample_Entropy | [2] https://www.ncbi.nlm.nih.gov/pubmed/10843903?dopt=Abstract :param x: the time series to calculate the feature of :type x: numpy.ndarray :return: the value of this featur...
[ "Calculate", "and", "return", "sample", "entropy", "of", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1467-L1517
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
autocorrelation
def autocorrelation(x, lag): """ Calculates the autocorrelation of the specified lag, according to the formula [1] .. math:: \\frac{1}{(n-l)\sigma^{2}} \\sum_{t=1}^{n-l}(X_{t}-\\mu )(X_{t+l}-\\mu) where :math:`n` is the length of the time series :math:`X_i`, :math:`\sigma^2` its variance and ...
python
def autocorrelation(x, lag): """ Calculates the autocorrelation of the specified lag, according to the formula [1] .. math:: \\frac{1}{(n-l)\sigma^{2}} \\sum_{t=1}^{n-l}(X_{t}-\\mu )(X_{t+l}-\\mu) where :math:`n` is the length of the time series :math:`X_i`, :math:`\sigma^2` its variance and ...
[ "def", "autocorrelation", "(", "x", ",", "lag", ")", ":", "# This is important: If a series is passed, the product below is calculated", "# based on the index, which corresponds to squaring the series.", "if", "type", "(", "x", ")", "is", "pd", ".", "Series", ":", "x", "=",...
Calculates the autocorrelation of the specified lag, according to the formula [1] .. math:: \\frac{1}{(n-l)\sigma^{2}} \\sum_{t=1}^{n-l}(X_{t}-\\mu )(X_{t+l}-\\mu) where :math:`n` is the length of the time series :math:`X_i`, :math:`\sigma^2` its variance and :math:`\mu` its mean. `l` denotes the...
[ "Calculates", "the", "autocorrelation", "of", "the", "specified", "lag", "according", "to", "the", "formula", "[", "1", "]" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1521-L1561
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
quantile
def quantile(x, q): """ Calculates the q quantile of x. This is the value of x greater than q% of the ordered values from x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param q: the quantile to calculate :type q: float :return: the value of this feature ...
python
def quantile(x, q): """ Calculates the q quantile of x. This is the value of x greater than q% of the ordered values from x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param q: the quantile to calculate :type q: float :return: the value of this feature ...
[ "def", "quantile", "(", "x", ",", "q", ")", ":", "x", "=", "pd", ".", "Series", "(", "x", ")", "return", "pd", ".", "Series", ".", "quantile", "(", "x", ",", "q", ")" ]
Calculates the q quantile of x. This is the value of x greater than q% of the ordered values from x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param q: the quantile to calculate :type q: float :return: the value of this feature :return type: float
[ "Calculates", "the", "q", "quantile", "of", "x", ".", "This", "is", "the", "value", "of", "x", "greater", "than", "q%", "of", "the", "ordered", "values", "from", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1565-L1577
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
number_crossing_m
def number_crossing_m(x, m): """ Calculates the number of crossings of x on m. A crossing is defined as two sequential values where the first value is lower than m and the next is greater, or vice-versa. If you set m to zero, you will get the number of zero crossings. :param x: the time series to c...
python
def number_crossing_m(x, m): """ Calculates the number of crossings of x on m. A crossing is defined as two sequential values where the first value is lower than m and the next is greater, or vice-versa. If you set m to zero, you will get the number of zero crossings. :param x: the time series to c...
[ "def", "number_crossing_m", "(", "x", ",", "m", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "# From https://stackoverflow.com/q...
Calculates the number of crossings of x on m. A crossing is defined as two sequential values where the first value is lower than m and the next is greater, or vice-versa. If you set m to zero, you will get the number of zero crossings. :param x: the time series to calculate the feature of :type x: nump...
[ "Calculates", "the", "number", "of", "crossings", "of", "x", "on", "m", ".", "A", "crossing", "is", "defined", "as", "two", "sequential", "values", "where", "the", "first", "value", "is", "lower", "than", "m", "and", "the", "next", "is", "greater", "or",...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1581-L1598
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
value_count
def value_count(x, value): """ Count occurrences of `value` in time series x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param value: the value to be counted :type value: int or float :return: the count :rtype: int """ if not isinstance(x, (np....
python
def value_count(x, value): """ Count occurrences of `value` in time series x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param value: the value to be counted :type value: int or float :return: the count :rtype: int """ if not isinstance(x, (np....
[ "def", "value_count", "(", "x", ",", "value", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "if", "np", ".", "isnan", "("...
Count occurrences of `value` in time series x. :param x: the time series to calculate the feature of :type x: numpy.ndarray :param value: the value to be counted :type value: int or float :return: the count :rtype: int
[ "Count", "occurrences", "of", "value", "in", "time", "series", "x", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1630-L1647
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
range_count
def range_count(x, min, max): """ Count observed values within the interval [min, max). :param x: the time series to calculate the feature of :type x: numpy.ndarray :param min: the inclusive lower bound of the range :type min: int or float :param max: the exclusive upper bound of the range ...
python
def range_count(x, min, max): """ Count observed values within the interval [min, max). :param x: the time series to calculate the feature of :type x: numpy.ndarray :param min: the inclusive lower bound of the range :type min: int or float :param max: the exclusive upper bound of the range ...
[ "def", "range_count", "(", "x", ",", "min", ",", "max", ")", ":", "return", "np", ".", "sum", "(", "(", "x", ">=", "min", ")", "&", "(", "x", "<", "max", ")", ")" ]
Count observed values within the interval [min, max). :param x: the time series to calculate the feature of :type x: numpy.ndarray :param min: the inclusive lower bound of the range :type min: int or float :param max: the exclusive upper bound of the range :type max: int or float :return: t...
[ "Count", "observed", "values", "within", "the", "interval", "[", "min", "max", ")", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1651-L1664
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
approximate_entropy
def approximate_entropy(x, m, r): """ Implements a vectorized Approximate entropy algorithm. https://en.wikipedia.org/wiki/Approximate_entropy For short time-series this method is highly dependent on the parameters, but should be stable for N > 2000, see: Yentes et al. (2012) - ...
python
def approximate_entropy(x, m, r): """ Implements a vectorized Approximate entropy algorithm. https://en.wikipedia.org/wiki/Approximate_entropy For short time-series this method is highly dependent on the parameters, but should be stable for N > 2000, see: Yentes et al. (2012) - ...
[ "def", "approximate_entropy", "(", "x", ",", "m", ",", "r", ")", ":", "if", "not", "isinstance", "(", "x", ",", "(", "np", ".", "ndarray", ",", "pd", ".", "Series", ")", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "N", "=", "x", ...
Implements a vectorized Approximate entropy algorithm. https://en.wikipedia.org/wiki/Approximate_entropy For short time-series this method is highly dependent on the parameters, but should be stable for N > 2000, see: Yentes et al. (2012) - *The Appropriate Use of Approximate Entropy ...
[ "Implements", "a", "vectorized", "Approximate", "entropy", "algorithm", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1669-L1713
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
friedrich_coefficients
def friedrich_coefficients(x, param): """ Coefficients of polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot{x}(t) = h(x(t)) + \mathcal{N}(0,R) as described by [1]. For short time-series this method is highly dependent on the ...
python
def friedrich_coefficients(x, param): """ Coefficients of polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot{x}(t) = h(x(t)) + \mathcal{N}(0,R) as described by [1]. For short time-series this method is highly dependent on the ...
[ "def", "friedrich_coefficients", "(", "x", ",", "param", ")", ":", "calculated", "=", "{", "}", "# calculated is dictionary storing the calculated coefficients {m: {r: friedrich_coefficients}}", "res", "=", "{", "}", "# res is a dictionary containg the results {\"m_10__r_2__coeff_3...
Coefficients of polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot{x}(t) = h(x(t)) + \mathcal{N}(0,R) as described by [1]. For short time-series this method is highly dependent on the parameters. .. rubric:: References | [1...
[ "Coefficients", "of", "polynomial", ":", "math", ":", "h", "(", "x", ")", "which", "has", "been", "fitted", "to", "the", "deterministic", "dynamics", "of", "Langevin", "model" ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1717-L1764
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
max_langevin_fixed_point
def max_langevin_fixed_point(x, r, m): """ Largest fixed point of dynamics :math:argmax_x {h(x)=0}` estimated from polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot(x)(t) = h(x(t)) + R \mathcal(N)(0,1) as described by Fr...
python
def max_langevin_fixed_point(x, r, m): """ Largest fixed point of dynamics :math:argmax_x {h(x)=0}` estimated from polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot(x)(t) = h(x(t)) + R \mathcal(N)(0,1) as described by Fr...
[ "def", "max_langevin_fixed_point", "(", "x", ",", "r", ",", "m", ")", ":", "coeff", "=", "_estimate_friedrich_coefficients", "(", "x", ",", "m", ",", "r", ")", "try", ":", "max_fixed_point", "=", "np", ".", "max", "(", "np", ".", "real", "(", "np", "...
Largest fixed point of dynamics :math:argmax_x {h(x)=0}` estimated from polynomial :math:`h(x)`, which has been fitted to the deterministic dynamics of Langevin model .. math:: \dot(x)(t) = h(x(t)) + R \mathcal(N)(0,1) as described by Friedrich et al. (2000): Physics Letters A 271, p. 21...
[ "Largest", "fixed", "point", "of", "dynamics", ":", "math", ":", "argmax_x", "{", "h", "(", "x", ")", "=", "0", "}", "estimated", "from", "polynomial", ":", "math", ":", "h", "(", "x", ")", "which", "has", "been", "fitted", "to", "the", "deterministi...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1768-L1801
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
agg_linear_trend
def agg_linear_trend(x, param): """ Calculates a linear least-squares regression for values of the time series that were aggregated over chunks versus the sequence from 0 up to the number of chunks minus one. This feature assumes the signal to be uniformly sampled. It will not use the time stamps to fi...
python
def agg_linear_trend(x, param): """ Calculates a linear least-squares regression for values of the time series that were aggregated over chunks versus the sequence from 0 up to the number of chunks minus one. This feature assumes the signal to be uniformly sampled. It will not use the time stamps to fi...
[ "def", "agg_linear_trend", "(", "x", ",", "param", ")", ":", "# todo: we could use the index of the DataFrame here", "calculated_agg", "=", "{", "}", "res_data", "=", "[", "]", "res_index", "=", "[", "]", "for", "parameter_combination", "in", "param", ":", "chunk_...
Calculates a linear least-squares regression for values of the time series that were aggregated over chunks versus the sequence from 0 up to the number of chunks minus one. This feature assumes the signal to be uniformly sampled. It will not use the time stamps to fit the model. The parameters attr contro...
[ "Calculates", "a", "linear", "least", "-", "squares", "regression", "for", "values", "of", "the", "time", "series", "that", "were", "aggregated", "over", "chunks", "versus", "the", "sequence", "from", "0", "up", "to", "the", "number", "of", "chunks", "minus"...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1805-L1854
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
energy_ratio_by_chunks
def energy_ratio_by_chunks(x, param): """ Calculates the sum of squares of chunk i out of N chunks expressed as a ratio with the sum of squares over the whole series. Takes as input parameters the number num_segments of segments to divide the series into and segment_focus which is the segment numbe...
python
def energy_ratio_by_chunks(x, param): """ Calculates the sum of squares of chunk i out of N chunks expressed as a ratio with the sum of squares over the whole series. Takes as input parameters the number num_segments of segments to divide the series into and segment_focus which is the segment numbe...
[ "def", "energy_ratio_by_chunks", "(", "x", ",", "param", ")", ":", "res_data", "=", "[", "]", "res_index", "=", "[", "]", "full_series_energy", "=", "np", ".", "sum", "(", "x", "**", "2", ")", "for", "parameter_combination", "in", "param", ":", "num_segm...
Calculates the sum of squares of chunk i out of N chunks expressed as a ratio with the sum of squares over the whole series. Takes as input parameters the number num_segments of segments to divide the series into and segment_focus which is the segment number (starting at zero) to return a feature on. ...
[ "Calculates", "the", "sum", "of", "squares", "of", "chunk", "i", "out", "of", "N", "chunks", "expressed", "as", "a", "ratio", "with", "the", "sum", "of", "squares", "over", "the", "whole", "series", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1858-L1892
train
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
linear_trend_timewise
def linear_trend_timewise(x, param): """ Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one. This feature uses the index of the time series to fit the model, which must be of a datetime dtype. The parame...
python
def linear_trend_timewise(x, param): """ Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one. This feature uses the index of the time series to fit the model, which must be of a datetime dtype. The parame...
[ "def", "linear_trend_timewise", "(", "x", ",", "param", ")", ":", "ix", "=", "x", ".", "index", "# Get differences between each timestamp and the first timestamp in seconds.", "# Then convert to hours and reshape for linear regression", "times_seconds", "=", "(", "ix", "-", "...
Calculate a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus one. This feature uses the index of the time series to fit the model, which must be of a datetime dtype. The parameters control which of the characteristics are ret...
[ "Calculate", "a", "linear", "least", "-", "squares", "regression", "for", "the", "values", "of", "the", "time", "series", "versus", "the", "sequence", "from", "0", "to", "length", "of", "the", "time", "series", "minus", "one", ".", "This", "feature", "uses...
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L1899-L1927
train
blue-yonder/tsfresh
tsfresh/transformers/feature_selector.py
FeatureSelector.fit
def fit(self, X, y): """ Extract the information, which of the features are relevent using the given target. For more information, please see the :func:`~tsfresh.festure_selection.festure_selector.check_fs_sig_bh` function. All columns in the input data sample are treated as feature. Th...
python
def fit(self, X, y): """ Extract the information, which of the features are relevent using the given target. For more information, please see the :func:`~tsfresh.festure_selection.festure_selector.check_fs_sig_bh` function. All columns in the input data sample are treated as feature. Th...
[ "def", "fit", "(", "self", ",", "X", ",", "y", ")", ":", "if", "not", "isinstance", "(", "X", ",", "pd", ".", "DataFrame", ")", ":", "X", "=", "pd", ".", "DataFrame", "(", "X", ".", "copy", "(", ")", ")", "if", "not", "isinstance", "(", "y", ...
Extract the information, which of the features are relevent using the given target. For more information, please see the :func:`~tsfresh.festure_selection.festure_selector.check_fs_sig_bh` function. All columns in the input data sample are treated as feature. The index of all rows in X must be ...
[ "Extract", "the", "information", "which", "of", "the", "features", "are", "relevent", "using", "the", "given", "target", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/feature_selector.py#L118-L151
train
blue-yonder/tsfresh
tsfresh/transformers/feature_selector.py
FeatureSelector.transform
def transform(self, X): """ Delete all features, which were not relevant in the fit phase. :param X: data sample with all features, which will be reduced to only those that are relevant :type X: pandas.DataSeries or numpy.array :return: same data sample as X, but with only the ...
python
def transform(self, X): """ Delete all features, which were not relevant in the fit phase. :param X: data sample with all features, which will be reduced to only those that are relevant :type X: pandas.DataSeries or numpy.array :return: same data sample as X, but with only the ...
[ "def", "transform", "(", "self", ",", "X", ")", ":", "if", "self", ".", "relevant_features", "is", "None", ":", "raise", "RuntimeError", "(", "\"You have to call fit before.\"", ")", "if", "isinstance", "(", "X", ",", "pd", ".", "DataFrame", ")", ":", "ret...
Delete all features, which were not relevant in the fit phase. :param X: data sample with all features, which will be reduced to only those that are relevant :type X: pandas.DataSeries or numpy.array :return: same data sample as X, but with only the relevant features :rtype: pandas.Dat...
[ "Delete", "all", "features", "which", "were", "not", "relevant", "in", "the", "fit", "phase", "." ]
c72c9c574371cf7dd7d54e00a466792792e5d202
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/transformers/feature_selector.py#L153-L169
train