repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.sell | def sell(self, product_id, order_type, **kwargs):
"""Place a sell order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
... | python | def sell(self, product_id, order_type, **kwargs):
"""Place a sell order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
... | [
"def",
"sell",
"(",
"self",
",",
"product_id",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"place_order",
"(",
"product_id",
",",
"'sell'",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")"
] | Place a sell order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
place_market_order, and place_stop_order.
Args:
... | [
"Place",
"a",
"sell",
"order",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L278-L296 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.place_market_order | def place_market_order(self, product_id, side, size=None, funds=None,
client_oid=None,
stp=None,
overdraft_enabled=None,
funding_amount=None):
""" Place market order.
Args:
product_id... | python | def place_market_order(self, product_id, side, size=None, funds=None,
client_oid=None,
stp=None,
overdraft_enabled=None,
funding_amount=None):
""" Place market order.
Args:
product_id... | [
"def",
"place_market_order",
"(",
"self",
",",
"product_id",
",",
"side",
",",
"size",
"=",
"None",
",",
"funds",
"=",
"None",
",",
"client_oid",
"=",
"None",
",",
"stp",
"=",
"None",
",",
"overdraft_enabled",
"=",
"None",
",",
"funding_amount",
"=",
"No... | Place market order.
Args:
product_id (str): Product to order (eg. 'BTC-USD')
side (str): Order side ('buy' or 'sell)
size (Optional[Decimal]): Desired amount in crypto. Specify this or
`funds`.
funds (Optional[Decimal]): Desired amount of quote cu... | [
"Place",
"market",
"order",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L354-L393 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.cancel_all | def cancel_all(self, product_id=None):
""" With best effort, cancel all open orders.
Args:
product_id (Optional[str]): Only cancel orders for this
product_id
Returns:
list: A list of ids of the canceled orders. Example::
[
... | python | def cancel_all(self, product_id=None):
""" With best effort, cancel all open orders.
Args:
product_id (Optional[str]): Only cancel orders for this
product_id
Returns:
list: A list of ids of the canceled orders. Example::
[
... | [
"def",
"cancel_all",
"(",
"self",
",",
"product_id",
"=",
"None",
")",
":",
"if",
"product_id",
"is",
"not",
"None",
":",
"params",
"=",
"{",
"'product_id'",
":",
"product_id",
"}",
"else",
":",
"params",
"=",
"None",
"return",
"self",
".",
"_send_messag... | With best effort, cancel all open orders.
Args:
product_id (Optional[str]): Only cancel orders for this
product_id
Returns:
list: A list of ids of the canceled orders. Example::
[
"144c6f8e-713f-4682-8435-5280fbe8b2b4",
... | [
"With",
"best",
"effort",
"cancel",
"all",
"open",
"orders",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L460-L482 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_orders | def get_orders(self, product_id=None, status=None, **kwargs):
""" List your current open orders.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Only open or un-settled orders are returned. As soon as an
order is no longer open ... | python | def get_orders(self, product_id=None, status=None, **kwargs):
""" List your current open orders.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Only open or un-settled orders are returned. As soon as an
order is no longer open ... | [
"def",
"get_orders",
"(",
"self",
",",
"product_id",
"=",
"None",
",",
"status",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"kwargs",
"if",
"product_id",
"is",
"not",
"None",
":",
"params",
"[",
"'product_id'",
"]",
"=",
"product_id... | List your current open orders.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Only open or un-settled orders are returned. As soon as an
order is no longer open and settled, it will no longer appear
in the default request.
... | [
"List",
"your",
"current",
"open",
"orders",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L519-L582 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_fundings | def get_fundings(self, status=None, **kwargs):
""" Every order placed with a margin profile that draws funding
will create a funding record.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
status (list/str): Li... | python | def get_fundings(self, status=None, **kwargs):
""" Every order placed with a margin profile that draws funding
will create a funding record.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
status (list/str): Li... | [
"def",
"get_fundings",
"(",
"self",
",",
"status",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"if",
"status",
"is",
"not",
"None",
":",
"params",
"[",
"'status'",
"]",
"=",
"status",
"params",
".",
"update",
"(",
"kwar... | Every order placed with a margin profile that draws funding
will create a funding record.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
status (list/str): Limit funding records to these statuses.
** O... | [
"Every",
"order",
"placed",
"with",
"a",
"margin",
"profile",
"that",
"draws",
"funding",
"will",
"create",
"a",
"funding",
"record",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L642-L679 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.repay_funding | def repay_funding(self, amount, currency):
""" Repay funding. Repays the older funding records first.
Args:
amount (int): Amount of currency to repay
currency (str): The currency, example USD
Returns:
Not specified by cbpro.
"""
params = {
... | python | def repay_funding(self, amount, currency):
""" Repay funding. Repays the older funding records first.
Args:
amount (int): Amount of currency to repay
currency (str): The currency, example USD
Returns:
Not specified by cbpro.
"""
params = {
... | [
"def",
"repay_funding",
"(",
"self",
",",
"amount",
",",
"currency",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
"# example: USD",
"}",
"return",
"self",
".",
"_send_message",
"(",
"'post'",
",",
"'/funding/re... | Repay funding. Repays the older funding records first.
Args:
amount (int): Amount of currency to repay
currency (str): The currency, example USD
Returns:
Not specified by cbpro. | [
"Repay",
"funding",
".",
"Repays",
"the",
"older",
"funding",
"records",
"first",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L681-L697 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.margin_transfer | def margin_transfer(self, margin_profile_id, transfer_type, currency,
amount):
""" Transfer funds between your standard profile and a margin profile.
Args:
margin_profile_id (str): Margin profile ID to withdraw or deposit
from.
transfer_ty... | python | def margin_transfer(self, margin_profile_id, transfer_type, currency,
amount):
""" Transfer funds between your standard profile and a margin profile.
Args:
margin_profile_id (str): Margin profile ID to withdraw or deposit
from.
transfer_ty... | [
"def",
"margin_transfer",
"(",
"self",
",",
"margin_profile_id",
",",
"transfer_type",
",",
"currency",
",",
"amount",
")",
":",
"params",
"=",
"{",
"'margin_profile_id'",
":",
"margin_profile_id",
",",
"'type'",
":",
"transfer_type",
",",
"'currency'",
":",
"cu... | Transfer funds between your standard profile and a margin profile.
Args:
margin_profile_id (str): Margin profile ID to withdraw or deposit
from.
transfer_type (str): 'deposit' or 'withdraw'
currency (str): Currency to transfer (eg. 'USD')
amount (... | [
"Transfer",
"funds",
"between",
"your",
"standard",
"profile",
"and",
"a",
"margin",
"profile",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L699-L734 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.close_position | def close_position(self, repay_only):
""" Close position.
Args:
repay_only (bool): Undocumented by cbpro.
Returns:
Undocumented
"""
params = {'repay_only': repay_only}
return self._send_message('post', '/position/close',
... | python | def close_position(self, repay_only):
""" Close position.
Args:
repay_only (bool): Undocumented by cbpro.
Returns:
Undocumented
"""
params = {'repay_only': repay_only}
return self._send_message('post', '/position/close',
... | [
"def",
"close_position",
"(",
"self",
",",
"repay_only",
")",
":",
"params",
"=",
"{",
"'repay_only'",
":",
"repay_only",
"}",
"return",
"self",
".",
"_send_message",
"(",
"'post'",
",",
"'/position/close'",
",",
"data",
"=",
"json",
".",
"dumps",
"(",
"pa... | Close position.
Args:
repay_only (bool): Undocumented by cbpro.
Returns:
Undocumented | [
"Close",
"position",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L745-L757 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.withdraw | def withdraw(self, amount, currency, payment_method_id):
""" Withdraw funds to a payment method.
See AuthenticatedClient.get_payment_methods() to receive
information regarding payment methods.
Args:
amount (Decimal): The amount to withdraw.
currency (str): Curre... | python | def withdraw(self, amount, currency, payment_method_id):
""" Withdraw funds to a payment method.
See AuthenticatedClient.get_payment_methods() to receive
information regarding payment methods.
Args:
amount (Decimal): The amount to withdraw.
currency (str): Curre... | [
"def",
"withdraw",
"(",
"self",
",",
"amount",
",",
"currency",
",",
"payment_method_id",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
",",
"'payment_method_id'",
":",
"payment_method_id",
"}",
"return",
"self",
... | Withdraw funds to a payment method.
See AuthenticatedClient.get_payment_methods() to receive
information regarding payment methods.
Args:
amount (Decimal): The amount to withdraw.
currency (str): Currency type (eg. 'BTC')
payment_method_id (str): ID of the p... | [
"Withdraw",
"funds",
"to",
"a",
"payment",
"method",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L816-L841 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.coinbase_withdraw | def coinbase_withdraw(self, amount, currency, coinbase_account_id):
""" Withdraw funds to a coinbase account.
You can move funds between your Coinbase accounts and your cbpro
trading accounts within your daily limits. Moving funds between
Coinbase and cbpro is instant and free.
... | python | def coinbase_withdraw(self, amount, currency, coinbase_account_id):
""" Withdraw funds to a coinbase account.
You can move funds between your Coinbase accounts and your cbpro
trading accounts within your daily limits. Moving funds between
Coinbase and cbpro is instant and free.
... | [
"def",
"coinbase_withdraw",
"(",
"self",
",",
"amount",
",",
"currency",
",",
"coinbase_account_id",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
",",
"'coinbase_account_id'",
":",
"coinbase_account_id",
"}",
"retu... | Withdraw funds to a coinbase account.
You can move funds between your Coinbase accounts and your cbpro
trading accounts within your daily limits. Moving funds between
Coinbase and cbpro is instant and free.
See AuthenticatedClient.get_coinbase_accounts() to receive
information ... | [
"Withdraw",
"funds",
"to",
"a",
"coinbase",
"account",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L843-L871 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.crypto_withdraw | def crypto_withdraw(self, amount, currency, crypto_address):
""" Withdraw funds to a crypto address.
Args:
amount (Decimal): The amount to withdraw
currency (str): The type of currency (eg. 'BTC')
crypto_address (str): Crypto address to withdraw to.
Returns:... | python | def crypto_withdraw(self, amount, currency, crypto_address):
""" Withdraw funds to a crypto address.
Args:
amount (Decimal): The amount to withdraw
currency (str): The type of currency (eg. 'BTC')
crypto_address (str): Crypto address to withdraw to.
Returns:... | [
"def",
"crypto_withdraw",
"(",
"self",
",",
"amount",
",",
"currency",
",",
"crypto_address",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
",",
"'crypto_address'",
":",
"crypto_address",
"}",
"return",
"self",
... | Withdraw funds to a crypto address.
Args:
amount (Decimal): The amount to withdraw
currency (str): The type of currency (eg. 'BTC')
crypto_address (str): Crypto address to withdraw to.
Returns:
dict: Withdraw details. Example::
{
... | [
"Withdraw",
"funds",
"to",
"a",
"crypto",
"address",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L873-L894 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.create_report | def create_report(self, report_type, start_date, end_date, product_id=None,
account_id=None, report_format='pdf', email=None):
""" Create report of historic information about your account.
The report will be generated when resources are available. Report status
can be quer... | python | def create_report(self, report_type, start_date, end_date, product_id=None,
account_id=None, report_format='pdf', email=None):
""" Create report of historic information about your account.
The report will be generated when resources are available. Report status
can be quer... | [
"def",
"create_report",
"(",
"self",
",",
"report_type",
",",
"start_date",
",",
"end_date",
",",
"product_id",
"=",
"None",
",",
"account_id",
"=",
"None",
",",
"report_format",
"=",
"'pdf'",
",",
"email",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'ty... | Create report of historic information about your account.
The report will be generated when resources are available. Report status
can be queried via `get_report(report_id)`.
Args:
report_type (str): 'fills' or 'account'
start_date (str): Starting date for the report in... | [
"Create",
"report",
"of",
"historic",
"information",
"about",
"your",
"account",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L914-L961 | train |
danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient.get_product_order_book | def get_product_order_book(self, product_id, level=1):
"""Get a list of open orders for a product.
The amount of detail shown can be customized with the `level`
parameter:
* 1: Only the best bid and ask
* 2: Top 50 bids and asks (aggregated)
* 3: Full order book (non agg... | python | def get_product_order_book(self, product_id, level=1):
"""Get a list of open orders for a product.
The amount of detail shown can be customized with the `level`
parameter:
* 1: Only the best bid and ask
* 2: Top 50 bids and asks (aggregated)
* 3: Full order book (non agg... | [
"def",
"get_product_order_book",
"(",
"self",
",",
"product_id",
",",
"level",
"=",
"1",
")",
":",
"params",
"=",
"{",
"'level'",
":",
"level",
"}",
"return",
"self",
".",
"_send_message",
"(",
"'get'",
",",
"'/products/{}/book'",
".",
"format",
"(",
"prod... | Get a list of open orders for a product.
The amount of detail shown can be customized with the `level`
parameter:
* 1: Only the best bid and ask
* 2: Top 50 bids and asks (aggregated)
* 3: Full order book (non aggregated)
Level 1 and Level 2 are recommended for polling.... | [
"Get",
"a",
"list",
"of",
"open",
"orders",
"for",
"a",
"product",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L52-L90 | train |
danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient.get_product_trades | def get_product_trades(self, product_id, before='', after='', limit=None, result=None):
"""List the latest trades for a product.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
product_id (str): Product
b... | python | def get_product_trades(self, product_id, before='', after='', limit=None, result=None):
"""List the latest trades for a product.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
product_id (str): Product
b... | [
"def",
"get_product_trades",
"(",
"self",
",",
"product_id",
",",
"before",
"=",
"''",
",",
"after",
"=",
"''",
",",
"limit",
"=",
"None",
",",
"result",
"=",
"None",
")",
":",
"return",
"self",
".",
"_send_paginated_message",
"(",
"'/products/{}/trades'",
... | List the latest trades for a product.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
product_id (str): Product
before (Optional[str]): start time in ISO 8601
after (Optional[str]): end time in ISO 8... | [
"List",
"the",
"latest",
"trades",
"for",
"a",
"product",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L117-L147 | train |
danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient.get_product_historic_rates | def get_product_historic_rates(self, product_id, start=None, end=None,
granularity=None):
"""Historic rates for a product.
Rates are returned in grouped buckets based on requested
`granularity`. If start, end, and granularity aren't provided,
the excha... | python | def get_product_historic_rates(self, product_id, start=None, end=None,
granularity=None):
"""Historic rates for a product.
Rates are returned in grouped buckets based on requested
`granularity`. If start, end, and granularity aren't provided,
the excha... | [
"def",
"get_product_historic_rates",
"(",
"self",
",",
"product_id",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"granularity",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"start",
"is",
"not",
"None",
":",
"params",
"[",
"'start... | Historic rates for a product.
Rates are returned in grouped buckets based on requested
`granularity`. If start, end, and granularity aren't provided,
the exchange will assume some (currently unknown) default values.
Historical rate data may be incomplete. No data is published for
... | [
"Historic",
"rates",
"for",
"a",
"product",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L149-L200 | train |
danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient._send_message | def _send_message(self, method, endpoint, params=None, data=None):
"""Send API request.
Args:
method (str): HTTP method (get, post, delete, etc.)
endpoint (str): Endpoint (to be added to base URL)
params (Optional[dict]): HTTP request parameters
data (Opt... | python | def _send_message(self, method, endpoint, params=None, data=None):
"""Send API request.
Args:
method (str): HTTP method (get, post, delete, etc.)
endpoint (str): Endpoint (to be added to base URL)
params (Optional[dict]): HTTP request parameters
data (Opt... | [
"def",
"_send_message",
"(",
"self",
",",
"method",
",",
"endpoint",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"url",
"+",
"endpoint",
"r",
"=",
"self",
".",
"session",
".",
"request",
"(",
"method",
"... | Send API request.
Args:
method (str): HTTP method (get, post, delete, etc.)
endpoint (str): Endpoint (to be added to base URL)
params (Optional[dict]): HTTP request parameters
data (Optional[str]): JSON-encoded string payload for POST
Returns:
... | [
"Send",
"API",
"request",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L254-L270 | train |
danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient._send_paginated_message | def _send_paginated_message(self, endpoint, params=None):
""" Send API message that results in a paginated response.
The paginated responses are abstracted away by making API requests on
demand as the response is iterated over.
Paginated API messages support 3 additional parameters: `b... | python | def _send_paginated_message(self, endpoint, params=None):
""" Send API message that results in a paginated response.
The paginated responses are abstracted away by making API requests on
demand as the response is iterated over.
Paginated API messages support 3 additional parameters: `b... | [
"def",
"_send_paginated_message",
"(",
"self",
",",
"endpoint",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"dict",
"(",
")",
"url",
"=",
"self",
".",
"url",
"+",
"endpoint",
"while",
"True",
":",
"r",
"=",... | Send API message that results in a paginated response.
The paginated responses are abstracted away by making API requests on
demand as the response is iterated over.
Paginated API messages support 3 additional parameters: `before`,
`after`, and `limit`. `before` and `after` are mutuall... | [
"Send",
"API",
"message",
"that",
"results",
"in",
"a",
"paginated",
"response",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L272-L311 | train |
dask/dask-ml | dask_ml/model_selection/_search.py | check_cv | def check_cv(cv=3, y=None, classifier=False):
"""Dask aware version of ``sklearn.model_selection.check_cv``
Same as the scikit-learn version, but works if ``y`` is a dask object.
"""
if cv is None:
cv = 3
# If ``cv`` is not an integer, the scikit-learn implementation doesn't
# touch th... | python | def check_cv(cv=3, y=None, classifier=False):
"""Dask aware version of ``sklearn.model_selection.check_cv``
Same as the scikit-learn version, but works if ``y`` is a dask object.
"""
if cv is None:
cv = 3
# If ``cv`` is not an integer, the scikit-learn implementation doesn't
# touch th... | [
"def",
"check_cv",
"(",
"cv",
"=",
"3",
",",
"y",
"=",
"None",
",",
"classifier",
"=",
"False",
")",
":",
"if",
"cv",
"is",
"None",
":",
"cv",
"=",
"3",
"# If ``cv`` is not an integer, the scikit-learn implementation doesn't",
"# touch the ``y`` object, so passing o... | Dask aware version of ``sklearn.model_selection.check_cv``
Same as the scikit-learn version, but works if ``y`` is a dask object. | [
"Dask",
"aware",
"version",
"of",
"sklearn",
".",
"model_selection",
".",
"check_cv"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L900-L918 | train |
dask/dask-ml | dask_ml/model_selection/_search.py | compute_n_splits | def compute_n_splits(cv, X, y=None, groups=None):
"""Return the number of splits.
Parameters
----------
cv : BaseCrossValidator
X, y, groups : array_like, dask object, or None
Returns
-------
n_splits : int
"""
if not any(is_dask_collection(i) for i in (X, y, groups)):
... | python | def compute_n_splits(cv, X, y=None, groups=None):
"""Return the number of splits.
Parameters
----------
cv : BaseCrossValidator
X, y, groups : array_like, dask object, or None
Returns
-------
n_splits : int
"""
if not any(is_dask_collection(i) for i in (X, y, groups)):
... | [
"def",
"compute_n_splits",
"(",
"cv",
",",
"X",
",",
"y",
"=",
"None",
",",
"groups",
"=",
"None",
")",
":",
"if",
"not",
"any",
"(",
"is_dask_collection",
"(",
"i",
")",
"for",
"i",
"in",
"(",
"X",
",",
"y",
",",
"groups",
")",
")",
":",
"retu... | Return the number of splits.
Parameters
----------
cv : BaseCrossValidator
X, y, groups : array_like, dask object, or None
Returns
-------
n_splits : int | [
"Return",
"the",
"number",
"of",
"splits",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L921-L956 | train |
dask/dask-ml | dask_ml/model_selection/_search.py | StaticDaskSearchMixin.visualize | def visualize(self, filename="mydask", format=None, **kwargs):
"""Render the task graph for this parameter search using ``graphviz``.
Requires ``graphviz`` to be installed.
Parameters
----------
filename : str or None, optional
The name (without an extension) of the... | python | def visualize(self, filename="mydask", format=None, **kwargs):
"""Render the task graph for this parameter search using ``graphviz``.
Requires ``graphviz`` to be installed.
Parameters
----------
filename : str or None, optional
The name (without an extension) of the... | [
"def",
"visualize",
"(",
"self",
",",
"filename",
"=",
"\"mydask\"",
",",
"format",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"dask_graph_\"",
")",
"return",
"dask",
".",
"visualize",
"(",
"self",
".",
"dask_g... | Render the task graph for this parameter search using ``graphviz``.
Requires ``graphviz`` to be installed.
Parameters
----------
filename : str or None, optional
The name (without an extension) of the file to write to disk. If
`filename` is None, no file will b... | [
"Render",
"the",
"task",
"graph",
"for",
"this",
"parameter",
"search",
"using",
"graphviz",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L975-L1000 | train |
dask/dask-ml | dask_ml/model_selection/_search.py | DaskBaseSearchCV.fit | def fit(self, X, y=None, groups=None, **fit_params):
"""Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
... | python | def fit(self, X, y=None, groups=None, **fit_params):
"""Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"groups",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"estimator",
"=",
"self",
".",
"estimator",
"from",
"sklearn",
".",
"metrics",
".",
"scorer",
"import",
"_check_multimetric_s... | Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array-like, shape = [n_samples] or [n_samples, n_out... | [
"Run",
"fit",
"with",
"all",
"sets",
"of",
"parameters",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L1117-L1212 | train |
dask/dask-ml | dask_ml/model_selection/_search.py | RandomizedSearchCV._get_param_iterator | def _get_param_iterator(self):
"""Return ParameterSampler instance for the given distributions"""
return model_selection.ParameterSampler(
self.param_distributions, self.n_iter, random_state=self.random_state
) | python | def _get_param_iterator(self):
"""Return ParameterSampler instance for the given distributions"""
return model_selection.ParameterSampler(
self.param_distributions, self.n_iter, random_state=self.random_state
) | [
"def",
"_get_param_iterator",
"(",
"self",
")",
":",
"return",
"model_selection",
".",
"ParameterSampler",
"(",
"self",
".",
"param_distributions",
",",
"self",
".",
"n_iter",
",",
"random_state",
"=",
"self",
".",
"random_state",
")"
] | Return ParameterSampler instance for the given distributions | [
"Return",
"ParameterSampler",
"instance",
"for",
"the",
"given",
"distributions"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L1605-L1609 | train |
dask/dask-ml | dask_ml/model_selection/_incremental.py | _partial_fit | def _partial_fit(model_and_meta, X, y, fit_params):
"""
Call partial_fit on a classifiers with training data X and y
Arguments
---------
model_and_meta : Tuple[Estimator, dict]
X, y : np.ndarray, np.ndarray
Training data
fit_params : dict
Extra keyword arguments to pass to p... | python | def _partial_fit(model_and_meta, X, y, fit_params):
"""
Call partial_fit on a classifiers with training data X and y
Arguments
---------
model_and_meta : Tuple[Estimator, dict]
X, y : np.ndarray, np.ndarray
Training data
fit_params : dict
Extra keyword arguments to pass to p... | [
"def",
"_partial_fit",
"(",
"model_and_meta",
",",
"X",
",",
"y",
",",
"fit_params",
")",
":",
"with",
"log_errors",
"(",
")",
":",
"start",
"=",
"time",
"(",
")",
"model",
",",
"meta",
"=",
"model_and_meta",
"if",
"len",
"(",
"X",
")",
":",
"model",... | Call partial_fit on a classifiers with training data X and y
Arguments
---------
model_and_meta : Tuple[Estimator, dict]
X, y : np.ndarray, np.ndarray
Training data
fit_params : dict
Extra keyword arguments to pass to partial_fit
Returns
-------
Results
A namedt... | [
"Call",
"partial_fit",
"on",
"a",
"classifiers",
"with",
"training",
"data",
"X",
"and",
"y"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L30-L86 | train |
dask/dask-ml | dask_ml/model_selection/_incremental.py | _create_model | def _create_model(model, ident, **params):
""" Create a model by cloning and then setting params """
with log_errors(pdb=True):
model = clone(model).set_params(**params)
return model, {"model_id": ident, "params": params, "partial_fit_calls": 0} | python | def _create_model(model, ident, **params):
""" Create a model by cloning and then setting params """
with log_errors(pdb=True):
model = clone(model).set_params(**params)
return model, {"model_id": ident, "params": params, "partial_fit_calls": 0} | [
"def",
"_create_model",
"(",
"model",
",",
"ident",
",",
"*",
"*",
"params",
")",
":",
"with",
"log_errors",
"(",
"pdb",
"=",
"True",
")",
":",
"model",
"=",
"clone",
"(",
"model",
")",
".",
"set_params",
"(",
"*",
"*",
"params",
")",
"return",
"mo... | Create a model by cloning and then setting params | [
"Create",
"a",
"model",
"by",
"cloning",
"and",
"then",
"setting",
"params"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L102-L106 | train |
dask/dask-ml | dask_ml/model_selection/_incremental.py | fit | def fit(
model,
params,
X_train,
y_train,
X_test,
y_test,
additional_calls,
fit_params=None,
scorer=None,
random_state=None,
):
""" Find a good model and search among a space of hyper-parameters
This does a hyper-parameter search by creating many models and then fitting
... | python | def fit(
model,
params,
X_train,
y_train,
X_test,
y_test,
additional_calls,
fit_params=None,
scorer=None,
random_state=None,
):
""" Find a good model and search among a space of hyper-parameters
This does a hyper-parameter search by creating many models and then fitting
... | [
"def",
"fit",
"(",
"model",
",",
"params",
",",
"X_train",
",",
"y_train",
",",
"X_test",
",",
"y_test",
",",
"additional_calls",
",",
"fit_params",
"=",
"None",
",",
"scorer",
"=",
"None",
",",
"random_state",
"=",
"None",
",",
")",
":",
"return",
"de... | Find a good model and search among a space of hyper-parameters
This does a hyper-parameter search by creating many models and then fitting
them incrementally on batches of data and reducing the number of models based
on the scores computed during training. Over time fewer and fewer models
remain. We ... | [
"Find",
"a",
"good",
"model",
"and",
"search",
"among",
"a",
"space",
"of",
"hyper",
"-",
"parameters"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L273-L402 | train |
dask/dask-ml | dask_ml/model_selection/_incremental.py | BaseIncrementalSearchCV._check_array | def _check_array(self, X, **kwargs):
"""Validate the data arguments X and y.
By default, NumPy arrays are converted to 1-block dask arrays.
Parameters
----------
X, y : array-like
"""
if isinstance(X, np.ndarray):
X = da.from_array(X, X.shape)
... | python | def _check_array(self, X, **kwargs):
"""Validate the data arguments X and y.
By default, NumPy arrays are converted to 1-block dask arrays.
Parameters
----------
X, y : array-like
"""
if isinstance(X, np.ndarray):
X = da.from_array(X, X.shape)
... | [
"def",
"_check_array",
"(",
"self",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"X",
"=",
"da",
".",
"from_array",
"(",
"X",
",",
"X",
".",
"shape",
")",
"X",
"=",
"check_array... | Validate the data arguments X and y.
By default, NumPy arrays are converted to 1-block dask arrays.
Parameters
----------
X, y : array-like | [
"Validate",
"the",
"data",
"arguments",
"X",
"and",
"y",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L432-L444 | train |
dask/dask-ml | dask_ml/model_selection/_incremental.py | BaseIncrementalSearchCV.fit | def fit(self, X, y, **fit_params):
"""Find the best parameters for a particular model.
Parameters
----------
X, y : array-like
**fit_params
Additional partial fit keyword arguments for the estimator.
"""
return default_client().sync(self._fit, X, y, *... | python | def fit(self, X, y, **fit_params):
"""Find the best parameters for a particular model.
Parameters
----------
X, y : array-like
**fit_params
Additional partial fit keyword arguments for the estimator.
"""
return default_client().sync(self._fit, X, y, *... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"*",
"*",
"fit_params",
")",
":",
"return",
"default_client",
"(",
")",
".",
"sync",
"(",
"self",
".",
"_fit",
",",
"X",
",",
"y",
",",
"*",
"*",
"fit_params",
")"
] | Find the best parameters for a particular model.
Parameters
----------
X, y : array-like
**fit_params
Additional partial fit keyword arguments for the estimator. | [
"Find",
"the",
"best",
"parameters",
"for",
"a",
"particular",
"model",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L569-L578 | train |
dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit._check_array | def _check_array(self, X):
"""Validate an array for post-fit tasks.
Parameters
----------
X : Union[Array, DataFrame]
Returns
-------
same type as 'X'
Notes
-----
The following checks are applied.
- Ensure that the array is bloc... | python | def _check_array(self, X):
"""Validate an array for post-fit tasks.
Parameters
----------
X : Union[Array, DataFrame]
Returns
-------
same type as 'X'
Notes
-----
The following checks are applied.
- Ensure that the array is bloc... | [
"def",
"_check_array",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"da",
".",
"Array",
")",
":",
"if",
"X",
".",
"ndim",
"==",
"2",
"and",
"X",
".",
"numblocks",
"[",
"1",
"]",
">",
"1",
":",
"logger",
".",
"debug",
"(... | Validate an array for post-fit tasks.
Parameters
----------
X : Union[Array, DataFrame]
Returns
-------
same type as 'X'
Notes
-----
The following checks are applied.
- Ensure that the array is blocked only along the samples. | [
"Validate",
"an",
"array",
"for",
"post",
"-",
"fit",
"tasks",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L122-L146 | train |
dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.transform | def transform(self, X):
"""Transform block or partition-wise for dask inputs.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does no... | python | def transform(self, X):
"""Transform block or partition-wise for dask inputs.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does no... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_check_method",
"(",
"\"transform\"",
")",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"isinstance",
"(",
"X",
",",
"da",
".",
"Array",
")",
":",
"return",
"X",
".",... | Transform block or partition-wise for dask inputs.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``transform`` method, then... | [
"Transform",
"block",
"or",
"partition",
"-",
"wise",
"for",
"dask",
"inputs",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L185-L211 | train |
dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.score | def score(self, X, y, compute=True):
"""Returns the score on the given data.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input data, where n_samples is the number of samples and
n_features is the number of features.
y : array-li... | python | def score(self, X, y, compute=True):
"""Returns the score on the given data.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input data, where n_samples is the number of samples and
n_features is the number of features.
y : array-li... | [
"def",
"score",
"(",
"self",
",",
"X",
",",
"y",
",",
"compute",
"=",
"True",
")",
":",
"scoring",
"=",
"self",
".",
"scoring",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"y",
"=",
"self",
".",
"_check_array",
"(",
"y",
")",
"if",
"n... | Returns the score on the given data.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input data, where n_samples is the number of samples and
n_features is the number of features.
y : array-like, shape = [n_samples] or [n_samples, n_output]... | [
"Returns",
"the",
"score",
"on",
"the",
"given",
"data",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L213-L253 | train |
dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.predict | def predict(self, X):
"""Predict for X.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
Parameters
----------
X : array-like
Returns
... | python | def predict(self, X):
"""Predict for X.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
Parameters
----------
X : array-like
Returns
... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_check_method",
"(",
"\"predict\"",
")",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"isinstance",
"(",
"X",
",",
"da",
".",
"Array",
")",
":",
"result",
"=",
"X",
"... | Predict for X.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
Parameters
----------
X : array-like
Returns
-------
y : array-li... | [
"Predict",
"for",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L255-L285 | train |
dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.predict_log_proba | def predict_log_proba(self, X):
"""Log of proability estimates.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``pre... | python | def predict_log_proba(self, X):
"""Log of proability estimates.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``pre... | [
"def",
"predict_log_proba",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_check_method",
"(",
"\"predict_log_proba\"",
")",
"return",
"da",
".",
"log",
"(",
"self",
".",
"predict_proba",
"(",
"X",
")",
")"
] | Log of proability estimates.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``predict_proba``
method, then an ``Attr... | [
"Log",
"of",
"proability",
"estimates",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L322-L341 | train |
dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit._check_method | def _check_method(self, method):
"""Check if self.estimator has 'method'.
Raises
------
AttributeError
"""
estimator = self._postfit_estimator
if not hasattr(estimator, method):
msg = "The wrapped estimator '{}' does not have a '{}' method.".format(
... | python | def _check_method(self, method):
"""Check if self.estimator has 'method'.
Raises
------
AttributeError
"""
estimator = self._postfit_estimator
if not hasattr(estimator, method):
msg = "The wrapped estimator '{}' does not have a '{}' method.".format(
... | [
"def",
"_check_method",
"(",
"self",
",",
"method",
")",
":",
"estimator",
"=",
"self",
".",
"_postfit_estimator",
"if",
"not",
"hasattr",
"(",
"estimator",
",",
"method",
")",
":",
"msg",
"=",
"\"The wrapped estimator '{}' does not have a '{}' method.\"",
".",
"f... | Check if self.estimator has 'method'.
Raises
------
AttributeError | [
"Check",
"if",
"self",
".",
"estimator",
"has",
"method",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L343-L356 | train |
dask/dask-ml | dask_ml/linear_model/glm.py | _GLM.fit | def fit(self, X, y=None):
"""Fit the model on the training data
Parameters
----------
X: array-like, shape (n_samples, n_features)
y : array-like, shape (n_samples,)
Returns
-------
self : objectj
"""
X = self._check_array(X)
sol... | python | def fit(self, X, y=None):
"""Fit the model on the training data
Parameters
----------
X: array-like, shape (n_samples, n_features)
y : array-like, shape (n_samples,)
Returns
-------
self : objectj
"""
X = self._check_array(X)
sol... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"solver_kwargs",
"=",
"self",
".",
"_get_solver_kwargs",
"(",
")",
"self",
".",
"_coef",
"=",
"algorithms",
".",
"_solvers",
... | Fit the model on the training data
Parameters
----------
X: array-like, shape (n_samples, n_features)
y : array-like, shape (n_samples,)
Returns
-------
self : objectj | [
"Fit",
"the",
"model",
"on",
"the",
"training",
"data"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/linear_model/glm.py#L171-L193 | train |
dask/dask-ml | dask_ml/linear_model/glm.py | LogisticRegression.predict_proba | def predict_proba(self, X):
"""Probability estimates for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
The probability of the sample for each class i... | python | def predict_proba(self, X):
"""Probability estimates for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
The probability of the sample for each class i... | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
")",
":",
"X_",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"return",
"sigmoid",
"(",
"dot",
"(",
"X_",
",",
"self",
".",
"_coef",
")",
")"
] | Probability estimates for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
The probability of the sample for each class in the model. | [
"Probability",
"estimates",
"for",
"samples",
"in",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/linear_model/glm.py#L235-L248 | train |
dask/dask-ml | dask_ml/linear_model/glm.py | PoissonRegression.predict | def predict(self, X):
"""Predict count for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
C : array, shape = [n_samples,]
Predicted count for each sample
"""
X_ = self._check_array(... | python | def predict(self, X):
"""Predict count for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
C : array, shape = [n_samples,]
Predicted count for each sample
"""
X_ = self._check_array(... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"X_",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"return",
"exp",
"(",
"dot",
"(",
"X_",
",",
"self",
".",
"_coef",
")",
")"
] | Predict count for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
C : array, shape = [n_samples,]
Predicted count for each sample | [
"Predict",
"count",
"for",
"samples",
"in",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/linear_model/glm.py#L348-L361 | train |
dask/dask-ml | dask_ml/cluster/k_means.py | k_means | def k_means(
X,
n_clusters,
init="k-means||",
precompute_distances="auto",
n_init=1,
max_iter=300,
verbose=False,
tol=1e-4,
random_state=None,
copy_x=True,
n_jobs=-1,
algorithm="full",
return_n_iter=False,
oversampling_factor=2,
init_max_iter=None,
):
"""K... | python | def k_means(
X,
n_clusters,
init="k-means||",
precompute_distances="auto",
n_init=1,
max_iter=300,
verbose=False,
tol=1e-4,
random_state=None,
copy_x=True,
n_jobs=-1,
algorithm="full",
return_n_iter=False,
oversampling_factor=2,
init_max_iter=None,
):
"""K... | [
"def",
"k_means",
"(",
"X",
",",
"n_clusters",
",",
"init",
"=",
"\"k-means||\"",
",",
"precompute_distances",
"=",
"\"auto\"",
",",
"n_init",
"=",
"1",
",",
"max_iter",
"=",
"300",
",",
"verbose",
"=",
"False",
",",
"tol",
"=",
"1e-4",
",",
"random_stat... | K-means algorithm for clustering
Differences from scikit-learn:
* init='k-means||'
* oversampling_factor keyword
* n_jobs=-1 | [
"K",
"-",
"means",
"algorithm",
"for",
"clustering"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L236-L275 | train |
dask/dask-ml | dask_ml/cluster/k_means.py | k_init | def k_init(
X,
n_clusters,
init="k-means||",
random_state=None,
max_iter=None,
oversampling_factor=2,
):
"""Choose the initial centers for K-Means.
Parameters
----------
X : da.Array (n_samples, n_features)
n_clusters : int
Number of clusters to end up with
init ... | python | def k_init(
X,
n_clusters,
init="k-means||",
random_state=None,
max_iter=None,
oversampling_factor=2,
):
"""Choose the initial centers for K-Means.
Parameters
----------
X : da.Array (n_samples, n_features)
n_clusters : int
Number of clusters to end up with
init ... | [
"def",
"k_init",
"(",
"X",
",",
"n_clusters",
",",
"init",
"=",
"\"k-means||\"",
",",
"random_state",
"=",
"None",
",",
"max_iter",
"=",
"None",
",",
"oversampling_factor",
"=",
"2",
",",
")",
":",
"if",
"isinstance",
"(",
"init",
",",
"np",
".",
"ndar... | Choose the initial centers for K-Means.
Parameters
----------
X : da.Array (n_samples, n_features)
n_clusters : int
Number of clusters to end up with
init : {'k-means||', 'k-means++', 'random'} or numpy.ndarray
Initialization method, or pass a NumPy array to use
random_state : i... | [
"Choose",
"the",
"initial",
"centers",
"for",
"K",
"-",
"Means",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L291-L369 | train |
dask/dask-ml | dask_ml/cluster/k_means.py | init_pp | def init_pp(X, n_clusters, random_state):
"""K-means initialization using k-means++
This uses scikit-learn's implementation.
"""
x_squared_norms = row_norms(X, squared=True).compute()
logger.info("Initializing with k-means++")
with _timer("initialization of %2d centers" % n_clusters, _logger=lo... | python | def init_pp(X, n_clusters, random_state):
"""K-means initialization using k-means++
This uses scikit-learn's implementation.
"""
x_squared_norms = row_norms(X, squared=True).compute()
logger.info("Initializing with k-means++")
with _timer("initialization of %2d centers" % n_clusters, _logger=lo... | [
"def",
"init_pp",
"(",
"X",
",",
"n_clusters",
",",
"random_state",
")",
":",
"x_squared_norms",
"=",
"row_norms",
"(",
"X",
",",
"squared",
"=",
"True",
")",
".",
"compute",
"(",
")",
"logger",
".",
"info",
"(",
"\"Initializing with k-means++\"",
")",
"wi... | K-means initialization using k-means++
This uses scikit-learn's implementation. | [
"K",
"-",
"means",
"initialization",
"using",
"k",
"-",
"means",
"++"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L372-L384 | train |
dask/dask-ml | dask_ml/cluster/k_means.py | init_random | def init_random(X, n_clusters, random_state):
"""K-means initialization using randomly chosen points"""
logger.info("Initializing randomly")
idx = sorted(draw_seed(random_state, 0, len(X), size=n_clusters))
centers = X[idx].compute()
return centers | python | def init_random(X, n_clusters, random_state):
"""K-means initialization using randomly chosen points"""
logger.info("Initializing randomly")
idx = sorted(draw_seed(random_state, 0, len(X), size=n_clusters))
centers = X[idx].compute()
return centers | [
"def",
"init_random",
"(",
"X",
",",
"n_clusters",
",",
"random_state",
")",
":",
"logger",
".",
"info",
"(",
"\"Initializing randomly\"",
")",
"idx",
"=",
"sorted",
"(",
"draw_seed",
"(",
"random_state",
",",
"0",
",",
"len",
"(",
"X",
")",
",",
"size",... | K-means initialization using randomly chosen points | [
"K",
"-",
"means",
"initialization",
"using",
"randomly",
"chosen",
"points"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L388-L393 | train |
dask/dask-ml | dask_ml/cluster/k_means.py | init_scalable | def init_scalable(
X, n_clusters, random_state=None, max_iter=None, oversampling_factor=2
):
"""K-Means initialization using k-means||
This is algorithm 2 in Scalable K-Means++ (2012).
"""
logger.info("Initializing with k-means||")
# Step 1: Initialize Centers
idx = 0
centers = da.comp... | python | def init_scalable(
X, n_clusters, random_state=None, max_iter=None, oversampling_factor=2
):
"""K-Means initialization using k-means||
This is algorithm 2 in Scalable K-Means++ (2012).
"""
logger.info("Initializing with k-means||")
# Step 1: Initialize Centers
idx = 0
centers = da.comp... | [
"def",
"init_scalable",
"(",
"X",
",",
"n_clusters",
",",
"random_state",
"=",
"None",
",",
"max_iter",
"=",
"None",
",",
"oversampling_factor",
"=",
"2",
")",
":",
"logger",
".",
"info",
"(",
"\"Initializing with k-means||\"",
")",
"# Step 1: Initialize Centers",... | K-Means initialization using k-means||
This is algorithm 2 in Scalable K-Means++ (2012). | [
"K",
"-",
"Means",
"initialization",
"using",
"k",
"-",
"means||"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L397-L467 | train |
dask/dask-ml | dask_ml/cluster/k_means.py | _sample_points | def _sample_points(X, centers, oversampling_factor, random_state):
r"""
Sample points independently with probability
.. math::
p_x = \frac{\ell \cdot d^2(x, \mathcal{C})}{\phi_X(\mathcal{C})}
"""
# re-implement evaluate_cost here, to avoid redundant computation
distances = pairwise_di... | python | def _sample_points(X, centers, oversampling_factor, random_state):
r"""
Sample points independently with probability
.. math::
p_x = \frac{\ell \cdot d^2(x, \mathcal{C})}{\phi_X(\mathcal{C})}
"""
# re-implement evaluate_cost here, to avoid redundant computation
distances = pairwise_di... | [
"def",
"_sample_points",
"(",
"X",
",",
"centers",
",",
"oversampling_factor",
",",
"random_state",
")",
":",
"# re-implement evaluate_cost here, to avoid redundant computation",
"distances",
"=",
"pairwise_distances",
"(",
"X",
",",
"centers",
")",
".",
"min",
"(",
"... | r"""
Sample points independently with probability
.. math::
p_x = \frac{\ell \cdot d^2(x, \mathcal{C})}{\phi_X(\mathcal{C})} | [
"r",
"Sample",
"points",
"independently",
"with",
"probability"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L476-L495 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | RobustScaler.transform | def transform(self, X):
"""Center and scale the data.
Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.
Parameters
----------
X : {array-like, sparse matrix}
The data used to scale alon... | python | def transform(self, X):
"""Center and scale the data.
Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.
Parameters
----------
X : {array-like, sparse matrix}
The data used to scale alon... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"with_centering",
":",
"check_is_fitted",
"(",
"self",
",",
"\"center_\"",
")",
"if",
"self",
".",
"with_scaling",
":",
"check_is_fitted",
"(",
"self",
",",
"\"scale_\"",
")",
"X",
"... | Center and scale the data.
Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.
Parameters
----------
X : {array-like, sparse matrix}
The data used to scale along the specified axis.
This... | [
"Center",
"and",
"scale",
"the",
"data",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L168-L198 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | RobustScaler.inverse_transform | def inverse_transform(self, X):
"""Scale back the data to the original representation
Parameters
----------
X : array-like
The data used to scale along the specified axis.
This implementation was copied and modified from Scikit-Learn.
See License informatio... | python | def inverse_transform(self, X):
"""Scale back the data to the original representation
Parameters
----------
X : array-like
The data used to scale along the specified axis.
This implementation was copied and modified from Scikit-Learn.
See License informatio... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"center_\"",
",",
"\"scale_\"",
")",
"# if sparse.issparse(X):",
"# if self.with_scaling:",
"# inplace_column_scale(X, self.scale_)",
"# else:",
"if",
"self",
"... | Scale back the data to the original representation
Parameters
----------
X : array-like
The data used to scale along the specified axis.
This implementation was copied and modified from Scikit-Learn.
See License information here:
https://github.com/scikit-l... | [
"Scale",
"back",
"the",
"data",
"to",
"the",
"original",
"representation"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L200-L223 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | Categorizer.fit | def fit(self, X, y=None):
"""Find the categorical columns.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
self
"""
X = self._check_array(X)
if self.categories is not None:
# s... | python | def fit(self, X, y=None):
"""Find the categorical columns.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
self
"""
X = self._check_array(X)
if self.categories is not None:
# s... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"self",
".",
"categories",
"is",
"not",
"None",
":",
"# some basic validation",
"columns",
"=",
"pd",
".",
"Index",
"(... | Find the categorical columns.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
self | [
"Find",
"the",
"categorical",
"columns",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L401-L427 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | Categorizer.transform | def transform(self, X, y=None):
"""Transform the columns in ``X`` according to ``self.categories_``.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
X_trn : pandas.DataFrame or dask.DataFrame
Same type... | python | def transform(self, X, y=None):
"""Transform the columns in ``X`` according to ``self.categories_``.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
X_trn : pandas.DataFrame or dask.DataFrame
Same type... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"categories_\"",
")",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
".",
"copy",
"(",
")",
"categories",
"=",
"self",
".",
"c... | Transform the columns in ``X`` according to ``self.categories_``.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
X_trn : pandas.DataFrame or dask.DataFrame
Same type as the input. The columns in ``self.catego... | [
"Transform",
"the",
"columns",
"in",
"X",
"according",
"to",
"self",
".",
"categories_",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L455-L482 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | DummyEncoder.fit | def fit(self, X, y=None):
"""Determine the categorical columns to be dummy encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = se... | python | def fit(self, X, y=None):
"""Determine the categorical columns to be dummy encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = se... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"self",
".",
"columns_",
"=",
"X",
".",
"columns",
"columns",
"=",
"self",
".",
"columns",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"X",
".",
"select_dtypes",
"(",
"... | Determine the categorical columns to be dummy encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self | [
"Determine",
"the",
"categorical",
"columns",
"to",
"be",
"dummy",
"encoded",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L570-L617 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | DummyEncoder.transform | def transform(self, X, y=None):
"""Dummy encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | python | def transform(self, X, y=None):
"""Dummy encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"X",
".",
"columns",
".",
"equals",
"(",
"self",
".",
"columns_",
")",
":",
"raise",
"ValueError",
"(",
"\"Columns of 'X' do not match the training \"",
"\"columns. Got ... | Dummy encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input | [
"Dummy",
"encode",
"the",
"categorical",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L619-L642 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | DummyEncoder.inverse_transform | def inverse_transform(self, X):
"""Inverse dummy-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask ... | python | def inverse_transform(self, X):
"""Inverse dummy-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask ... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"X",
"=",
"pd",
".",
"DataFrame",
"(",
"X",
",",
"columns",
"=",
"self",
".",
"transformed_columns_",
")",
"elif",
"isinst... | Inverse dummy-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask DataFrame.
Numpy array or panda... | [
"Inverse",
"dummy",
"-",
"encode",
"the",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L644-L729 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | OrdinalEncoder.fit | def fit(self, X, y=None):
"""Determine the categorical columns to be encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = self.col... | python | def fit(self, X, y=None):
"""Determine the categorical columns to be encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = self.col... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"self",
".",
"columns_",
"=",
"X",
".",
"columns",
"columns",
"=",
"self",
".",
"columns",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"X",
".",
"select_dtypes",
"(",
"... | Determine the categorical columns to be encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self | [
"Determine",
"the",
"categorical",
"columns",
"to",
"be",
"encoded",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L804-L835 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | OrdinalEncoder.transform | def transform(self, X, y=None):
"""Ordinal encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | python | def transform(self, X, y=None):
"""Ordinal encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"X",
".",
"columns",
".",
"equals",
"(",
"self",
".",
"columns_",
")",
":",
"raise",
"ValueError",
"(",
"\"Columns of 'X' do not match the training \"",
"\"columns. Got ... | Ordinal encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input | [
"Ordinal",
"encode",
"the",
"categorical",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L837-L861 | train |
dask/dask-ml | dask_ml/preprocessing/data.py | OrdinalEncoder.inverse_transform | def inverse_transform(self, X):
"""Inverse ordinal-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Das... | python | def inverse_transform(self, X):
"""Inverse ordinal-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Das... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"X",
"=",
"pd",
".",
"DataFrame",
"(",
"X",
",",
"columns",
"=",
"self",
".",
"columns_",
")",
"elif",
"isinstance",
"("... | Inverse ordinal-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask DataFrame.
Numpy array or pan... | [
"Inverse",
"ordinal",
"-",
"encode",
"the",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L863-L933 | train |
dask/dask-ml | dask_ml/_partial.py | fit | def fit(model, x, y, compute=True, shuffle_blocks=True, random_state=None, **kwargs):
""" Fit scikit learn model against dask arrays
Model must support the ``partial_fit`` interface for online or batch
learning.
Ideally your rows are independent and identically distributed. By default,
this functi... | python | def fit(model, x, y, compute=True, shuffle_blocks=True, random_state=None, **kwargs):
""" Fit scikit learn model against dask arrays
Model must support the ``partial_fit`` interface for online or batch
learning.
Ideally your rows are independent and identically distributed. By default,
this functi... | [
"def",
"fit",
"(",
"model",
",",
"x",
",",
"y",
",",
"compute",
"=",
"True",
",",
"shuffle_blocks",
"=",
"True",
",",
"random_state",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"x",
",",
"\"chunks\"",
")",
"and",
... | Fit scikit learn model against dask arrays
Model must support the ``partial_fit`` interface for online or batch
learning.
Ideally your rows are independent and identically distributed. By default,
this function will step through chunks of the arrays in random order.
Parameters
----------
... | [
"Fit",
"scikit",
"learn",
"model",
"against",
"dask",
"arrays"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/_partial.py#L109-L217 | train |
dask/dask-ml | dask_ml/_partial.py | predict | def predict(model, x):
""" Predict with a scikit learn model
Parameters
----------
model : scikit learn classifier
x : dask Array
See docstring for ``da.learn.fit``
"""
if not hasattr(x, "chunks") and hasattr(x, "to_dask_array"):
x = x.to_dask_array()
assert x.ndim == 2
... | python | def predict(model, x):
""" Predict with a scikit learn model
Parameters
----------
model : scikit learn classifier
x : dask Array
See docstring for ``da.learn.fit``
"""
if not hasattr(x, "chunks") and hasattr(x, "to_dask_array"):
x = x.to_dask_array()
assert x.ndim == 2
... | [
"def",
"predict",
"(",
"model",
",",
"x",
")",
":",
"if",
"not",
"hasattr",
"(",
"x",
",",
"\"chunks\"",
")",
"and",
"hasattr",
"(",
"x",
",",
"\"to_dask_array\"",
")",
":",
"x",
"=",
"x",
".",
"to_dask_array",
"(",
")",
"assert",
"x",
".",
"ndim",... | Predict with a scikit learn model
Parameters
----------
model : scikit learn classifier
x : dask Array
See docstring for ``da.learn.fit`` | [
"Predict",
"with",
"a",
"scikit",
"learn",
"model"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/_partial.py#L224-L242 | train |
dask/dask-ml | dask_ml/cluster/spectral.py | _slice_mostly_sorted | def _slice_mostly_sorted(array, keep, rest, ind=None):
"""Slice dask array `array` that is almost entirely sorted already.
We perform approximately `2 * len(keep)` slices on `array`.
This is OK, since `keep` is small. Individually, each of these slices
is entirely sorted.
Parameters
----------... | python | def _slice_mostly_sorted(array, keep, rest, ind=None):
"""Slice dask array `array` that is almost entirely sorted already.
We perform approximately `2 * len(keep)` slices on `array`.
This is OK, since `keep` is small. Individually, each of these slices
is entirely sorted.
Parameters
----------... | [
"def",
"_slice_mostly_sorted",
"(",
"array",
",",
"keep",
",",
"rest",
",",
"ind",
"=",
"None",
")",
":",
"if",
"ind",
"is",
"None",
":",
"ind",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"array",
")",
")",
"idx",
"=",
"np",
".",
"argsort",
"(",
... | Slice dask array `array` that is almost entirely sorted already.
We perform approximately `2 * len(keep)` slices on `array`.
This is OK, since `keep` is small. Individually, each of these slices
is entirely sorted.
Parameters
----------
array : dask.array.Array
keep : ndarray[Int]
... | [
"Slice",
"dask",
"array",
"array",
"that",
"is",
"almost",
"entirely",
"sorted",
"already",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/spectral.py#L339-L376 | train |
dask/dask-ml | dask_ml/datasets.py | make_counts | def make_counts(
n_samples=1000,
n_features=100,
n_informative=2,
scale=1.0,
chunks=100,
random_state=None,
):
"""
Generate a dummy dataset for modeling count data.
Parameters
----------
n_samples : int
number of rows in the output array
n_features : int
... | python | def make_counts(
n_samples=1000,
n_features=100,
n_informative=2,
scale=1.0,
chunks=100,
random_state=None,
):
"""
Generate a dummy dataset for modeling count data.
Parameters
----------
n_samples : int
number of rows in the output array
n_features : int
... | [
"def",
"make_counts",
"(",
"n_samples",
"=",
"1000",
",",
"n_features",
"=",
"100",
",",
"n_informative",
"=",
"2",
",",
"scale",
"=",
"1.0",
",",
"chunks",
"=",
"100",
",",
"random_state",
"=",
"None",
",",
")",
":",
"rng",
"=",
"dask_ml",
".",
"uti... | Generate a dummy dataset for modeling count data.
Parameters
----------
n_samples : int
number of rows in the output array
n_features : int
number of columns (features) in the output array
n_informative : int
number of features that are correlated with the outcome
scale ... | [
"Generate",
"a",
"dummy",
"dataset",
"for",
"modeling",
"count",
"data",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/datasets.py#L24-L73 | train |
dask/dask-ml | dask_ml/datasets.py | make_blobs | def make_blobs(
n_samples=100,
n_features=2,
centers=None,
cluster_std=1.0,
center_box=(-10.0, 10.0),
shuffle=True,
random_state=None,
chunks=None,
):
"""
Generate isotropic Gaussian blobs for clustering.
This can be used to generate very large Dask arrays on a cluster of
... | python | def make_blobs(
n_samples=100,
n_features=2,
centers=None,
cluster_std=1.0,
center_box=(-10.0, 10.0),
shuffle=True,
random_state=None,
chunks=None,
):
"""
Generate isotropic Gaussian blobs for clustering.
This can be used to generate very large Dask arrays on a cluster of
... | [
"def",
"make_blobs",
"(",
"n_samples",
"=",
"100",
",",
"n_features",
"=",
"2",
",",
"centers",
"=",
"None",
",",
"cluster_std",
"=",
"1.0",
",",
"center_box",
"=",
"(",
"-",
"10.0",
",",
"10.0",
")",
",",
"shuffle",
"=",
"True",
",",
"random_state",
... | Generate isotropic Gaussian blobs for clustering.
This can be used to generate very large Dask arrays on a cluster of
machines. When using Dask in distributed mode, the client machine
only needs to allocate a single block's worth of data.
Parameters
----------
n_samples : int or array-like, op... | [
"Generate",
"isotropic",
"Gaussian",
"blobs",
"for",
"clustering",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/datasets.py#L76-L203 | train |
dask/dask-ml | dask_ml/datasets.py | make_regression | def make_regression(
n_samples=100,
n_features=100,
n_informative=10,
n_targets=1,
bias=0.0,
effective_rank=None,
tail_strength=0.5,
noise=0.0,
shuffle=True,
coef=False,
random_state=None,
chunks=None,
):
"""
Generate a random regression problem.
The input se... | python | def make_regression(
n_samples=100,
n_features=100,
n_informative=10,
n_targets=1,
bias=0.0,
effective_rank=None,
tail_strength=0.5,
noise=0.0,
shuffle=True,
coef=False,
random_state=None,
chunks=None,
):
"""
Generate a random regression problem.
The input se... | [
"def",
"make_regression",
"(",
"n_samples",
"=",
"100",
",",
"n_features",
"=",
"100",
",",
"n_informative",
"=",
"10",
",",
"n_targets",
"=",
"1",
",",
"bias",
"=",
"0.0",
",",
"effective_rank",
"=",
"None",
",",
"tail_strength",
"=",
"0.5",
",",
"noise... | Generate a random regression problem.
The input set can either be well conditioned (by default) or have a low
rank-fat tail singular profile. See
:func:`sklearn.datasets.make_low_rank_matrix` for more details.
This can be used to generate very large Dask arrays on a cluster of
machines. When using... | [
"Generate",
"a",
"random",
"regression",
"problem",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/datasets.py#L206-L338 | train |
dask/dask-ml | dask_ml/decomposition/truncated_svd.py | TruncatedSVD.fit_transform | def fit_transform(self, X, y=None):
"""Fit model to X and perform dimensionality reduction on X.
Parameters
----------
X : array-like, shape (n_samples, n_features)
Training data.
y : Ignored
Returns
-------
X_new : array, shape (n_samples, ... | python | def fit_transform(self, X, y=None):
"""Fit model to X and perform dimensionality reduction on X.
Parameters
----------
X : array-like, shape (n_samples, n_features)
Training data.
y : Ignored
Returns
-------
X_new : array, shape (n_samples, ... | [
"def",
"fit_transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"self",
".",
"algorithm",
"not",
"in",
"{",
"\"tsqr\"",
",",
"\"randomized\"",
"}",
":",
"raise",
"ValueError"... | Fit model to X and perform dimensionality reduction on X.
Parameters
----------
X : array-like, shape (n_samples, n_features)
Training data.
y : Ignored
Returns
-------
X_new : array, shape (n_samples, n_components)
Reduced version of X.... | [
"Fit",
"model",
"to",
"X",
"and",
"perform",
"dimensionality",
"reduction",
"on",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/truncated_svd.py#L144-L186 | train |
dask/dask-ml | dask_ml/compose/_column_transformer.py | ColumnTransformer._hstack | def _hstack(self, Xs):
"""
Stacks X horizontally.
Supports input types (X): list of
numpy arrays, sparse arrays and DataFrames
"""
types = set(type(X) for X in Xs)
if self.sparse_output_:
return sparse.hstack(Xs).tocsr()
elif dd.Series in... | python | def _hstack(self, Xs):
"""
Stacks X horizontally.
Supports input types (X): list of
numpy arrays, sparse arrays and DataFrames
"""
types = set(type(X) for X in Xs)
if self.sparse_output_:
return sparse.hstack(Xs).tocsr()
elif dd.Series in... | [
"def",
"_hstack",
"(",
"self",
",",
"Xs",
")",
":",
"types",
"=",
"set",
"(",
"type",
"(",
"X",
")",
"for",
"X",
"in",
"Xs",
")",
"if",
"self",
".",
"sparse_output_",
":",
"return",
"sparse",
".",
"hstack",
"(",
"Xs",
")",
".",
"tocsr",
"(",
")... | Stacks X horizontally.
Supports input types (X): list of
numpy arrays, sparse arrays and DataFrames | [
"Stacks",
"X",
"horizontally",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/compose/_column_transformer.py#L172-L200 | train |
dask/dask-ml | dask_ml/decomposition/pca.py | PCA.transform | def transform(self, X):
"""Apply dimensionality reduction on X.
X is projected on the first principal components previous extracted
from a training set.
Parameters
----------
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the numb... | python | def transform(self, X):
"""Apply dimensionality reduction on X.
X is projected on the first principal components previous extracted
from a training set.
Parameters
----------
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the numb... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"[",
"\"mean_\"",
",",
"\"components_\"",
"]",
",",
"all_or_any",
"=",
"all",
")",
"# X = check_array(X)",
"if",
"self",
".",
"mean_",
"is",
"not",
"None",
":",
"X"... | Apply dimensionality reduction on X.
X is projected on the first principal components previous extracted
from a training set.
Parameters
----------
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the number of samples
and n_fea... | [
"Apply",
"dimensionality",
"reduction",
"on",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L319-L344 | train |
dask/dask-ml | dask_ml/decomposition/pca.py | PCA.fit_transform | def fit_transform(self, X, y=None):
"""Fit the model with X and apply the dimensionality reduction on X.
Parameters
----------
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the number of samples
and n_features is the number of feature... | python | def fit_transform(self, X, y=None):
"""Fit the model with X and apply the dimensionality reduction on X.
Parameters
----------
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the number of samples
and n_features is the number of feature... | [
"def",
"fit_transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"# X = check_array(X)",
"U",
",",
"S",
",",
"V",
"=",
"self",
".",
"_fit",
"(",
"X",
")",
"U",
"=",
"U",
"[",
":",
",",
":",
"self",
".",
"n_components_",
"]",
"if"... | Fit the model with X and apply the dimensionality reduction on X.
Parameters
----------
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the number of samples
and n_features is the number of features.
y : Ignored
Returns
... | [
"Fit",
"the",
"model",
"with",
"X",
"and",
"apply",
"the",
"dimensionality",
"reduction",
"on",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L346-L373 | train |
dask/dask-ml | dask_ml/decomposition/pca.py | PCA.inverse_transform | def inverse_transform(self, X):
"""Transform data back to its original space.
Returns an array X_original whose transform would be X.
Parameters
----------
X : array-like, shape (n_samples, n_components)
New data, where n_samples in the number of samples
... | python | def inverse_transform(self, X):
"""Transform data back to its original space.
Returns an array X_original whose transform would be X.
Parameters
----------
X : array-like, shape (n_samples, n_components)
New data, where n_samples in the number of samples
... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"mean_\"",
")",
"if",
"self",
".",
"whiten",
":",
"return",
"(",
"da",
".",
"dot",
"(",
"X",
",",
"np",
".",
"sqrt",
"(",
"self",
".",
"explained_vari... | Transform data back to its original space.
Returns an array X_original whose transform would be X.
Parameters
----------
X : array-like, shape (n_samples, n_components)
New data, where n_samples in the number of samples
and n_components is the number of componen... | [
"Transform",
"data",
"back",
"to",
"its",
"original",
"space",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L375-L406 | train |
dask/dask-ml | dask_ml/decomposition/pca.py | PCA.score_samples | def score_samples(self, X):
"""Return the log-likelihood of each sample.
See. "Pattern Recognition and Machine Learning"
by C. Bishop, 12.2.1 p. 574
or http://www.miketipping.com/papers/met-mppca.pdf
Parameters
----------
X : array, shape(n_samples, n_features)
... | python | def score_samples(self, X):
"""Return the log-likelihood of each sample.
See. "Pattern Recognition and Machine Learning"
by C. Bishop, 12.2.1 p. 574
or http://www.miketipping.com/papers/met-mppca.pdf
Parameters
----------
X : array, shape(n_samples, n_features)
... | [
"def",
"score_samples",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"mean_\"",
")",
"# X = check_array(X)",
"Xr",
"=",
"X",
"-",
"self",
".",
"mean_",
"n_features",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"precision",
"=",
"s... | Return the log-likelihood of each sample.
See. "Pattern Recognition and Machine Learning"
by C. Bishop, 12.2.1 p. 574
or http://www.miketipping.com/papers/met-mppca.pdf
Parameters
----------
X : array, shape(n_samples, n_features)
The data.
Returns
... | [
"Return",
"the",
"log",
"-",
"likelihood",
"of",
"each",
"sample",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L408-L433 | train |
dask/dask-ml | dask_ml/utils.py | assert_estimator_equal | def assert_estimator_equal(left, right, exclude=None, **kwargs):
"""Check that two Estimators are equal
Parameters
----------
left, right : Estimators
exclude : str or sequence of str
attributes to skip in the check
kwargs : dict
Passed through to the dask `assert_eq` method.
... | python | def assert_estimator_equal(left, right, exclude=None, **kwargs):
"""Check that two Estimators are equal
Parameters
----------
left, right : Estimators
exclude : str or sequence of str
attributes to skip in the check
kwargs : dict
Passed through to the dask `assert_eq` method.
... | [
"def",
"assert_estimator_equal",
"(",
"left",
",",
"right",
",",
"exclude",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"left_attrs",
"=",
"[",
"x",
"for",
"x",
"in",
"dir",
"(",
"left",
")",
"if",
"x",
".",
"endswith",
"(",
"\"_\"",
")",
"and"... | Check that two Estimators are equal
Parameters
----------
left, right : Estimators
exclude : str or sequence of str
attributes to skip in the check
kwargs : dict
Passed through to the dask `assert_eq` method. | [
"Check",
"that",
"two",
"Estimators",
"are",
"equal"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L58-L84 | train |
dask/dask-ml | dask_ml/utils.py | check_matching_blocks | def check_matching_blocks(*arrays):
"""Check that the partitioning structure for many arrays matches.
Parameters
----------
*arrays : Sequence of array-likes
This includes
* Dask Array
* Dask DataFrame
* Dask Series
"""
if len(arrays) <= 1:
return
if... | python | def check_matching_blocks(*arrays):
"""Check that the partitioning structure for many arrays matches.
Parameters
----------
*arrays : Sequence of array-likes
This includes
* Dask Array
* Dask DataFrame
* Dask Series
"""
if len(arrays) <= 1:
return
if... | [
"def",
"check_matching_blocks",
"(",
"*",
"arrays",
")",
":",
"if",
"len",
"(",
"arrays",
")",
"<=",
"1",
":",
"return",
"if",
"all",
"(",
"isinstance",
"(",
"x",
",",
"da",
".",
"Array",
")",
"for",
"x",
"in",
"arrays",
")",
":",
"# TODO: unknown ch... | Check that the partitioning structure for many arrays matches.
Parameters
----------
*arrays : Sequence of array-likes
This includes
* Dask Array
* Dask DataFrame
* Dask Series | [
"Check",
"that",
"the",
"partitioning",
"structure",
"for",
"many",
"arrays",
"matches",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L190-L221 | train |
dask/dask-ml | dask_ml/utils.py | check_chunks | def check_chunks(n_samples, n_features, chunks=None):
"""Validate and normalize the chunks argument for a dask.array
Parameters
----------
n_samples, n_features : int
Give the shape of the array
chunks : int, sequence, optional, default None
* For 'chunks=None', this picks a "good" ... | python | def check_chunks(n_samples, n_features, chunks=None):
"""Validate and normalize the chunks argument for a dask.array
Parameters
----------
n_samples, n_features : int
Give the shape of the array
chunks : int, sequence, optional, default None
* For 'chunks=None', this picks a "good" ... | [
"def",
"check_chunks",
"(",
"n_samples",
",",
"n_features",
",",
"chunks",
"=",
"None",
")",
":",
"if",
"chunks",
"is",
"None",
":",
"chunks",
"=",
"(",
"max",
"(",
"100",
",",
"n_samples",
"//",
"cpu_count",
"(",
")",
")",
",",
"n_features",
")",
"e... | Validate and normalize the chunks argument for a dask.array
Parameters
----------
n_samples, n_features : int
Give the shape of the array
chunks : int, sequence, optional, default None
* For 'chunks=None', this picks a "good" default number of chunks based
on the number of CPU... | [
"Validate",
"and",
"normalize",
"the",
"chunks",
"argument",
"for",
"a",
"dask",
".",
"array"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L224-L261 | train |
dask/dask-ml | dask_ml/metrics/scorer.py | get_scorer | def get_scorer(scoring, compute=True):
"""Get a scorer from string
Parameters
----------
scoring : str | callable
scoring method as string. If callable it is returned as is.
Returns
-------
scorer : callable
The scorer.
"""
# This is the same as sklearns, only we us... | python | def get_scorer(scoring, compute=True):
"""Get a scorer from string
Parameters
----------
scoring : str | callable
scoring method as string. If callable it is returned as is.
Returns
-------
scorer : callable
The scorer.
"""
# This is the same as sklearns, only we us... | [
"def",
"get_scorer",
"(",
"scoring",
",",
"compute",
"=",
"True",
")",
":",
"# This is the same as sklearns, only we use our SCORERS dict,",
"# and don't have back-compat code",
"if",
"isinstance",
"(",
"scoring",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
... | Get a scorer from string
Parameters
----------
scoring : str | callable
scoring method as string. If callable it is returned as is.
Returns
-------
scorer : callable
The scorer. | [
"Get",
"a",
"scorer",
"from",
"string"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/metrics/scorer.py#L22-L51 | train |
dask/dask-ml | dask_ml/model_selection/utils.py | to_indexable | def to_indexable(*args, **kwargs):
"""Ensure that all args are an indexable type.
Conversion runs lazily for dask objects, immediately otherwise.
Parameters
----------
args : array_like or scalar
allow_scalars : bool, optional
Whether to allow scalars in args. Default is False.
"""... | python | def to_indexable(*args, **kwargs):
"""Ensure that all args are an indexable type.
Conversion runs lazily for dask objects, immediately otherwise.
Parameters
----------
args : array_like or scalar
allow_scalars : bool, optional
Whether to allow scalars in args. Default is False.
"""... | [
"def",
"to_indexable",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"allow_scalars\"",
",",
"False",
")",
":",
"indexable",
"=",
"_maybe_indexable",
"else",
":",
"indexable",
"=",
"_indexable",
"for",
"x",
"in",... | Ensure that all args are an indexable type.
Conversion runs lazily for dask objects, immediately otherwise.
Parameters
----------
args : array_like or scalar
allow_scalars : bool, optional
Whether to allow scalars in args. Default is False. | [
"Ensure",
"that",
"all",
"args",
"are",
"an",
"indexable",
"type",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/utils.py#L33-L54 | train |
dask/dask-ml | dask_ml/model_selection/utils.py | _index_param_value | def _index_param_value(num_samples, v, indices):
"""Private helper function for parameter value indexing.
This determines whether a fit parameter `v` to a SearchCV.fit
should be indexed along with `X` and `y`. Note that this differs
from the scikit-learn version. They pass `X` and compute num_samples.
... | python | def _index_param_value(num_samples, v, indices):
"""Private helper function for parameter value indexing.
This determines whether a fit parameter `v` to a SearchCV.fit
should be indexed along with `X` and `y`. Note that this differs
from the scikit-learn version. They pass `X` and compute num_samples.
... | [
"def",
"_index_param_value",
"(",
"num_samples",
",",
"v",
",",
"indices",
")",
":",
"if",
"not",
"_is_arraylike",
"(",
"v",
")",
"or",
"_num_samples",
"(",
"v",
")",
"!=",
"num_samples",
":",
"# pass through: skip indexing",
"return",
"v",
"if",
"sp",
".",
... | Private helper function for parameter value indexing.
This determines whether a fit parameter `v` to a SearchCV.fit
should be indexed along with `X` and `y`. Note that this differs
from the scikit-learn version. They pass `X` and compute num_samples.
We pass `num_samples` instead. | [
"Private",
"helper",
"function",
"for",
"parameter",
"value",
"indexing",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/utils.py#L57-L70 | train |
dask/dask-ml | dask_ml/model_selection/utils.py | DeprecationDict.add_warning | def add_warning(self, key, *args, **kwargs):
"""Add a warning to be triggered when the specified key is read
Parameters
----------
key : any hashable object
The key
"""
self._deprecations[key] = (args, kwargs) | python | def add_warning(self, key, *args, **kwargs):
"""Add a warning to be triggered when the specified key is read
Parameters
----------
key : any hashable object
The key
"""
self._deprecations[key] = (args, kwargs) | [
"def",
"add_warning",
"(",
"self",
",",
"key",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_deprecations",
"[",
"key",
"]",
"=",
"(",
"args",
",",
"kwargs",
")"
] | Add a warning to be triggered when the specified key is read
Parameters
----------
key : any hashable object
The key | [
"Add",
"a",
"warning",
"to",
"be",
"triggered",
"when",
"the",
"specified",
"key",
"is",
"read"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/utils.py#L141-L149 | train |
dask/dask-ml | dask_ml/preprocessing/label.py | _construct | def _construct(x, categories):
"""Make a sparse matrix from an encoded array.
>>> construct(np.array([0, 1, 0]), np.array([0, 1])).toarray()
array([[1., 0.],
[0., 1.],
[1., 0.]])
"""
# type: (np.ndarray, np.ndarray) -> scipy.sparse.csr_matrix
data = np.ones(len(x))
row... | python | def _construct(x, categories):
"""Make a sparse matrix from an encoded array.
>>> construct(np.array([0, 1, 0]), np.array([0, 1])).toarray()
array([[1., 0.],
[0., 1.],
[1., 0.]])
"""
# type: (np.ndarray, np.ndarray) -> scipy.sparse.csr_matrix
data = np.ones(len(x))
row... | [
"def",
"_construct",
"(",
"x",
",",
"categories",
")",
":",
"# type: (np.ndarray, np.ndarray) -> scipy.sparse.csr_matrix",
"data",
"=",
"np",
".",
"ones",
"(",
"len",
"(",
"x",
")",
")",
"rows",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"x",
")",
")",
"... | Make a sparse matrix from an encoded array.
>>> construct(np.array([0, 1, 0]), np.array([0, 1])).toarray()
array([[1., 0.],
[0., 1.],
[1., 0.]]) | [
"Make",
"a",
"sparse",
"matrix",
"from",
"an",
"encoded",
"array",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/label.py#L224-L238 | train |
dask/dask-ml | dask_ml/preprocessing/label.py | _encode_dask_array | def _encode_dask_array(values, uniques=None, encode=False, onehot_dtype=None):
"""One-hot or label encode a dask array.
Parameters
----------
values : da.Array, shape [n_samples,]
unqiques : np.ndarray, shape [n_uniques,]
encode : bool, default False
Whether to encode the values (True) ... | python | def _encode_dask_array(values, uniques=None, encode=False, onehot_dtype=None):
"""One-hot or label encode a dask array.
Parameters
----------
values : da.Array, shape [n_samples,]
unqiques : np.ndarray, shape [n_uniques,]
encode : bool, default False
Whether to encode the values (True) ... | [
"def",
"_encode_dask_array",
"(",
"values",
",",
"uniques",
"=",
"None",
",",
"encode",
"=",
"False",
",",
"onehot_dtype",
"=",
"None",
")",
":",
"if",
"uniques",
"is",
"None",
":",
"if",
"encode",
"and",
"onehot_dtype",
":",
"raise",
"ValueError",
"(",
... | One-hot or label encode a dask array.
Parameters
----------
values : da.Array, shape [n_samples,]
unqiques : np.ndarray, shape [n_uniques,]
encode : bool, default False
Whether to encode the values (True) or just discover the uniques.
onehot_dtype : np.dtype, optional
Optional d... | [
"One",
"-",
"hot",
"or",
"label",
"encode",
"a",
"dask",
"array",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/label.py#L241-L301 | train |
dask/dask-ml | dask_ml/model_selection/methods.py | pipeline | def pipeline(names, steps):
"""Reconstruct a Pipeline from names and steps"""
steps, times = zip(*map(_maybe_timed, steps))
fit_time = sum(times)
if any(s is FIT_FAILURE for s in steps):
fit_est = FIT_FAILURE
else:
fit_est = Pipeline(list(zip(names, steps)))
return fit_est, fit_t... | python | def pipeline(names, steps):
"""Reconstruct a Pipeline from names and steps"""
steps, times = zip(*map(_maybe_timed, steps))
fit_time = sum(times)
if any(s is FIT_FAILURE for s in steps):
fit_est = FIT_FAILURE
else:
fit_est = Pipeline(list(zip(names, steps)))
return fit_est, fit_t... | [
"def",
"pipeline",
"(",
"names",
",",
"steps",
")",
":",
"steps",
",",
"times",
"=",
"zip",
"(",
"*",
"map",
"(",
"_maybe_timed",
",",
"steps",
")",
")",
"fit_time",
"=",
"sum",
"(",
"times",
")",
"if",
"any",
"(",
"s",
"is",
"FIT_FAILURE",
"for",
... | Reconstruct a Pipeline from names and steps | [
"Reconstruct",
"a",
"Pipeline",
"from",
"names",
"and",
"steps"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/methods.py#L183-L191 | train |
dask/dask-ml | dask_ml/model_selection/methods.py | feature_union | def feature_union(names, steps, weights):
"""Reconstruct a FeatureUnion from names, steps, and weights"""
steps, times = zip(*map(_maybe_timed, steps))
fit_time = sum(times)
if any(s is FIT_FAILURE for s in steps):
fit_est = FIT_FAILURE
else:
fit_est = FeatureUnion(list(zip(names, st... | python | def feature_union(names, steps, weights):
"""Reconstruct a FeatureUnion from names, steps, and weights"""
steps, times = zip(*map(_maybe_timed, steps))
fit_time = sum(times)
if any(s is FIT_FAILURE for s in steps):
fit_est = FIT_FAILURE
else:
fit_est = FeatureUnion(list(zip(names, st... | [
"def",
"feature_union",
"(",
"names",
",",
"steps",
",",
"weights",
")",
":",
"steps",
",",
"times",
"=",
"zip",
"(",
"*",
"map",
"(",
"_maybe_timed",
",",
"steps",
")",
")",
"fit_time",
"=",
"sum",
"(",
"times",
")",
"if",
"any",
"(",
"s",
"is",
... | Reconstruct a FeatureUnion from names, steps, and weights | [
"Reconstruct",
"a",
"FeatureUnion",
"from",
"names",
"steps",
"and",
"weights"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/methods.py#L194-L202 | train |
dask/dask-ml | dask_ml/model_selection/methods.py | feature_union_concat | def feature_union_concat(Xs, nsamples, weights):
"""Apply weights and concatenate outputs from a FeatureUnion"""
if any(x is FIT_FAILURE for x in Xs):
return FIT_FAILURE
Xs = [X if w is None else X * w for X, w in zip(Xs, weights) if X is not None]
if not Xs:
return np.zeros((nsamples, 0... | python | def feature_union_concat(Xs, nsamples, weights):
"""Apply weights and concatenate outputs from a FeatureUnion"""
if any(x is FIT_FAILURE for x in Xs):
return FIT_FAILURE
Xs = [X if w is None else X * w for X, w in zip(Xs, weights) if X is not None]
if not Xs:
return np.zeros((nsamples, 0... | [
"def",
"feature_union_concat",
"(",
"Xs",
",",
"nsamples",
",",
"weights",
")",
":",
"if",
"any",
"(",
"x",
"is",
"FIT_FAILURE",
"for",
"x",
"in",
"Xs",
")",
":",
"return",
"FIT_FAILURE",
"Xs",
"=",
"[",
"X",
"if",
"w",
"is",
"None",
"else",
"X",
"... | Apply weights and concatenate outputs from a FeatureUnion | [
"Apply",
"weights",
"and",
"concatenate",
"outputs",
"from",
"a",
"FeatureUnion"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/methods.py#L205-L214 | train |
dask/dask-ml | dask_ml/model_selection/_split.py | _generate_idx | def _generate_idx(n, seed, n_train, n_test):
"""Generate train, test indices for a length-n array.
Parameters
----------
n : int
The length of the array
seed : int
Seed for a RandomState
n_train, n_test : int, 0 < n_train, n_test < n
Number of samples to use for the trai... | python | def _generate_idx(n, seed, n_train, n_test):
"""Generate train, test indices for a length-n array.
Parameters
----------
n : int
The length of the array
seed : int
Seed for a RandomState
n_train, n_test : int, 0 < n_train, n_test < n
Number of samples to use for the trai... | [
"def",
"_generate_idx",
"(",
"n",
",",
"seed",
",",
"n_train",
",",
"n_test",
")",
":",
"idx",
"=",
"check_random_state",
"(",
"seed",
")",
".",
"permutation",
"(",
"n",
")",
"ind_test",
"=",
"idx",
"[",
":",
"n_test",
"]",
"ind_train",
"=",
"idx",
"... | Generate train, test indices for a length-n array.
Parameters
----------
n : int
The length of the array
seed : int
Seed for a RandomState
n_train, n_test : int, 0 < n_train, n_test < n
Number of samples to use for the train or
test index.
Notes
----- | [
"Generate",
"train",
"test",
"indices",
"for",
"a",
"length",
"-",
"n",
"array",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_split.py#L67-L87 | train |
dask/dask-ml | dask_ml/model_selection/_split.py | _blockwise_slice | def _blockwise_slice(arr, idx):
"""Slice an array that is blockwise-aligned with idx.
Parameters
----------
arr : Dask array
idx : Dask array
Should have the following properties
* Same blocks as `arr` along the first dimension
* Contains only integers
* Each block'... | python | def _blockwise_slice(arr, idx):
"""Slice an array that is blockwise-aligned with idx.
Parameters
----------
arr : Dask array
idx : Dask array
Should have the following properties
* Same blocks as `arr` along the first dimension
* Contains only integers
* Each block'... | [
"def",
"_blockwise_slice",
"(",
"arr",
",",
"idx",
")",
":",
"objs",
"=",
"[",
"]",
"offsets",
"=",
"np",
".",
"hstack",
"(",
"[",
"0",
",",
"np",
".",
"cumsum",
"(",
"arr",
".",
"chunks",
"[",
"0",
"]",
")",
"[",
":",
"-",
"1",
"]",
"]",
"... | Slice an array that is blockwise-aligned with idx.
Parameters
----------
arr : Dask array
idx : Dask array
Should have the following properties
* Same blocks as `arr` along the first dimension
* Contains only integers
* Each block's values should be between ``[0, len(bl... | [
"Slice",
"an",
"array",
"that",
"is",
"blockwise",
"-",
"aligned",
"with",
"idx",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_split.py#L317-L356 | train |
dask/dask-ml | dask_ml/feature_extraction/text.py | HashingVectorizer.transform | def transform(self, X):
"""Transform a sequence of documents to a document-term matrix.
Transformation is done in parallel, and correctly handles dask
collections.
Parameters
----------
X : dask.Bag of raw text documents, length = n_samples
Samples. Each sam... | python | def transform(self, X):
"""Transform a sequence of documents to a document-term matrix.
Transformation is done in parallel, and correctly handles dask
collections.
Parameters
----------
X : dask.Bag of raw text documents, length = n_samples
Samples. Each sam... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"msg",
"=",
"\"'X' should be a 1-dimensional array with length 'num_samples'.\"",
"if",
"not",
"dask",
".",
"is_dask_collection",
"(",
"X",
")",
":",
"return",
"super",
"(",
"HashingVectorizer",
",",
"self",
")"... | Transform a sequence of documents to a document-term matrix.
Transformation is done in parallel, and correctly handles dask
collections.
Parameters
----------
X : dask.Bag of raw text documents, length = n_samples
Samples. Each sample must be a text document (either... | [
"Transform",
"a",
"sequence",
"of",
"documents",
"to",
"a",
"document",
"-",
"term",
"matrix",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/feature_extraction/text.py#L10-L67 | train |
MIT-LCP/wfdb-python | wfdb/processing/peaks.py | correct_peaks | def correct_peaks(sig, peak_inds, search_radius, smooth_window_size,
peak_dir='compare'):
"""
Adjust a set of detected peaks to coincide with local signal maxima,
and
Parameters
----------
sig : numpy array
The 1d signal array
peak_inds : np array
Array of ... | python | def correct_peaks(sig, peak_inds, search_radius, smooth_window_size,
peak_dir='compare'):
"""
Adjust a set of detected peaks to coincide with local signal maxima,
and
Parameters
----------
sig : numpy array
The 1d signal array
peak_inds : np array
Array of ... | [
"def",
"correct_peaks",
"(",
"sig",
",",
"peak_inds",
",",
"search_radius",
",",
"smooth_window_size",
",",
"peak_dir",
"=",
"'compare'",
")",
":",
"sig_len",
"=",
"sig",
".",
"shape",
"[",
"0",
"]",
"n_peaks",
"=",
"len",
"(",
"peak_inds",
")",
"# Subtrac... | Adjust a set of detected peaks to coincide with local signal maxima,
and
Parameters
----------
sig : numpy array
The 1d signal array
peak_inds : np array
Array of the original peak indices
max_gap : int
The radius within which the original peaks may be shifted.
smoot... | [
"Adjust",
"a",
"set",
"of",
"detected",
"peaks",
"to",
"coincide",
"with",
"local",
"signal",
"maxima",
"and"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/peaks.py#L106-L188 | train |
MIT-LCP/wfdb-python | wfdb/processing/peaks.py | shift_peaks | def shift_peaks(sig, peak_inds, search_radius, peak_up):
"""
Helper function for correct_peaks. Return the shifted peaks to local
maxima or minima within a radius.
peak_up : bool
Whether the expected peak direction is up
"""
sig_len = sig.shape[0]
n_peaks = len(peak_inds)
# The ... | python | def shift_peaks(sig, peak_inds, search_radius, peak_up):
"""
Helper function for correct_peaks. Return the shifted peaks to local
maxima or minima within a radius.
peak_up : bool
Whether the expected peak direction is up
"""
sig_len = sig.shape[0]
n_peaks = len(peak_inds)
# The ... | [
"def",
"shift_peaks",
"(",
"sig",
",",
"peak_inds",
",",
"search_radius",
",",
"peak_up",
")",
":",
"sig_len",
"=",
"sig",
".",
"shape",
"[",
"0",
"]",
"n_peaks",
"=",
"len",
"(",
"peak_inds",
")",
"# The indices to shift each peak ind by",
"shift_inds",
"=",
... | Helper function for correct_peaks. Return the shifted peaks to local
maxima or minima within a radius.
peak_up : bool
Whether the expected peak direction is up | [
"Helper",
"function",
"for",
"correct_peaks",
".",
"Return",
"the",
"shifted",
"peaks",
"to",
"local",
"maxima",
"or",
"minima",
"within",
"a",
"radius",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/peaks.py#L191-L223 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | get_plot_dims | def get_plot_dims(signal, ann_samp):
"Figure out the number of plot channels"
if signal is not None:
if signal.ndim == 1:
sig_len = len(signal)
n_sig = 1
else:
sig_len = signal.shape[0]
n_sig = signal.shape[1]
else:
sig_len = 0
... | python | def get_plot_dims(signal, ann_samp):
"Figure out the number of plot channels"
if signal is not None:
if signal.ndim == 1:
sig_len = len(signal)
n_sig = 1
else:
sig_len = signal.shape[0]
n_sig = signal.shape[1]
else:
sig_len = 0
... | [
"def",
"get_plot_dims",
"(",
"signal",
",",
"ann_samp",
")",
":",
"if",
"signal",
"is",
"not",
"None",
":",
"if",
"signal",
".",
"ndim",
"==",
"1",
":",
"sig_len",
"=",
"len",
"(",
"signal",
")",
"n_sig",
"=",
"1",
"else",
":",
"sig_len",
"=",
"sig... | Figure out the number of plot channels | [
"Figure",
"out",
"the",
"number",
"of",
"plot",
"channels"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L125-L143 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | create_figure | def create_figure(n_subplots, figsize):
"Create the plot figure and subplot axes"
fig = plt.figure(figsize=figsize)
axes = []
for i in range(n_subplots):
axes.append(fig.add_subplot(n_subplots, 1, i+1))
return fig, axes | python | def create_figure(n_subplots, figsize):
"Create the plot figure and subplot axes"
fig = plt.figure(figsize=figsize)
axes = []
for i in range(n_subplots):
axes.append(fig.add_subplot(n_subplots, 1, i+1))
return fig, axes | [
"def",
"create_figure",
"(",
"n_subplots",
",",
"figsize",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"figsize",
")",
"axes",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"n_subplots",
")",
":",
"axes",
".",
"append",
"(",
"... | Create the plot figure and subplot axes | [
"Create",
"the",
"plot",
"figure",
"and",
"subplot",
"axes"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L146-L154 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | plot_signal | def plot_signal(signal, sig_len, n_sig, fs, time_units, sig_style, axes):
"Plot signal channels"
# Extend signal style if necesary
if len(sig_style) == 1:
sig_style = n_sig * sig_style
# Figure out time indices
if time_units == 'samples':
t = np.linspace(0, sig_len-1, sig_len)
... | python | def plot_signal(signal, sig_len, n_sig, fs, time_units, sig_style, axes):
"Plot signal channels"
# Extend signal style if necesary
if len(sig_style) == 1:
sig_style = n_sig * sig_style
# Figure out time indices
if time_units == 'samples':
t = np.linspace(0, sig_len-1, sig_len)
... | [
"def",
"plot_signal",
"(",
"signal",
",",
"sig_len",
",",
"n_sig",
",",
"fs",
",",
"time_units",
",",
"sig_style",
",",
"axes",
")",
":",
"# Extend signal style if necesary",
"if",
"len",
"(",
"sig_style",
")",
"==",
"1",
":",
"sig_style",
"=",
"n_sig",
"*... | Plot signal channels | [
"Plot",
"signal",
"channels"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L157-L177 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | plot_annotation | def plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs, time_units,
ann_style, axes):
"Plot annotations, possibly overlaid on signals"
# Extend annotation style if necesary
if len(ann_style) == 1:
ann_style = n_annot * ann_style
# Figure out downsample factor for ... | python | def plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs, time_units,
ann_style, axes):
"Plot annotations, possibly overlaid on signals"
# Extend annotation style if necesary
if len(ann_style) == 1:
ann_style = n_annot * ann_style
# Figure out downsample factor for ... | [
"def",
"plot_annotation",
"(",
"ann_samp",
",",
"n_annot",
",",
"ann_sym",
",",
"signal",
",",
"n_sig",
",",
"fs",
",",
"time_units",
",",
"ann_style",
",",
"axes",
")",
":",
"# Extend annotation style if necesary",
"if",
"len",
"(",
"ann_style",
")",
"==",
... | Plot annotations, possibly overlaid on signals | [
"Plot",
"annotations",
"possibly",
"overlaid",
"on",
"signals"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L180-L214 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | plot_ecg_grids | def plot_ecg_grids(ecg_grids, fs, units, time_units, axes):
"Add ecg grids to the axes"
if ecg_grids == 'all':
ecg_grids = range(0, len(axes))
for ch in ecg_grids:
# Get the initial plot limits
auto_xlims = axes[ch].get_xlim()
auto_ylims= axes[ch].get_ylim()
(major... | python | def plot_ecg_grids(ecg_grids, fs, units, time_units, axes):
"Add ecg grids to the axes"
if ecg_grids == 'all':
ecg_grids = range(0, len(axes))
for ch in ecg_grids:
# Get the initial plot limits
auto_xlims = axes[ch].get_xlim()
auto_ylims= axes[ch].get_ylim()
(major... | [
"def",
"plot_ecg_grids",
"(",
"ecg_grids",
",",
"fs",
",",
"units",
",",
"time_units",
",",
"axes",
")",
":",
"if",
"ecg_grids",
"==",
"'all'",
":",
"ecg_grids",
"=",
"range",
"(",
"0",
",",
"len",
"(",
"axes",
")",
")",
"for",
"ch",
"in",
"ecg_grids... | Add ecg grids to the axes | [
"Add",
"ecg",
"grids",
"to",
"the",
"axes"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L217-L251 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | calc_ecg_grids | def calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units):
"""
Calculate tick intervals for ecg grids
- 5mm 0.2s major grids, 0.04s minor grids
- 0.5mV major grids, 0.125 minor grids
10 mm is equal to 1mV in voltage.
"""
# Get the grid interval of the x axis
if time_units == ... | python | def calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units):
"""
Calculate tick intervals for ecg grids
- 5mm 0.2s major grids, 0.04s minor grids
- 0.5mV major grids, 0.125 minor grids
10 mm is equal to 1mV in voltage.
"""
# Get the grid interval of the x axis
if time_units == ... | [
"def",
"calc_ecg_grids",
"(",
"minsig",
",",
"maxsig",
",",
"sig_units",
",",
"fs",
",",
"maxt",
",",
"time_units",
")",
":",
"# Get the grid interval of the x axis",
"if",
"time_units",
"==",
"'samples'",
":",
"majorx",
"=",
"0.2",
"*",
"fs",
"minorx",
"=",
... | Calculate tick intervals for ecg grids
- 5mm 0.2s major grids, 0.04s minor grids
- 0.5mV major grids, 0.125 minor grids
10 mm is equal to 1mV in voltage. | [
"Calculate",
"tick",
"intervals",
"for",
"ecg",
"grids"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L253-L297 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | label_figure | def label_figure(axes, n_subplots, time_units, sig_name, sig_units, ylabel,
title):
"Add title, and axes labels"
if title:
axes[0].set_title(title)
# Determine y label
# Explicit labels take precedence if present. Otherwise, construct labels
# using signal names and units
... | python | def label_figure(axes, n_subplots, time_units, sig_name, sig_units, ylabel,
title):
"Add title, and axes labels"
if title:
axes[0].set_title(title)
# Determine y label
# Explicit labels take precedence if present. Otherwise, construct labels
# using signal names and units
... | [
"def",
"label_figure",
"(",
"axes",
",",
"n_subplots",
",",
"time_units",
",",
"sig_name",
",",
"sig_units",
",",
"ylabel",
",",
"title",
")",
":",
"if",
"title",
":",
"axes",
"[",
"0",
"]",
".",
"set_title",
"(",
"title",
")",
"# Determine y label",
"# ... | Add title, and axes labels | [
"Add",
"title",
"and",
"axes",
"labels"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L300-L329 | train |
MIT-LCP/wfdb-python | wfdb/plot/plot.py | get_wfdb_plot_items | def get_wfdb_plot_items(record, annotation, plot_sym):
"""
Get items to plot from wfdb objects
"""
# Get record attributes
if record:
if record.p_signal is not None:
signal = record.p_signal
elif record.d_signal is not None:
signal = record.d_signal
el... | python | def get_wfdb_plot_items(record, annotation, plot_sym):
"""
Get items to plot from wfdb objects
"""
# Get record attributes
if record:
if record.p_signal is not None:
signal = record.p_signal
elif record.d_signal is not None:
signal = record.d_signal
el... | [
"def",
"get_wfdb_plot_items",
"(",
"record",
",",
"annotation",
",",
"plot_sym",
")",
":",
"# Get record attributes",
"if",
"record",
":",
"if",
"record",
".",
"p_signal",
"is",
"not",
"None",
":",
"signal",
"=",
"record",
".",
"p_signal",
"elif",
"record",
... | Get items to plot from wfdb objects | [
"Get",
"items",
"to",
"plot",
"from",
"wfdb",
"objects"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L417-L510 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | _remote_file_size | def _remote_file_size(url=None, file_name=None, pb_dir=None):
"""
Get the remote file size in bytes
Parameters
----------
url : str, optional
The full url of the file. Use this option to explicitly
state the full url.
file_name : str, optional
The base file name. Use thi... | python | def _remote_file_size(url=None, file_name=None, pb_dir=None):
"""
Get the remote file size in bytes
Parameters
----------
url : str, optional
The full url of the file. Use this option to explicitly
state the full url.
file_name : str, optional
The base file name. Use thi... | [
"def",
"_remote_file_size",
"(",
"url",
"=",
"None",
",",
"file_name",
"=",
"None",
",",
"pb_dir",
"=",
"None",
")",
":",
"# Option to construct the url",
"if",
"file_name",
"and",
"pb_dir",
":",
"url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"d... | Get the remote file size in bytes
Parameters
----------
url : str, optional
The full url of the file. Use this option to explicitly
state the full url.
file_name : str, optional
The base file name. Use this argument along with pb_dir if you
want the full url to be constr... | [
"Get",
"the",
"remote",
"file",
"size",
"in",
"bytes"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L35-L69 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | _stream_header | def _stream_header(file_name, pb_dir):
"""
Stream the lines of a remote header file.
Parameters
----------
file_name : str
pb_dir : str
The Physiobank database directory from which to find the
required header file. eg. For file '100.hea' in
'http://physionet.org/physiob... | python | def _stream_header(file_name, pb_dir):
"""
Stream the lines of a remote header file.
Parameters
----------
file_name : str
pb_dir : str
The Physiobank database directory from which to find the
required header file. eg. For file '100.hea' in
'http://physionet.org/physiob... | [
"def",
"_stream_header",
"(",
"file_name",
",",
"pb_dir",
")",
":",
"# Full url of header location",
"url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"pb_dir",
",",
"file_name",
")",
"response",
"=",
"requests",
".",
"get",
"(",
... | Stream the lines of a remote header file.
Parameters
----------
file_name : str
pb_dir : str
The Physiobank database directory from which to find the
required header file. eg. For file '100.hea' in
'http://physionet.org/physiobank/database/mitdb', pb_dir='mitdb'. | [
"Stream",
"the",
"lines",
"of",
"a",
"remote",
"header",
"file",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L71-L115 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | _stream_dat | def _stream_dat(file_name, pb_dir, byte_count, start_byte, dtype):
"""
Stream data from a remote dat file, into a 1d numpy array.
Parameters
----------
file_name : str
The name of the dat file to be read.
pb_dir : str
The physiobank directory where the dat file is located.
b... | python | def _stream_dat(file_name, pb_dir, byte_count, start_byte, dtype):
"""
Stream data from a remote dat file, into a 1d numpy array.
Parameters
----------
file_name : str
The name of the dat file to be read.
pb_dir : str
The physiobank directory where the dat file is located.
b... | [
"def",
"_stream_dat",
"(",
"file_name",
",",
"pb_dir",
",",
"byte_count",
",",
"start_byte",
",",
"dtype",
")",
":",
"# Full url of dat file",
"url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"pb_dir",
",",
"file_name",
")",
"# ... | Stream data from a remote dat file, into a 1d numpy array.
Parameters
----------
file_name : str
The name of the dat file to be read.
pb_dir : str
The physiobank directory where the dat file is located.
byte_count : int
The number of bytes to be read.
start_byte : int
... | [
"Stream",
"data",
"from",
"a",
"remote",
"dat",
"file",
"into",
"a",
"1d",
"numpy",
"array",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L118-L159 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | _stream_annotation | def _stream_annotation(file_name, pb_dir):
"""
Stream an entire remote annotation file from physiobank
Parameters
----------
file_name : str
The name of the annotation file to be read.
pb_dir : str
The physiobank directory where the annotation file is located.
"""
# Ful... | python | def _stream_annotation(file_name, pb_dir):
"""
Stream an entire remote annotation file from physiobank
Parameters
----------
file_name : str
The name of the annotation file to be read.
pb_dir : str
The physiobank directory where the annotation file is located.
"""
# Ful... | [
"def",
"_stream_annotation",
"(",
"file_name",
",",
"pb_dir",
")",
":",
"# Full url of annotation file",
"url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"pb_dir",
",",
"file_name",
")",
"# Get the content",
"response",
"=",
"requests... | Stream an entire remote annotation file from physiobank
Parameters
----------
file_name : str
The name of the annotation file to be read.
pb_dir : str
The physiobank directory where the annotation file is located. | [
"Stream",
"an",
"entire",
"remote",
"annotation",
"file",
"from",
"physiobank"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L162-L185 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | get_dbs | def get_dbs():
"""
Get a list of all the Physiobank databases available.
Examples
--------
>>> dbs = get_dbs()
"""
url = posixpath.join(config.db_index_url, 'DBS')
response = requests.get(url)
dbs = response.content.decode('ascii').splitlines()
dbs = [re.sub('\t{2,}', '\t', li... | python | def get_dbs():
"""
Get a list of all the Physiobank databases available.
Examples
--------
>>> dbs = get_dbs()
"""
url = posixpath.join(config.db_index_url, 'DBS')
response = requests.get(url)
dbs = response.content.decode('ascii').splitlines()
dbs = [re.sub('\t{2,}', '\t', li... | [
"def",
"get_dbs",
"(",
")",
":",
"url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"'DBS'",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"dbs",
"=",
"response",
".",
"content",
".",
"decode",
"(",
"'asci... | Get a list of all the Physiobank databases available.
Examples
--------
>>> dbs = get_dbs() | [
"Get",
"a",
"list",
"of",
"all",
"the",
"Physiobank",
"databases",
"available",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L188-L203 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | get_record_list | def get_record_list(db_dir, records='all'):
"""
Get a list of records belonging to a database.
Parameters
----------
db_dir : str
The database directory, usually the same as the database slug.
The location to look for a RECORDS file.
records : list, optional
A Option use... | python | def get_record_list(db_dir, records='all'):
"""
Get a list of records belonging to a database.
Parameters
----------
db_dir : str
The database directory, usually the same as the database slug.
The location to look for a RECORDS file.
records : list, optional
A Option use... | [
"def",
"get_record_list",
"(",
"db_dir",
",",
"records",
"=",
"'all'",
")",
":",
"# Full url physiobank database",
"db_url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"db_dir",
")",
"# Check for a RECORDS file",
"if",
"records",
"==",... | Get a list of records belonging to a database.
Parameters
----------
db_dir : str
The database directory, usually the same as the database slug.
The location to look for a RECORDS file.
records : list, optional
A Option used when this function acts as a helper function.
... | [
"Get",
"a",
"list",
"of",
"records",
"belonging",
"to",
"a",
"database",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L208-L241 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | make_local_dirs | def make_local_dirs(dl_dir, dl_inputs, keep_subdirs):
"""
Make any required local directories to prepare for downloading
"""
# Make the local download dir if it doesn't exist
if not os.path.isdir(dl_dir):
os.makedirs(dl_dir)
print('Created local base download directory: %s' % dl_dir... | python | def make_local_dirs(dl_dir, dl_inputs, keep_subdirs):
"""
Make any required local directories to prepare for downloading
"""
# Make the local download dir if it doesn't exist
if not os.path.isdir(dl_dir):
os.makedirs(dl_dir)
print('Created local base download directory: %s' % dl_dir... | [
"def",
"make_local_dirs",
"(",
"dl_dir",
",",
"dl_inputs",
",",
"keep_subdirs",
")",
":",
"# Make the local download dir if it doesn't exist",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"dl_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"dl_dir",
")",
"pr... | Make any required local directories to prepare for downloading | [
"Make",
"any",
"required",
"local",
"directories",
"to",
"prepare",
"for",
"downloading"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L277-L294 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | dl_pb_file | def dl_pb_file(inputs):
"""
Download a file from physiobank.
The input args are to be unpacked for the use of multiprocessing
map, because python2 doesn't have starmap...
"""
basefile, subdir, db, dl_dir, keep_subdirs, overwrite = inputs
# Full url of file
url = posixpath.join(config... | python | def dl_pb_file(inputs):
"""
Download a file from physiobank.
The input args are to be unpacked for the use of multiprocessing
map, because python2 doesn't have starmap...
"""
basefile, subdir, db, dl_dir, keep_subdirs, overwrite = inputs
# Full url of file
url = posixpath.join(config... | [
"def",
"dl_pb_file",
"(",
"inputs",
")",
":",
"basefile",
",",
"subdir",
",",
"db",
",",
"dl_dir",
",",
"keep_subdirs",
",",
"overwrite",
"=",
"inputs",
"# Full url of file",
"url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"d... | Download a file from physiobank.
The input args are to be unpacked for the use of multiprocessing
map, because python2 doesn't have starmap... | [
"Download",
"a",
"file",
"from",
"physiobank",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L297-L349 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | dl_full_file | def dl_full_file(url, save_file_name):
"""
Download a file. No checks are performed.
Parameters
----------
url : str
The url of the file to download
save_file_name : str
The name to save the file as
"""
response = requests.get(url)
with open(save_file_name, 'wb') as... | python | def dl_full_file(url, save_file_name):
"""
Download a file. No checks are performed.
Parameters
----------
url : str
The url of the file to download
save_file_name : str
The name to save the file as
"""
response = requests.get(url)
with open(save_file_name, 'wb') as... | [
"def",
"dl_full_file",
"(",
"url",
",",
"save_file_name",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"with",
"open",
"(",
"save_file_name",
",",
"'wb'",
")",
"as",
"writefile",
":",
"writefile",
".",
"write",
"(",
"response",
"."... | Download a file. No checks are performed.
Parameters
----------
url : str
The url of the file to download
save_file_name : str
The name to save the file as | [
"Download",
"a",
"file",
".",
"No",
"checks",
"are",
"performed",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L352-L368 | train |
MIT-LCP/wfdb-python | wfdb/io/download.py | dl_files | def dl_files(db, dl_dir, files, keep_subdirs=True, overwrite=False):
"""
Download specified files from a Physiobank database.
Parameters
----------
db : str
The Physiobank database directory to download. eg. For database:
'http://physionet.org/physiobank/database/mitdb', db='mitdb'.... | python | def dl_files(db, dl_dir, files, keep_subdirs=True, overwrite=False):
"""
Download specified files from a Physiobank database.
Parameters
----------
db : str
The Physiobank database directory to download. eg. For database:
'http://physionet.org/physiobank/database/mitdb', db='mitdb'.... | [
"def",
"dl_files",
"(",
"db",
",",
"dl_dir",
",",
"files",
",",
"keep_subdirs",
"=",
"True",
",",
"overwrite",
"=",
"False",
")",
":",
"# Full url physiobank database",
"db_url",
"=",
"posixpath",
".",
"join",
"(",
"config",
".",
"db_index_url",
",",
"db",
... | Download specified files from a Physiobank database.
Parameters
----------
db : str
The Physiobank database directory to download. eg. For database:
'http://physionet.org/physiobank/database/mitdb', db='mitdb'.
dl_dir : str
The full local directory path in which to download the ... | [
"Download",
"specified",
"files",
"from",
"a",
"Physiobank",
"database",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L371-L425 | train |
MIT-LCP/wfdb-python | wfdb/io/annotation.py | label_triplets_to_df | def label_triplets_to_df(triplets):
"""
Get a pd dataframe from a tuple triplets
used to define annotation labels.
The triplets should come in the
form: (label_store, symbol, description)
"""
label_df = pd.DataFrame({'label_store':np.array([t[0] for t in triplets],
... | python | def label_triplets_to_df(triplets):
"""
Get a pd dataframe from a tuple triplets
used to define annotation labels.
The triplets should come in the
form: (label_store, symbol, description)
"""
label_df = pd.DataFrame({'label_store':np.array([t[0] for t in triplets],
... | [
"def",
"label_triplets_to_df",
"(",
"triplets",
")",
":",
"label_df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"'label_store'",
":",
"np",
".",
"array",
"(",
"[",
"t",
"[",
"0",
"]",
"for",
"t",
"in",
"triplets",
"]",
",",
"dtype",
"=",
"'int'",
")",
... | Get a pd dataframe from a tuple triplets
used to define annotation labels.
The triplets should come in the
form: (label_store, symbol, description) | [
"Get",
"a",
"pd",
"dataframe",
"from",
"a",
"tuple",
"triplets",
"used",
"to",
"define",
"annotation",
"labels",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L925-L942 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.