repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | is_probabilistic_classifier | def is_probabilistic_classifier(clf):
# type: (Any) -> bool
""" Return True if a classifier can return probabilities """
if not hasattr(clf, 'predict_proba'):
return False
if isinstance(clf, OneVsRestClassifier):
# It currently has a predict_proba method, but does not check if
# ... | python | def is_probabilistic_classifier(clf):
# type: (Any) -> bool
""" Return True if a classifier can return probabilities """
if not hasattr(clf, 'predict_proba'):
return False
if isinstance(clf, OneVsRestClassifier):
# It currently has a predict_proba method, but does not check if
# ... | [
"def",
"is_probabilistic_classifier",
"(",
"clf",
")",
":",
"# type: (Any) -> bool",
"if",
"not",
"hasattr",
"(",
"clf",
",",
"'predict_proba'",
")",
":",
"return",
"False",
"if",
"isinstance",
"(",
"clf",
",",
"OneVsRestClassifier",
")",
":",
"# It currently has ... | Return True if a classifier can return probabilities | [
"Return",
"True",
"if",
"a",
"classifier",
"can",
"return",
"probabilities"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L31-L40 | train | Return True if a classifier can return probabilities. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | predict_proba | def predict_proba(estimator, X):
# type: (Any, Any) -> Optional[np.ndarray]
""" Return result of predict_proba, if an estimator supports it, or None.
"""
if is_probabilistic_classifier(estimator):
try:
proba, = estimator.predict_proba(X)
return proba
except NotImp... | python | def predict_proba(estimator, X):
# type: (Any, Any) -> Optional[np.ndarray]
""" Return result of predict_proba, if an estimator supports it, or None.
"""
if is_probabilistic_classifier(estimator):
try:
proba, = estimator.predict_proba(X)
return proba
except NotImp... | [
"def",
"predict_proba",
"(",
"estimator",
",",
"X",
")",
":",
"# type: (Any, Any) -> Optional[np.ndarray]",
"if",
"is_probabilistic_classifier",
"(",
"estimator",
")",
":",
"try",
":",
"proba",
",",
"=",
"estimator",
".",
"predict_proba",
"(",
"X",
")",
"return",
... | Return result of predict_proba, if an estimator supports it, or None. | [
"Return",
"result",
"of",
"predict_proba",
"if",
"an",
"estimator",
"supports",
"it",
"or",
"None",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L43-L54 | train | Predicts the probability of X in the node. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | has_intercept | def has_intercept(estimator):
# type: (Any) -> bool
""" Return True if an estimator has intercept fit. """
if hasattr(estimator, 'fit_intercept'):
return estimator.fit_intercept
if hasattr(estimator, 'intercept_'):
if estimator.intercept_ is None:
return False
# sciki... | python | def has_intercept(estimator):
# type: (Any) -> bool
""" Return True if an estimator has intercept fit. """
if hasattr(estimator, 'fit_intercept'):
return estimator.fit_intercept
if hasattr(estimator, 'intercept_'):
if estimator.intercept_ is None:
return False
# sciki... | [
"def",
"has_intercept",
"(",
"estimator",
")",
":",
"# type: (Any) -> bool",
"if",
"hasattr",
"(",
"estimator",
",",
"'fit_intercept'",
")",
":",
"return",
"estimator",
".",
"fit_intercept",
"if",
"hasattr",
"(",
"estimator",
",",
"'intercept_'",
")",
":",
"if",... | Return True if an estimator has intercept fit. | [
"Return",
"True",
"if",
"an",
"estimator",
"has",
"intercept",
"fit",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L57-L67 | train | Return True if an estimator has intercept fit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | get_feature_names | def get_feature_names(clf, vec=None, bias_name='<BIAS>', feature_names=None,
num_features=None, estimator_feature_names=None):
# type: (Any, Any, Optional[str], Any, int, Any) -> FeatureNames
"""
Return a FeatureNames instance that holds all feature names
and a bias feature.
If... | python | def get_feature_names(clf, vec=None, bias_name='<BIAS>', feature_names=None,
num_features=None, estimator_feature_names=None):
# type: (Any, Any, Optional[str], Any, int, Any) -> FeatureNames
"""
Return a FeatureNames instance that holds all feature names
and a bias feature.
If... | [
"def",
"get_feature_names",
"(",
"clf",
",",
"vec",
"=",
"None",
",",
"bias_name",
"=",
"'<BIAS>'",
",",
"feature_names",
"=",
"None",
",",
"num_features",
"=",
"None",
",",
"estimator_feature_names",
"=",
"None",
")",
":",
"# type: (Any, Any, Optional[str], Any, ... | Return a FeatureNames instance that holds all feature names
and a bias feature.
If vec is None or doesn't have get_feature_names() method,
features are named x0, x1, x2, etc. | [
"Return",
"a",
"FeatureNames",
"instance",
"that",
"holds",
"all",
"feature",
"names",
"and",
"a",
"bias",
"feature",
".",
"If",
"vec",
"is",
"None",
"or",
"doesn",
"t",
"have",
"get_feature_names",
"()",
"method",
"features",
"are",
"named",
"x0",
"x1",
"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L70-L112 | train | Returns a list of feature names for a given class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | get_default_target_names | def get_default_target_names(estimator, num_targets=None):
"""
Return a vector of target names: "y" if there is only one target,
and "y0", "y1", ... if there are multiple targets.
"""
if num_targets is None:
if len(estimator.coef_.shape) <= 1:
num_targets = 1
else:
... | python | def get_default_target_names(estimator, num_targets=None):
"""
Return a vector of target names: "y" if there is only one target,
and "y0", "y1", ... if there are multiple targets.
"""
if num_targets is None:
if len(estimator.coef_.shape) <= 1:
num_targets = 1
else:
... | [
"def",
"get_default_target_names",
"(",
"estimator",
",",
"num_targets",
"=",
"None",
")",
":",
"if",
"num_targets",
"is",
"None",
":",
"if",
"len",
"(",
"estimator",
".",
"coef_",
".",
"shape",
")",
"<=",
"1",
":",
"num_targets",
"=",
"1",
"else",
":",
... | Return a vector of target names: "y" if there is only one target,
and "y0", "y1", ... if there are multiple targets. | [
"Return",
"a",
"vector",
"of",
"target",
"names",
":",
"y",
"if",
"there",
"is",
"only",
"one",
"target",
"and",
"y0",
"y1",
"...",
"if",
"there",
"are",
"multiple",
"targets",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L131-L145 | train | Return a vector of target names for the default estimator. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | get_coef | def get_coef(clf, label_id, scale=None):
"""
Return a vector of coefficients for a given label,
including bias feature.
``scale`` (optional) is a scaling vector; coef_[i] => coef[i] * scale[i] if
scale[i] is not nan. Intercept is not scaled.
"""
if len(clf.coef_.shape) == 2:
# Most ... | python | def get_coef(clf, label_id, scale=None):
"""
Return a vector of coefficients for a given label,
including bias feature.
``scale`` (optional) is a scaling vector; coef_[i] => coef[i] * scale[i] if
scale[i] is not nan. Intercept is not scaled.
"""
if len(clf.coef_.shape) == 2:
# Most ... | [
"def",
"get_coef",
"(",
"clf",
",",
"label_id",
",",
"scale",
"=",
"None",
")",
":",
"if",
"len",
"(",
"clf",
".",
"coef_",
".",
"shape",
")",
"==",
"2",
":",
"# Most classifiers (even in binary case) and regressors",
"coef",
"=",
"_dense_1d",
"(",
"clf",
... | Return a vector of coefficients for a given label,
including bias feature.
``scale`` (optional) is a scaling vector; coef_[i] => coef[i] * scale[i] if
scale[i] is not nan. Intercept is not scaled. | [
"Return",
"a",
"vector",
"of",
"coefficients",
"for",
"a",
"given",
"label",
"including",
"bias",
"feature",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L148-L187 | train | Returns a vector of coefficients for a given label. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | get_num_features | def get_num_features(estimator):
""" Return size of a feature vector estimator expects as an input. """
if hasattr(estimator, 'coef_'): # linear models
if len(estimator.coef_.shape) == 0:
return 1
return estimator.coef_.shape[-1]
elif hasattr(estimator, 'feature_importances_'): ... | python | def get_num_features(estimator):
""" Return size of a feature vector estimator expects as an input. """
if hasattr(estimator, 'coef_'): # linear models
if len(estimator.coef_.shape) == 0:
return 1
return estimator.coef_.shape[-1]
elif hasattr(estimator, 'feature_importances_'): ... | [
"def",
"get_num_features",
"(",
"estimator",
")",
":",
"if",
"hasattr",
"(",
"estimator",
",",
"'coef_'",
")",
":",
"# linear models",
"if",
"len",
"(",
"estimator",
".",
"coef_",
".",
"shape",
")",
"==",
"0",
":",
"return",
"1",
"return",
"estimator",
"... | Return size of a feature vector estimator expects as an input. | [
"Return",
"size",
"of",
"a",
"feature",
"vector",
"estimator",
"expects",
"as",
"an",
"input",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L196-L213 | train | Return the size of a feature vector estimator expects as an input. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | get_X0 | def get_X0(X):
""" Return zero-th element of a one-element data container.
"""
if pandas_available and isinstance(X, pd.DataFrame):
assert len(X) == 1
x = np.array(X.iloc[0])
else:
x, = X
return x | python | def get_X0(X):
""" Return zero-th element of a one-element data container.
"""
if pandas_available and isinstance(X, pd.DataFrame):
assert len(X) == 1
x = np.array(X.iloc[0])
else:
x, = X
return x | [
"def",
"get_X0",
"(",
"X",
")",
":",
"if",
"pandas_available",
"and",
"isinstance",
"(",
"X",
",",
"pd",
".",
"DataFrame",
")",
":",
"assert",
"len",
"(",
"X",
")",
"==",
"1",
"x",
"=",
"np",
".",
"array",
"(",
"X",
".",
"iloc",
"[",
"0",
"]",
... | Return zero-th element of a one-element data container. | [
"Return",
"zero",
"-",
"th",
"element",
"of",
"a",
"one",
"-",
"element",
"data",
"container",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L239-L247 | train | Return zero - th element of a one - element data container. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | add_intercept | def add_intercept(X):
""" Add intercept column to X """
intercept = np.ones((X.shape[0], 1))
if sp.issparse(X):
return sp.hstack([X, intercept]).tocsr()
else:
return np.hstack([X, intercept]) | python | def add_intercept(X):
""" Add intercept column to X """
intercept = np.ones((X.shape[0], 1))
if sp.issparse(X):
return sp.hstack([X, intercept]).tocsr()
else:
return np.hstack([X, intercept]) | [
"def",
"add_intercept",
"(",
"X",
")",
":",
"intercept",
"=",
"np",
".",
"ones",
"(",
"(",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
")",
"if",
"sp",
".",
"issparse",
"(",
"X",
")",
":",
"return",
"sp",
".",
"hstack",
"(",
"[",
"X",
... | Add intercept column to X | [
"Add",
"intercept",
"column",
"to",
"X"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L266-L272 | train | Add intercept column to X | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn_crfsuite/explain_weights.py | explain_weights_sklearn_crfsuite | def explain_weights_sklearn_crfsuite(crf,
top=20,
target_names=None,
targets=None,
feature_re=None,
feature_filter=None):
""" Expla... | python | def explain_weights_sklearn_crfsuite(crf,
top=20,
target_names=None,
targets=None,
feature_re=None,
feature_filter=None):
""" Expla... | [
"def",
"explain_weights_sklearn_crfsuite",
"(",
"crf",
",",
"top",
"=",
"20",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"feature_re",
"=",
"None",
",",
"feature_filter",
"=",
"None",
")",
":",
"feature_names",
"=",
"np",
".",
"arr... | Explain sklearn_crfsuite.CRF weights.
See :func:`eli5.explain_weights` for description of
``top``, ``target_names``, ``targets``,
``feature_re`` and ``feature_filter`` parameters. | [
"Explain",
"sklearn_crfsuite",
".",
"CRF",
"weights",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn_crfsuite/explain_weights.py#L16-L65 | train | Explain sklearn_crfsuite. CRF weights. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn_crfsuite/explain_weights.py | filter_transition_coefs | def filter_transition_coefs(transition_coef, indices):
"""
>>> coef = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
>>> filter_transition_coefs(coef, [0])
array([[0]])
>>> filter_transition_coefs(coef, [1, 2])
array([[4, 5],
[7, 8]])
>>> filter_transition_coefs(coef, [2, 0])
arr... | python | def filter_transition_coefs(transition_coef, indices):
"""
>>> coef = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
>>> filter_transition_coefs(coef, [0])
array([[0]])
>>> filter_transition_coefs(coef, [1, 2])
array([[4, 5],
[7, 8]])
>>> filter_transition_coefs(coef, [2, 0])
arr... | [
"def",
"filter_transition_coefs",
"(",
"transition_coef",
",",
"indices",
")",
":",
"indices",
"=",
"np",
".",
"array",
"(",
"indices",
")",
"rows",
"=",
"transition_coef",
"[",
"indices",
"]",
"return",
"rows",
"[",
":",
",",
"indices",
"]"
] | >>> coef = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
>>> filter_transition_coefs(coef, [0])
array([[0]])
>>> filter_transition_coefs(coef, [1, 2])
array([[4, 5],
[7, 8]])
>>> filter_transition_coefs(coef, [2, 0])
array([[8, 6],
[2, 0]])
>>> filter_transition_coefs(coe... | [
">>>",
"coef",
"=",
"np",
".",
"array",
"(",
"[[",
"0",
"1",
"2",
"]",
"[",
"3",
"4",
"5",
"]",
"[",
"6",
"7",
"8",
"]]",
")",
">>>",
"filter_transition_coefs",
"(",
"coef",
"[",
"0",
"]",
")",
"array",
"(",
"[[",
"0",
"]]",
")",
">>>",
"fi... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn_crfsuite/explain_weights.py#L94-L112 | train | Filter the transition coefficients by indices. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn_crfsuite/explain_weights.py | sorted_for_ner | def sorted_for_ner(crf_classes):
"""
Return labels sorted in a default order suitable for NER tasks:
>>> sorted_for_ner(['B-ORG', 'B-PER', 'O', 'I-PER'])
['O', 'B-ORG', 'B-PER', 'I-PER']
"""
def key(cls):
if len(cls) > 2 and cls[1] == '-':
# group names like B-ORG and I-ORG ... | python | def sorted_for_ner(crf_classes):
"""
Return labels sorted in a default order suitable for NER tasks:
>>> sorted_for_ner(['B-ORG', 'B-PER', 'O', 'I-PER'])
['O', 'B-ORG', 'B-PER', 'I-PER']
"""
def key(cls):
if len(cls) > 2 and cls[1] == '-':
# group names like B-ORG and I-ORG ... | [
"def",
"sorted_for_ner",
"(",
"crf_classes",
")",
":",
"def",
"key",
"(",
"cls",
")",
":",
"if",
"len",
"(",
"cls",
")",
">",
"2",
"and",
"cls",
"[",
"1",
"]",
"==",
"'-'",
":",
"# group names like B-ORG and I-ORG together",
"return",
"cls",
".",
"split"... | Return labels sorted in a default order suitable for NER tasks:
>>> sorted_for_ner(['B-ORG', 'B-PER', 'O', 'I-PER'])
['O', 'B-ORG', 'B-PER', 'I-PER'] | [
"Return",
"labels",
"sorted",
"in",
"a",
"default",
"order",
"suitable",
"for",
"NER",
"tasks",
":"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn_crfsuite/explain_weights.py#L115-L127 | train | Return a list of crf_classes sorted in a default order suitable for NER tasks. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dict.py | _numpy_to_python | def _numpy_to_python(obj):
""" Convert an nested dict/list/tuple that might contain numpy objects
to their python equivalents. Return converted object.
"""
if isinstance(obj, dict):
return {k: _numpy_to_python(v) for k, v in obj.items()}
elif isinstance(obj, (list, tuple, np.ndarray)):
... | python | def _numpy_to_python(obj):
""" Convert an nested dict/list/tuple that might contain numpy objects
to their python equivalents. Return converted object.
"""
if isinstance(obj, dict):
return {k: _numpy_to_python(v) for k, v in obj.items()}
elif isinstance(obj, (list, tuple, np.ndarray)):
... | [
"def",
"_numpy_to_python",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"{",
"k",
":",
"_numpy_to_python",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"obj",
".",
"items",
"(",
")",
"}",
"elif",
"isinstance"... | Convert an nested dict/list/tuple that might contain numpy objects
to their python equivalents. Return converted object. | [
"Convert",
"an",
"nested",
"dict",
"/",
"list",
"/",
"tuple",
"that",
"might",
"contain",
"numpy",
"objects",
"to",
"their",
"python",
"equivalents",
".",
"Return",
"converted",
"object",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dict.py#L19-L38 | train | Convert a numpy object to their python equivalents. Return converted object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/samplers.py | MaskingTextSamplers._sampler_n_samples | def _sampler_n_samples(self, n_samples):
""" Return (sampler, n_samplers) tuples """
sampler_indices = self.rng_.choice(range(len(self.samplers)),
size=n_samples,
replace=True,
... | python | def _sampler_n_samples(self, n_samples):
""" Return (sampler, n_samplers) tuples """
sampler_indices = self.rng_.choice(range(len(self.samplers)),
size=n_samples,
replace=True,
... | [
"def",
"_sampler_n_samples",
"(",
"self",
",",
"n_samples",
")",
":",
"sampler_indices",
"=",
"self",
".",
"rng_",
".",
"choice",
"(",
"range",
"(",
"len",
"(",
"self",
".",
"samplers",
")",
")",
",",
"size",
"=",
"n_samples",
",",
"replace",
"=",
"Tru... | Return (sampler, n_samplers) tuples | [
"Return",
"(",
"sampler",
"n_samplers",
")",
"tuples"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/samplers.py#L183-L192 | train | Return n_samplers sampler tuples | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/samplers.py | UnivariateKernelDensitySampler.sample_near | def sample_near(self, doc, n_samples=1):
"""
Sample near the document by replacing some of its features
with values sampled from distribution found by KDE.
"""
doc = np.asarray(doc)
num_features = len(self.kdes_)
sizes = self.rng_.randint(low=1, high=num_features ... | python | def sample_near(self, doc, n_samples=1):
"""
Sample near the document by replacing some of its features
with values sampled from distribution found by KDE.
"""
doc = np.asarray(doc)
num_features = len(self.kdes_)
sizes = self.rng_.randint(low=1, high=num_features ... | [
"def",
"sample_near",
"(",
"self",
",",
"doc",
",",
"n_samples",
"=",
"1",
")",
":",
"doc",
"=",
"np",
".",
"asarray",
"(",
"doc",
")",
"num_features",
"=",
"len",
"(",
"self",
".",
"kdes_",
")",
"sizes",
"=",
"self",
".",
"rng_",
".",
"randint",
... | Sample near the document by replacing some of its features
with values sampled from distribution found by KDE. | [
"Sample",
"near",
"the",
"document",
"by",
"replacing",
"some",
"of",
"its",
"features",
"with",
"values",
"sampled",
"from",
"distribution",
"found",
"by",
"KDE",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/samplers.py#L295-L312 | train | Sample near the document by replacing some of its features
with values sampled from distribution found by KDE. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/_feature_names.py | _all_feature_names | def _all_feature_names(name):
# type: (Union[str, bytes, List[Dict]]) -> List[str]
""" All feature names for a feature: usually just the feature itself,
but can be several features for unhashed features with collisions.
"""
if isinstance(name, bytes):
return [name.decode('utf8')]
elif is... | python | def _all_feature_names(name):
# type: (Union[str, bytes, List[Dict]]) -> List[str]
""" All feature names for a feature: usually just the feature itself,
but can be several features for unhashed features with collisions.
"""
if isinstance(name, bytes):
return [name.decode('utf8')]
elif is... | [
"def",
"_all_feature_names",
"(",
"name",
")",
":",
"# type: (Union[str, bytes, List[Dict]]) -> List[str]",
"if",
"isinstance",
"(",
"name",
",",
"bytes",
")",
":",
"return",
"[",
"name",
".",
"decode",
"(",
"'utf8'",
")",
"]",
"elif",
"isinstance",
"(",
"name",... | All feature names for a feature: usually just the feature itself,
but can be several features for unhashed features with collisions. | [
"All",
"feature",
"names",
"for",
"a",
"feature",
":",
"usually",
"just",
"the",
"feature",
"itself",
"but",
"can",
"be",
"several",
"features",
"for",
"unhashed",
"features",
"with",
"collisions",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/_feature_names.py#L182-L192 | train | Returns a list of all feature names for a given feature. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/_feature_names.py | FeatureNames.filtered | def filtered(self, feature_filter, x=None):
# type: (Callable, Any) -> Tuple[FeatureNames, List[int]]
""" Return feature names filtered by a regular expression
``feature_re``, and indices of filtered elements.
"""
indices = []
filtered_feature_names = []
indexed_... | python | def filtered(self, feature_filter, x=None):
# type: (Callable, Any) -> Tuple[FeatureNames, List[int]]
""" Return feature names filtered by a regular expression
``feature_re``, and indices of filtered elements.
"""
indices = []
filtered_feature_names = []
indexed_... | [
"def",
"filtered",
"(",
"self",
",",
"feature_filter",
",",
"x",
"=",
"None",
")",
":",
"# type: (Callable, Any) -> Tuple[FeatureNames, List[int]]",
"indices",
"=",
"[",
"]",
"filtered_feature_names",
"=",
"[",
"]",
"indexed_names",
"=",
"None",
"# type: Optional[Iter... | Return feature names filtered by a regular expression
``feature_re``, and indices of filtered elements. | [
"Return",
"feature",
"names",
"filtered",
"by",
"a",
"regular",
"expression",
"feature_re",
"and",
"indices",
"of",
"filtered",
"elements",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/_feature_names.py#L98-L140 | train | Return a list of feature names filtered by a regular expression
feature_re and indices of filtered elements. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/_feature_names.py | FeatureNames.add_feature | def add_feature(self, feature):
# type: (Any) -> int
""" Add a new feature name, return it's index.
"""
# A copy of self.feature_names is always made, because it might be
# "owned" by someone else.
# It's possible to make the copy only at the first call to
# self.... | python | def add_feature(self, feature):
# type: (Any) -> int
""" Add a new feature name, return it's index.
"""
# A copy of self.feature_names is always made, because it might be
# "owned" by someone else.
# It's possible to make the copy only at the first call to
# self.... | [
"def",
"add_feature",
"(",
"self",
",",
"feature",
")",
":",
"# type: (Any) -> int",
"# A copy of self.feature_names is always made, because it might be",
"# \"owned\" by someone else.",
"# It's possible to make the copy only at the first call to",
"# self.add_feature to improve performance.... | Add a new feature name, return it's index. | [
"Add",
"a",
"new",
"feature",
"name",
"return",
"it",
"s",
"index",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/_feature_names.py#L161-L179 | train | Add a new feature name to the internal list of features. Return the index of the new feature name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/text.py | format_as_text | def format_as_text(expl, # type: Explanation
show=fields.ALL,
highlight_spaces=None, # type: Optional[bool]
show_feature_values=False, # type: bool
):
# type: (...) -> str
""" Format explanation as text.
Parameters
---------... | python | def format_as_text(expl, # type: Explanation
show=fields.ALL,
highlight_spaces=None, # type: Optional[bool]
show_feature_values=False, # type: bool
):
# type: (...) -> str
""" Format explanation as text.
Parameters
---------... | [
"def",
"format_as_text",
"(",
"expl",
",",
"# type: Explanation",
"show",
"=",
"fields",
".",
"ALL",
",",
"highlight_spaces",
"=",
"None",
",",
"# type: Optional[bool]",
"show_feature_values",
"=",
"False",
",",
"# type: bool",
")",
":",
"# type: (...) -> str",
"lin... | Format explanation as text.
Parameters
----------
expl : eli5.base.Explanation
Explanation returned by ``eli5.explain_weights`` or
``eli5.explain_prediction`` functions.
highlight_spaces : bool or None, optional
Whether to highlight spaces in feature names. This is useful if
... | [
"Format",
"explanation",
"as",
"text",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/text.py#L21-L99 | train | Format an explanation as text. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/text.py | _format_unhashed_feature | def _format_unhashed_feature(name, hl_spaces, sep=' | '):
# type: (List, bool, str) -> str
"""
Format feature name for hashed features.
"""
return sep.join(
format_signed(n, _format_single_feature, hl_spaces=hl_spaces)
for n in name) | python | def _format_unhashed_feature(name, hl_spaces, sep=' | '):
# type: (List, bool, str) -> str
"""
Format feature name for hashed features.
"""
return sep.join(
format_signed(n, _format_single_feature, hl_spaces=hl_spaces)
for n in name) | [
"def",
"_format_unhashed_feature",
"(",
"name",
",",
"hl_spaces",
",",
"sep",
"=",
"' | '",
")",
":",
"# type: (List, bool, str) -> str",
"return",
"sep",
".",
"join",
"(",
"format_signed",
"(",
"n",
",",
"_format_single_feature",
",",
"hl_spaces",
"=",
"hl_spaces... | Format feature name for hashed features. | [
"Format",
"feature",
"name",
"for",
"hashed",
"features",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/text.py#L270-L277 | train | Format unhashed features. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/_feature_weights.py | _get_top_features | def _get_top_features(feature_names, coef, top, x):
"""
Return a ``(pos, neg)`` tuple. ``pos`` and ``neg`` are lists of
``(name, value)`` tuples for features with positive and negative
coefficients.
Parameters:
* ``feature_names`` - a vector of feature names;
* ``coef`` - coefficient vecto... | python | def _get_top_features(feature_names, coef, top, x):
"""
Return a ``(pos, neg)`` tuple. ``pos`` and ``neg`` are lists of
``(name, value)`` tuples for features with positive and negative
coefficients.
Parameters:
* ``feature_names`` - a vector of feature names;
* ``coef`` - coefficient vecto... | [
"def",
"_get_top_features",
"(",
"feature_names",
",",
"coef",
",",
"top",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"top",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"num_pos",
",",
"num_neg",
"=",
"list",
"(",
"top",
")",
"# \"list\" is just f... | Return a ``(pos, neg)`` tuple. ``pos`` and ``neg`` are lists of
``(name, value)`` tuples for features with positive and negative
coefficients.
Parameters:
* ``feature_names`` - a vector of feature names;
* ``coef`` - coefficient vector; coef.shape must be equal to
feature_names.shape;
* ... | [
"Return",
"a",
"(",
"pos",
"neg",
")",
"tuple",
".",
"pos",
"and",
"neg",
"are",
"lists",
"of",
"(",
"name",
"value",
")",
"tuples",
"for",
"features",
"with",
"positive",
"and",
"negative",
"coefficients",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/_feature_weights.py#L10-L35 | train | Internal function to get the top features of a tree tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/text_helpers.py | get_char_weights | def get_char_weights(doc_weighted_spans, preserve_density=None):
# type: (DocWeightedSpans, Optional[bool]) -> np.ndarray
""" Return character weights for a text document with highlighted features.
If preserve_density is True, then color for longer fragments will be
less intensive than for shorter fragm... | python | def get_char_weights(doc_weighted_spans, preserve_density=None):
# type: (DocWeightedSpans, Optional[bool]) -> np.ndarray
""" Return character weights for a text document with highlighted features.
If preserve_density is True, then color for longer fragments will be
less intensive than for shorter fragm... | [
"def",
"get_char_weights",
"(",
"doc_weighted_spans",
",",
"preserve_density",
"=",
"None",
")",
":",
"# type: (DocWeightedSpans, Optional[bool]) -> np.ndarray",
"if",
"preserve_density",
"is",
"None",
":",
"preserve_density",
"=",
"doc_weighted_spans",
".",
"preserve_density... | Return character weights for a text document with highlighted features.
If preserve_density is True, then color for longer fragments will be
less intensive than for shorter fragments, so that "sum" of intensities
will correspond to feature weight.
If preserve_density is None, then it's value is taken fr... | [
"Return",
"character",
"weights",
"for",
"a",
"text",
"document",
"with",
"highlighted",
"features",
".",
"If",
"preserve_density",
"is",
"True",
"then",
"color",
"for",
"longer",
"fragments",
"will",
"be",
"less",
"intensive",
"than",
"for",
"shorter",
"fragmen... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/text_helpers.py#L11-L32 | train | Return the character weights for a text document with highlighted features. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/text_helpers.py | prepare_weighted_spans | def prepare_weighted_spans(targets, # type: List[TargetExplanation]
preserve_density=None, # type: Optional[bool]
):
# type: (...) -> List[Optional[List[PreparedWeightedSpans]]]
""" Return weighted spans prepared for rendering.
Calculate a separate wei... | python | def prepare_weighted_spans(targets, # type: List[TargetExplanation]
preserve_density=None, # type: Optional[bool]
):
# type: (...) -> List[Optional[List[PreparedWeightedSpans]]]
""" Return weighted spans prepared for rendering.
Calculate a separate wei... | [
"def",
"prepare_weighted_spans",
"(",
"targets",
",",
"# type: List[TargetExplanation]",
"preserve_density",
"=",
"None",
",",
"# type: Optional[bool]",
")",
":",
"# type: (...) -> List[Optional[List[PreparedWeightedSpans]]]",
"targets_char_weights",
"=",
"[",
"[",
"get_char_weig... | Return weighted spans prepared for rendering.
Calculate a separate weight range for each different weighted
span (for each different index): each target has the same number
of weighted spans. | [
"Return",
"weighted",
"spans",
"prepared",
"for",
"rendering",
".",
"Calculate",
"a",
"separate",
"weight",
"range",
"for",
"each",
"different",
"weighted",
"span",
"(",
"for",
"each",
"different",
"index",
")",
":",
"each",
"target",
"has",
"the",
"same",
"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/text_helpers.py#L58-L90 | train | Prepare weighted spans for rendering. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/_span_analyzers.py | build_span_analyzer | def build_span_analyzer(document, vec):
""" Return an analyzer and the preprocessed doc.
Analyzer will yield pairs of spans and feature, where spans are pairs
of indices into the preprocessed doc. The idea here is to do minimal
preprocessing so that we can still recover the same features as sklearn
... | python | def build_span_analyzer(document, vec):
""" Return an analyzer and the preprocessed doc.
Analyzer will yield pairs of spans and feature, where spans are pairs
of indices into the preprocessed doc. The idea here is to do minimal
preprocessing so that we can still recover the same features as sklearn
... | [
"def",
"build_span_analyzer",
"(",
"document",
",",
"vec",
")",
":",
"preprocessed_doc",
"=",
"vec",
".",
"build_preprocessor",
"(",
")",
"(",
"vec",
".",
"decode",
"(",
"document",
")",
")",
"analyzer",
"=",
"None",
"if",
"vec",
".",
"analyzer",
"==",
"... | Return an analyzer and the preprocessed doc.
Analyzer will yield pairs of spans and feature, where spans are pairs
of indices into the preprocessed doc. The idea here is to do minimal
preprocessing so that we can still recover the same features as sklearn
vectorizers, but with spans, that will allow us ... | [
"Return",
"an",
"analyzer",
"and",
"the",
"preprocessed",
"doc",
".",
"Analyzer",
"will",
"yield",
"pairs",
"of",
"spans",
"and",
"feature",
"where",
"spans",
"are",
"pairs",
"of",
"indices",
"into",
"the",
"preprocessed",
"doc",
".",
"The",
"idea",
"here",
... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/_span_analyzers.py#L7-L28 | train | Build an analyzer and preprocessed doc. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | explain_weights_xgboost | def explain_weights_xgboost(xgb,
vec=None,
top=20,
target_names=None, # ignored
targets=None, # ignored
feature_names=None,
feature_re=None, # type: ... | python | def explain_weights_xgboost(xgb,
vec=None,
top=20,
target_names=None, # ignored
targets=None, # ignored
feature_names=None,
feature_re=None, # type: ... | [
"def",
"explain_weights_xgboost",
"(",
"xgb",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"20",
",",
"target_names",
"=",
"None",
",",
"# ignored",
"targets",
"=",
"None",
",",
"# ignored",
"feature_names",
"=",
"None",
",",
"feature_re",
"=",
"None",
",",
... | Return an explanation of an XGBoost estimator (via scikit-learn wrapper
XGBClassifier or XGBRegressor, or via xgboost.Booster)
as feature importances.
See :func:`eli5.explain_weights` for description of
``top``, ``feature_names``,
``feature_re`` and ``feature_filter`` parameters.
``target_name... | [
"Return",
"an",
"explanation",
"of",
"an",
"XGBoost",
"estimator",
"(",
"via",
"scikit",
"-",
"learn",
"wrapper",
"XGBClassifier",
"or",
"XGBRegressor",
"or",
"via",
"xgboost",
".",
"Booster",
")",
"as",
"feature",
"importances",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L38-L83 | train | Return an explanation of an XGBoost estimator or XGBRegressor or XGBClassifier or XGBClassifier or XGBRegressor. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | explain_prediction_xgboost | def explain_prediction_xgboost(
xgb, doc,
vec=None,
top=None,
top_targets=None,
target_names=None,
targets=None,
feature_names=None,
feature_re=None, # type: Pattern[str]
feature_filter=None,
vectorized=False, # type: bool
is_regr... | python | def explain_prediction_xgboost(
xgb, doc,
vec=None,
top=None,
top_targets=None,
target_names=None,
targets=None,
feature_names=None,
feature_re=None, # type: Pattern[str]
feature_filter=None,
vectorized=False, # type: bool
is_regr... | [
"def",
"explain_prediction_xgboost",
"(",
"xgb",
",",
"doc",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"None",
",",
"top_targets",
"=",
"None",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"featur... | Return an explanation of XGBoost prediction (via scikit-learn wrapper
XGBClassifier or XGBRegressor, or via xgboost.Booster) as feature weights.
See :func:`eli5.explain_prediction` for description of
``top``, ``top_targets``, ``target_names``, ``targets``,
``feature_names``, ``feature_re`` and ``featur... | [
"Return",
"an",
"explanation",
"of",
"XGBoost",
"prediction",
"(",
"via",
"scikit",
"-",
"learn",
"wrapper",
"XGBClassifier",
"or",
"XGBRegressor",
"or",
"via",
"xgboost",
".",
"Booster",
")",
"as",
"feature",
"weights",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L89-L217 | train | Return an explanation of XGBoost prediction for a given document. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | _prediction_feature_weights | def _prediction_feature_weights(booster, dmatrix, n_targets,
feature_names, xgb_feature_names):
""" For each target, return score and numpy array with feature weights
on this prediction, following an idea from
http://blog.datadive.net/interpreting-random-forests/
"""
... | python | def _prediction_feature_weights(booster, dmatrix, n_targets,
feature_names, xgb_feature_names):
""" For each target, return score and numpy array with feature weights
on this prediction, following an idea from
http://blog.datadive.net/interpreting-random-forests/
"""
... | [
"def",
"_prediction_feature_weights",
"(",
"booster",
",",
"dmatrix",
",",
"n_targets",
",",
"feature_names",
",",
"xgb_feature_names",
")",
":",
"# XGBClassifier does not have pred_leaf argument, so use booster",
"leaf_ids",
",",
"=",
"booster",
".",
"predict",
"(",
"dma... | For each target, return score and numpy array with feature weights
on this prediction, following an idea from
http://blog.datadive.net/interpreting-random-forests/ | [
"For",
"each",
"target",
"return",
"score",
"and",
"numpy",
"array",
"with",
"feature",
"weights",
"on",
"this",
"prediction",
"following",
"an",
"idea",
"from",
"http",
":",
"//",
"blog",
".",
"datadive",
".",
"net",
"/",
"interpreting",
"-",
"random",
"-... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L239-L264 | train | Predicts the feature weights on the given tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | _indexed_leafs | def _indexed_leafs(parent):
""" Return a leaf nodeid -> node dictionary with
"parent" and "leaf" (average child "leaf" value) added to all nodes.
"""
if not parent.get('children'):
return {parent['nodeid']: parent}
indexed = {}
for child in parent['children']:
child['parent'] = p... | python | def _indexed_leafs(parent):
""" Return a leaf nodeid -> node dictionary with
"parent" and "leaf" (average child "leaf" value) added to all nodes.
"""
if not parent.get('children'):
return {parent['nodeid']: parent}
indexed = {}
for child in parent['children']:
child['parent'] = p... | [
"def",
"_indexed_leafs",
"(",
"parent",
")",
":",
"if",
"not",
"parent",
".",
"get",
"(",
"'children'",
")",
":",
"return",
"{",
"parent",
"[",
"'nodeid'",
"]",
":",
"parent",
"}",
"indexed",
"=",
"{",
"}",
"for",
"child",
"in",
"parent",
"[",
"'chil... | Return a leaf nodeid -> node dictionary with
"parent" and "leaf" (average child "leaf" value) added to all nodes. | [
"Return",
"a",
"leaf",
"nodeid",
"-",
">",
"node",
"dictionary",
"with",
"parent",
"and",
"leaf",
"(",
"average",
"child",
"leaf",
"value",
")",
"added",
"to",
"all",
"nodes",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L291-L305 | train | Return a dictionary with the leaf nodeid and leaf value added to all nodes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | _parent_value | def _parent_value(children):
# type: (...) -> int
""" Value of the parent node: a weighted sum of child values.
"""
covers = np.array([child['cover'] for child in children])
covers /= np.sum(covers)
leafs = np.array([child['leaf'] for child in children])
return np.sum(leafs * covers) | python | def _parent_value(children):
# type: (...) -> int
""" Value of the parent node: a weighted sum of child values.
"""
covers = np.array([child['cover'] for child in children])
covers /= np.sum(covers)
leafs = np.array([child['leaf'] for child in children])
return np.sum(leafs * covers) | [
"def",
"_parent_value",
"(",
"children",
")",
":",
"# type: (...) -> int",
"covers",
"=",
"np",
".",
"array",
"(",
"[",
"child",
"[",
"'cover'",
"]",
"for",
"child",
"in",
"children",
"]",
")",
"covers",
"/=",
"np",
".",
"sum",
"(",
"covers",
")",
"lea... | Value of the parent node: a weighted sum of child values. | [
"Value",
"of",
"the",
"parent",
"node",
":",
"a",
"weighted",
"sum",
"of",
"child",
"values",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L308-L315 | train | Returns the value of the parent node. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | _parse_tree_dump | def _parse_tree_dump(text_dump):
# type: (str) -> Optional[Dict[str, Any]]
""" Parse text tree dump (one item of a list returned by Booster.get_dump())
into json format that will be used by next XGBoost release.
"""
result = None
stack = [] # type: List[Dict]
for line in text_dump.split('\n... | python | def _parse_tree_dump(text_dump):
# type: (str) -> Optional[Dict[str, Any]]
""" Parse text tree dump (one item of a list returned by Booster.get_dump())
into json format that will be used by next XGBoost release.
"""
result = None
stack = [] # type: List[Dict]
for line in text_dump.split('\n... | [
"def",
"_parse_tree_dump",
"(",
"text_dump",
")",
":",
"# type: (str) -> Optional[Dict[str, Any]]",
"result",
"=",
"None",
"stack",
"=",
"[",
"]",
"# type: List[Dict]",
"for",
"line",
"in",
"text_dump",
".",
"split",
"(",
"'\\n'",
")",
":",
"if",
"line",
":",
... | Parse text tree dump (one item of a list returned by Booster.get_dump())
into json format that will be used by next XGBoost release. | [
"Parse",
"text",
"tree",
"dump",
"(",
"one",
"item",
"of",
"a",
"list",
"returned",
"by",
"Booster",
".",
"get_dump",
"()",
")",
"into",
"json",
"format",
"that",
"will",
"be",
"used",
"by",
"next",
"XGBoost",
"release",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L335-L356 | train | Parses the text tree dump into a dict that will be used by next XGBoost release release. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/xgboost.py | _missing_values_set_to_nan | def _missing_values_set_to_nan(values, missing_value, sparse_missing):
""" Return a copy of values where missing values (equal to missing_value)
are replaced to nan according. If sparse_missing is True,
entries missing in a sparse matrix will also be set to nan.
Sparse matrices will be converted to dens... | python | def _missing_values_set_to_nan(values, missing_value, sparse_missing):
""" Return a copy of values where missing values (equal to missing_value)
are replaced to nan according. If sparse_missing is True,
entries missing in a sparse matrix will also be set to nan.
Sparse matrices will be converted to dens... | [
"def",
"_missing_values_set_to_nan",
"(",
"values",
",",
"missing_value",
",",
"sparse_missing",
")",
":",
"if",
"sp",
".",
"issparse",
"(",
"values",
")",
":",
"assert",
"values",
".",
"shape",
"[",
"0",
"]",
"==",
"1",
"if",
"sparse_missing",
"and",
"sp"... | Return a copy of values where missing values (equal to missing_value)
are replaced to nan according. If sparse_missing is True,
entries missing in a sparse matrix will also be set to nan.
Sparse matrices will be converted to dense format. | [
"Return",
"a",
"copy",
"of",
"values",
"where",
"missing",
"values",
"(",
"equal",
"to",
"missing_value",
")",
"are",
"replaced",
"to",
"nan",
"according",
".",
"If",
"sparse_missing",
"is",
"True",
"entries",
"missing",
"in",
"a",
"sparse",
"matrix",
"will"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L392-L415 | train | Return a copy of values where missing values are replaced to nan according. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | argsort_k_smallest | def argsort_k_smallest(x, k):
""" Return no more than ``k`` indices of smallest values. """
if k == 0:
return np.array([], dtype=np.intp)
if k is None or k >= len(x):
return np.argsort(x)
indices = np.argpartition(x, k)[:k]
values = x[indices]
return indices[np.argsort(values)] | python | def argsort_k_smallest(x, k):
""" Return no more than ``k`` indices of smallest values. """
if k == 0:
return np.array([], dtype=np.intp)
if k is None or k >= len(x):
return np.argsort(x)
indices = np.argpartition(x, k)[:k]
values = x[indices]
return indices[np.argsort(values)] | [
"def",
"argsort_k_smallest",
"(",
"x",
",",
"k",
")",
":",
"if",
"k",
"==",
"0",
":",
"return",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"np",
".",
"intp",
")",
"if",
"k",
"is",
"None",
"or",
"k",
">=",
"len",
"(",
"x",
")",
":... | Return no more than ``k`` indices of smallest values. | [
"Return",
"no",
"more",
"than",
"k",
"indices",
"of",
"smallest",
"values",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L23-L31 | train | Return no more than k indices of smallest values. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | mask | def mask(x, indices):
"""
The same as x[indices], but return an empty array if indices are empty,
instead of returning all x elements,
and handles sparse "vectors".
"""
indices_shape = (
[len(indices)] if isinstance(indices, list) else indices.shape)
if not indices_shape[0]:
... | python | def mask(x, indices):
"""
The same as x[indices], but return an empty array if indices are empty,
instead of returning all x elements,
and handles sparse "vectors".
"""
indices_shape = (
[len(indices)] if isinstance(indices, list) else indices.shape)
if not indices_shape[0]:
... | [
"def",
"mask",
"(",
"x",
",",
"indices",
")",
":",
"indices_shape",
"=",
"(",
"[",
"len",
"(",
"indices",
")",
"]",
"if",
"isinstance",
"(",
"indices",
",",
"list",
")",
"else",
"indices",
".",
"shape",
")",
"if",
"not",
"indices_shape",
"[",
"0",
... | The same as x[indices], but return an empty array if indices are empty,
instead of returning all x elements,
and handles sparse "vectors". | [
"The",
"same",
"as",
"x",
"[",
"indices",
"]",
"but",
"return",
"an",
"empty",
"array",
"if",
"indices",
"are",
"empty",
"instead",
"of",
"returning",
"all",
"x",
"elements",
"and",
"handles",
"sparse",
"vectors",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L34-L47 | train | A function that returns a single array with the same shape as x. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | is_sparse_vector | def is_sparse_vector(x):
""" x is a 2D sparse matrix with it's first shape equal to 1.
"""
return sp.issparse(x) and len(x.shape) == 2 and x.shape[0] == 1 | python | def is_sparse_vector(x):
""" x is a 2D sparse matrix with it's first shape equal to 1.
"""
return sp.issparse(x) and len(x.shape) == 2 and x.shape[0] == 1 | [
"def",
"is_sparse_vector",
"(",
"x",
")",
":",
"return",
"sp",
".",
"issparse",
"(",
"x",
")",
"and",
"len",
"(",
"x",
".",
"shape",
")",
"==",
"2",
"and",
"x",
".",
"shape",
"[",
"0",
"]",
"==",
"1"
] | x is a 2D sparse matrix with it's first shape equal to 1. | [
"x",
"is",
"a",
"2D",
"sparse",
"matrix",
"with",
"it",
"s",
"first",
"shape",
"equal",
"to",
"1",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L50-L53 | train | Check if x is a 2D sparse matrix with first shape equal to 1. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | indices_to_bool_mask | def indices_to_bool_mask(indices, size):
""" Convert indices to a boolean (integer) mask.
>>> list(indices_to_bool_mask(np.array([2, 3]), 4))
[False, False, True, True]
>>> list(indices_to_bool_mask([2, 3], 4))
[False, False, True, True]
>>> indices_to_bool_mask(np.array([5]), 2)
Tracebac... | python | def indices_to_bool_mask(indices, size):
""" Convert indices to a boolean (integer) mask.
>>> list(indices_to_bool_mask(np.array([2, 3]), 4))
[False, False, True, True]
>>> list(indices_to_bool_mask([2, 3], 4))
[False, False, True, True]
>>> indices_to_bool_mask(np.array([5]), 2)
Tracebac... | [
"def",
"indices_to_bool_mask",
"(",
"indices",
",",
"size",
")",
":",
"mask",
"=",
"np",
".",
"zeros",
"(",
"size",
",",
"dtype",
"=",
"bool",
")",
"mask",
"[",
"indices",
"]",
"=",
"1",
"return",
"mask"
] | Convert indices to a boolean (integer) mask.
>>> list(indices_to_bool_mask(np.array([2, 3]), 4))
[False, False, True, True]
>>> list(indices_to_bool_mask([2, 3], 4))
[False, False, True, True]
>>> indices_to_bool_mask(np.array([5]), 2)
Traceback (most recent call last):
...
IndexError... | [
"Convert",
"indices",
"to",
"a",
"boolean",
"(",
"integer",
")",
"mask",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L56-L72 | train | Convert indices to a boolean mask. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | get_target_display_names | def get_target_display_names(original_names=None, target_names=None,
targets=None, top_targets=None, score=None):
"""
Return a list of (target_id, display_name) tuples.
By default original names are passed as-is, only indices are added:
>>> get_target_display_names(['x', 'y... | python | def get_target_display_names(original_names=None, target_names=None,
targets=None, top_targets=None, score=None):
"""
Return a list of (target_id, display_name) tuples.
By default original names are passed as-is, only indices are added:
>>> get_target_display_names(['x', 'y... | [
"def",
"get_target_display_names",
"(",
"original_names",
"=",
"None",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"top_targets",
"=",
"None",
",",
"score",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"target_names",
",",
"(",
"... | Return a list of (target_id, display_name) tuples.
By default original names are passed as-is, only indices are added:
>>> get_target_display_names(['x', 'y'])
[(0, 'x'), (1, 'y')]
``targets`` can be written using both names from ``target_names` and
from ``original_names``:
>>> get_target_disp... | [
"Return",
"a",
"list",
"of",
"(",
"target_id",
"display_name",
")",
"tuples",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L84-L177 | train | Get a list of target_id and display_name tuples. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | get_binary_target_scale_label_id | def get_binary_target_scale_label_id(score, display_names, proba=None):
"""
Return (target_name, scale, label_id) tuple for a binary classifier.
>>> get_binary_target_scale_label_id(+5.0, get_target_display_names([False, True]))
(True, 1, 1)
>>> get_binary_target_scale_label_id(-5.0, get_target_dis... | python | def get_binary_target_scale_label_id(score, display_names, proba=None):
"""
Return (target_name, scale, label_id) tuple for a binary classifier.
>>> get_binary_target_scale_label_id(+5.0, get_target_display_names([False, True]))
(True, 1, 1)
>>> get_binary_target_scale_label_id(-5.0, get_target_dis... | [
"def",
"get_binary_target_scale_label_id",
"(",
"score",
",",
"display_names",
",",
"proba",
"=",
"None",
")",
":",
"if",
"score",
"is",
"not",
"None",
":",
"label_id",
"=",
"1",
"if",
"score",
">=",
"0",
"else",
"0",
"scale",
"=",
"-",
"1",
"if",
"lab... | Return (target_name, scale, label_id) tuple for a binary classifier.
>>> get_binary_target_scale_label_id(+5.0, get_target_display_names([False, True]))
(True, 1, 1)
>>> get_binary_target_scale_label_id(-5.0, get_target_display_names([False, True]))
(False, -1, 0)
>>> get_binary_target_scale_label_... | [
"Return",
"(",
"target_name",
"scale",
"label_id",
")",
"tuple",
"for",
"a",
"binary",
"classifier",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L180-L210 | train | Return the target scale and label_id tuple for a binary classifier. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/utils.py | _get_value_indices | def _get_value_indices(names1, names2, lookups):
"""
>>> _get_value_indices(['foo', 'bar', 'baz'], ['foo', 'bar', 'baz'],
... ['bar', 'foo'])
[1, 0]
>>> _get_value_indices(['foo', 'bar', 'baz'], ['FOO', 'bar', 'baz'],
... ['bar', 'FOO'])
[1, 0]
>>> _... | python | def _get_value_indices(names1, names2, lookups):
"""
>>> _get_value_indices(['foo', 'bar', 'baz'], ['foo', 'bar', 'baz'],
... ['bar', 'foo'])
[1, 0]
>>> _get_value_indices(['foo', 'bar', 'baz'], ['FOO', 'bar', 'baz'],
... ['bar', 'FOO'])
[1, 0]
>>> _... | [
"def",
"_get_value_indices",
"(",
"names1",
",",
"names2",
",",
"lookups",
")",
":",
"positions",
"=",
"{",
"name",
":",
"idx",
"for",
"idx",
",",
"name",
"in",
"enumerate",
"(",
"names2",
")",
"}",
"positions",
".",
"update",
"(",
"{",
"name",
":",
... | >>> _get_value_indices(['foo', 'bar', 'baz'], ['foo', 'bar', 'baz'],
... ['bar', 'foo'])
[1, 0]
>>> _get_value_indices(['foo', 'bar', 'baz'], ['FOO', 'bar', 'baz'],
... ['bar', 'FOO'])
[1, 0]
>>> _get_value_indices(['foo', 'bar', 'BAZ'], ['foo', 'BAZ', 'baz'... | [
">>>",
"_get_value_indices",
"(",
"[",
"foo",
"bar",
"baz",
"]",
"[",
"foo",
"bar",
"baz",
"]",
"...",
"[",
"bar",
"foo",
"]",
")",
"[",
"1",
"0",
"]",
">>>",
"_get_value_indices",
"(",
"[",
"foo",
"bar",
"baz",
"]",
"[",
"FOO",
"bar",
"baz",
"]"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/utils.py#L213-L232 | train | Get the indices of the values in the sequence names1 and names2. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/_graphviz.py | dot2svg | def dot2svg(dot):
# type: (str) -> str
""" Render Graphviz data to SVG """
svg = graphviz.Source(dot).pipe(format='svg').decode('utf8') # type: str
# strip doctype and xml declaration
svg = svg[svg.index('<svg'):]
return svg | python | def dot2svg(dot):
# type: (str) -> str
""" Render Graphviz data to SVG """
svg = graphviz.Source(dot).pipe(format='svg').decode('utf8') # type: str
# strip doctype and xml declaration
svg = svg[svg.index('<svg'):]
return svg | [
"def",
"dot2svg",
"(",
"dot",
")",
":",
"# type: (str) -> str",
"svg",
"=",
"graphviz",
".",
"Source",
"(",
"dot",
")",
".",
"pipe",
"(",
"format",
"=",
"'svg'",
")",
".",
"decode",
"(",
"'utf8'",
")",
"# type: str",
"# strip doctype and xml declaration",
"s... | Render Graphviz data to SVG | [
"Render",
"Graphviz",
"data",
"to",
"SVG"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/_graphviz.py#L14-L20 | train | Render Graphviz data to SVG | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/explain_weights.py | explain_weights_sklearn | def explain_weights_sklearn(estimator, vec=None, top=_TOP,
target_names=None,
targets=None,
feature_names=None, coef_scale=None,
feature_re=None, feature_filter=None):
""" Return an explanation of an esti... | python | def explain_weights_sklearn(estimator, vec=None, top=_TOP,
target_names=None,
targets=None,
feature_names=None, coef_scale=None,
feature_re=None, feature_filter=None):
""" Return an explanation of an esti... | [
"def",
"explain_weights_sklearn",
"(",
"estimator",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"_TOP",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"coef_scale",
"=",
"None",
",",
"feature_re",
"=",
... | Return an explanation of an estimator | [
"Return",
"an",
"explanation",
"of",
"an",
"estimator"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_weights.py#L136-L142 | train | Return an explanation of an estimator | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/explain_weights.py | explain_linear_classifier_weights | def explain_linear_classifier_weights(clf,
vec=None,
top=_TOP,
target_names=None,
targets=None,
feature_names=None,
... | python | def explain_linear_classifier_weights(clf,
vec=None,
top=_TOP,
target_names=None,
targets=None,
feature_names=None,
... | [
"def",
"explain_linear_classifier_weights",
"(",
"clf",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"_TOP",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"coef_scale",
"=",
"None",
",",
"feature_re",
"... | Return an explanation of a linear classifier weights.
See :func:`eli5.explain_weights` for description of
``top``, ``target_names``, ``targets``, ``feature_names``,
``feature_re`` and ``feature_filter`` parameters.
``vec`` is a vectorizer instance used to transform
raw features to the input of the... | [
"Return",
"an",
"explanation",
"of",
"a",
"linear",
"classifier",
"weights",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_weights.py#L189-L261 | train | Return an explanation of a linear classifier weights. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/explain_weights.py | explain_rf_feature_importance | def explain_rf_feature_importance(estimator,
vec=None,
top=_TOP,
target_names=None, # ignored
targets=None, # ignored
feature_names=None,
... | python | def explain_rf_feature_importance(estimator,
vec=None,
top=_TOP,
target_names=None, # ignored
targets=None, # ignored
feature_names=None,
... | [
"def",
"explain_rf_feature_importance",
"(",
"estimator",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"_TOP",
",",
"target_names",
"=",
"None",
",",
"# ignored",
"targets",
"=",
"None",
",",
"# ignored",
"feature_names",
"=",
"None",
",",
"feature_re",
"=",
"N... | Return an explanation of a tree-based ensemble estimator.
See :func:`eli5.explain_weights` for description of
``top``, ``feature_names``, ``feature_re`` and ``feature_filter``
parameters.
``target_names`` and ``targets`` parameters are ignored.
``vec`` is a vectorizer instance used to transform
... | [
"Return",
"an",
"explanation",
"of",
"a",
"tree",
"-",
"based",
"ensemble",
"estimator",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_weights.py#L291-L324 | train | Return an explanation of an RF feature importance estimator. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/explain_weights.py | explain_decision_tree | def explain_decision_tree(estimator,
vec=None,
top=_TOP,
target_names=None,
targets=None, # ignored
feature_names=None,
feature_re=None,
... | python | def explain_decision_tree(estimator,
vec=None,
top=_TOP,
target_names=None,
targets=None, # ignored
feature_names=None,
feature_re=None,
... | [
"def",
"explain_decision_tree",
"(",
"estimator",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"_TOP",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"# ignored",
"feature_names",
"=",
"None",
",",
"feature_re",
"=",
"None",
",",
"feature... | Return an explanation of a decision tree.
See :func:`eli5.explain_weights` for description of
``top``, ``target_names``, ``feature_names``,
``feature_re`` and ``feature_filter`` parameters.
``targets`` parameter is ignored.
``vec`` is a vectorizer instance used to transform
raw features to th... | [
"Return",
"an",
"explanation",
"of",
"a",
"decision",
"tree",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_weights.py#L329-L377 | train | Return an explanation of a decision tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/explain_weights.py | explain_linear_regressor_weights | def explain_linear_regressor_weights(reg,
vec=None,
top=_TOP,
target_names=None,
targets=None,
feature_names=None,
... | python | def explain_linear_regressor_weights(reg,
vec=None,
top=_TOP,
target_names=None,
targets=None,
feature_names=None,
... | [
"def",
"explain_linear_regressor_weights",
"(",
"reg",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"_TOP",
",",
"target_names",
"=",
"None",
",",
"targets",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"coef_scale",
"=",
"None",
",",
"feature_re",
"=... | Return an explanation of a linear regressor weights.
See :func:`eli5.explain_weights` for description of
``top``, ``target_names``, ``targets``, ``feature_names``,
``feature_re`` and ``feature_filter`` parameters.
``vec`` is a vectorizer instance used to transform
raw features to the input of the ... | [
"Return",
"an",
"explanation",
"of",
"a",
"linear",
"regressor",
"weights",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_weights.py#L396-L467 | train | Return an explanation of a linear regressor weights. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/explain_weights.py | explain_permutation_importance | def explain_permutation_importance(estimator,
vec=None,
top=_TOP,
target_names=None, # ignored
targets=None, # ignored
feature_names=None,
... | python | def explain_permutation_importance(estimator,
vec=None,
top=_TOP,
target_names=None, # ignored
targets=None, # ignored
feature_names=None,
... | [
"def",
"explain_permutation_importance",
"(",
"estimator",
",",
"vec",
"=",
"None",
",",
"top",
"=",
"_TOP",
",",
"target_names",
"=",
"None",
",",
"# ignored",
"targets",
"=",
"None",
",",
"# ignored",
"feature_names",
"=",
"None",
",",
"feature_re",
"=",
"... | Return an explanation of PermutationImportance.
See :func:`eli5.explain_weights` for description of
``top``, ``feature_names``, ``feature_re`` and ``feature_filter``
parameters.
``target_names`` and ``targets`` parameters are ignored.
``vec`` is a vectorizer instance used to transform
raw fea... | [
"Return",
"an",
"explanation",
"of",
"PermutationImportance",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_weights.py#L485-L517 | train | Return an explanation of PermutationImportance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | _get_collisions | def _get_collisions(indices):
# type: (...) -> Dict[int, List[int]]
"""
Return a dict ``{column_id: [possible term ids]}``
with collision information.
"""
collisions = defaultdict(list) # type: Dict[int, List[int]]
for term_id, hash_id in enumerate(indices):
collisions[hash_id].appe... | python | def _get_collisions(indices):
# type: (...) -> Dict[int, List[int]]
"""
Return a dict ``{column_id: [possible term ids]}``
with collision information.
"""
collisions = defaultdict(list) # type: Dict[int, List[int]]
for term_id, hash_id in enumerate(indices):
collisions[hash_id].appe... | [
"def",
"_get_collisions",
"(",
"indices",
")",
":",
"# type: (...) -> Dict[int, List[int]]",
"collisions",
"=",
"defaultdict",
"(",
"list",
")",
"# type: Dict[int, List[int]]",
"for",
"term_id",
",",
"hash_id",
"in",
"enumerate",
"(",
"indices",
")",
":",
"collisions"... | Return a dict ``{column_id: [possible term ids]}``
with collision information. | [
"Return",
"a",
"dict",
"{",
"column_id",
":",
"[",
"possible",
"term",
"ids",
"]",
"}",
"with",
"collision",
"information",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L210-L219 | train | Returns a dict of column_id = > list of possible term ids. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | _get_indices_and_signs | def _get_indices_and_signs(hasher, terms):
"""
For each term from ``terms`` return its column index and sign,
as assigned by FeatureHasher ``hasher``.
"""
X = _transform_terms(hasher, terms)
indices = X.nonzero()[1]
signs = X.sum(axis=1).A.ravel()
return indices, signs | python | def _get_indices_and_signs(hasher, terms):
"""
For each term from ``terms`` return its column index and sign,
as assigned by FeatureHasher ``hasher``.
"""
X = _transform_terms(hasher, terms)
indices = X.nonzero()[1]
signs = X.sum(axis=1).A.ravel()
return indices, signs | [
"def",
"_get_indices_and_signs",
"(",
"hasher",
",",
"terms",
")",
":",
"X",
"=",
"_transform_terms",
"(",
"hasher",
",",
"terms",
")",
"indices",
"=",
"X",
".",
"nonzero",
"(",
")",
"[",
"1",
"]",
"signs",
"=",
"X",
".",
"sum",
"(",
"axis",
"=",
"... | For each term from ``terms`` return its column index and sign,
as assigned by FeatureHasher ``hasher``. | [
"For",
"each",
"term",
"from",
"terms",
"return",
"its",
"column",
"index",
"and",
"sign",
"as",
"assigned",
"by",
"FeatureHasher",
"hasher",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L222-L230 | train | Get the column index and sign of each term in terms. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | handle_hashing_vec | def handle_hashing_vec(vec, feature_names, coef_scale, with_coef_scale=True):
""" Return feature_names and coef_scale (if with_coef_scale is True),
calling .get_feature_names for invhashing vectorizers.
"""
needs_coef_scale = with_coef_scale and coef_scale is None
if is_invhashing(vec):
if f... | python | def handle_hashing_vec(vec, feature_names, coef_scale, with_coef_scale=True):
""" Return feature_names and coef_scale (if with_coef_scale is True),
calling .get_feature_names for invhashing vectorizers.
"""
needs_coef_scale = with_coef_scale and coef_scale is None
if is_invhashing(vec):
if f... | [
"def",
"handle_hashing_vec",
"(",
"vec",
",",
"feature_names",
",",
"coef_scale",
",",
"with_coef_scale",
"=",
"True",
")",
":",
"needs_coef_scale",
"=",
"with_coef_scale",
"and",
"coef_scale",
"is",
"None",
"if",
"is_invhashing",
"(",
"vec",
")",
":",
"if",
"... | Return feature_names and coef_scale (if with_coef_scale is True),
calling .get_feature_names for invhashing vectorizers. | [
"Return",
"feature_names",
"and",
"coef_scale",
"(",
"if",
"with_coef_scale",
"is",
"True",
")",
"calling",
".",
"get_feature_names",
"for",
"invhashing",
"vectorizers",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L248-L266 | train | Return feature_names and coef_scale for invhashing vectorizers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | invert_hashing_and_fit | def invert_hashing_and_fit(
vec, # type: Union[FeatureUnion, HashingVectorizer]
docs
):
# type: (...) -> Union[FeatureUnion, InvertableHashingVectorizer]
""" Create an :class:`~.InvertableHashingVectorizer` from hashing
vectorizer vec and fit it on docs. If vec is a FeatureUnion, do it ... | python | def invert_hashing_and_fit(
vec, # type: Union[FeatureUnion, HashingVectorizer]
docs
):
# type: (...) -> Union[FeatureUnion, InvertableHashingVectorizer]
""" Create an :class:`~.InvertableHashingVectorizer` from hashing
vectorizer vec and fit it on docs. If vec is a FeatureUnion, do it ... | [
"def",
"invert_hashing_and_fit",
"(",
"vec",
",",
"# type: Union[FeatureUnion, HashingVectorizer]",
"docs",
")",
":",
"# type: (...) -> Union[FeatureUnion, InvertableHashingVectorizer]",
"if",
"isinstance",
"(",
"vec",
",",
"HashingVectorizer",
")",
":",
"vec",
"=",
"Invertab... | Create an :class:`~.InvertableHashingVectorizer` from hashing
vectorizer vec and fit it on docs. If vec is a FeatureUnion, do it for all
hashing vectorizers in the union.
Return an :class:`~.InvertableHashingVectorizer`, or a FeatureUnion,
or an unchanged vectorizer. | [
"Create",
"an",
":",
"class",
":",
"~",
".",
"InvertableHashingVectorizer",
"from",
"hashing",
"vectorizer",
"vec",
"and",
"fit",
"it",
"on",
"docs",
".",
"If",
"vec",
"is",
"a",
"FeatureUnion",
"do",
"it",
"for",
"all",
"hashing",
"vectorizers",
"in",
"th... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L305-L323 | train | Invert the given vectorizer vec on the given docs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | _fit_invhashing_union | def _fit_invhashing_union(vec_union, docs):
# type: (FeatureUnion, Any) -> FeatureUnion
""" Fit InvertableHashingVectorizer on doc inside a FeatureUnion.
"""
return FeatureUnion(
[(name, invert_hashing_and_fit(v, docs))
for name, v in vec_union.transformer_list],
transformer_wei... | python | def _fit_invhashing_union(vec_union, docs):
# type: (FeatureUnion, Any) -> FeatureUnion
""" Fit InvertableHashingVectorizer on doc inside a FeatureUnion.
"""
return FeatureUnion(
[(name, invert_hashing_and_fit(v, docs))
for name, v in vec_union.transformer_list],
transformer_wei... | [
"def",
"_fit_invhashing_union",
"(",
"vec_union",
",",
"docs",
")",
":",
"# type: (FeatureUnion, Any) -> FeatureUnion",
"return",
"FeatureUnion",
"(",
"[",
"(",
"name",
",",
"invert_hashing_and_fit",
"(",
"v",
",",
"docs",
")",
")",
"for",
"name",
",",
"v",
"in"... | Fit InvertableHashingVectorizer on doc inside a FeatureUnion. | [
"Fit",
"InvertableHashingVectorizer",
"on",
"doc",
"inside",
"a",
"FeatureUnion",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L326-L334 | train | Fit InvertableHashingVectorizer on a list of docs inside a FeatureUnion. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | InvertableHashingVectorizer.fit | def fit(self, X, y=None):
""" Extract possible terms from documents """
self.unhasher.fit(self._get_terms_iter(X))
return self | python | def fit(self, X, y=None):
""" Extract possible terms from documents """
self.unhasher.fit(self._get_terms_iter(X))
return self | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"self",
".",
"unhasher",
".",
"fit",
"(",
"self",
".",
"_get_terms_iter",
"(",
"X",
")",
")",
"return",
"self"
] | Extract possible terms from documents | [
"Extract",
"possible",
"terms",
"from",
"documents"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L55-L58 | train | Fits the unhasher to the set of possible terms. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | InvertableHashingVectorizer.get_feature_names | def get_feature_names(self, always_signed=True):
# type: (bool) -> FeatureNames
"""
Return feature names.
This is a best-effort function which tries to reconstruct feature
names based on what it has seen so far.
HashingVectorizer uses a signed hash function. If always_si... | python | def get_feature_names(self, always_signed=True):
# type: (bool) -> FeatureNames
"""
Return feature names.
This is a best-effort function which tries to reconstruct feature
names based on what it has seen so far.
HashingVectorizer uses a signed hash function. If always_si... | [
"def",
"get_feature_names",
"(",
"self",
",",
"always_signed",
"=",
"True",
")",
":",
"# type: (bool) -> FeatureNames",
"return",
"self",
".",
"unhasher",
".",
"get_feature_names",
"(",
"always_signed",
"=",
"always_signed",
",",
"always_positive",
"=",
"self",
".",... | Return feature names.
This is a best-effort function which tries to reconstruct feature
names based on what it has seen so far.
HashingVectorizer uses a signed hash function. If always_signed is True,
each term in feature names is prepended with its sign. If it is False,
signs a... | [
"Return",
"feature",
"names",
".",
"This",
"is",
"a",
"best",
"-",
"effort",
"function",
"which",
"tries",
"to",
"reconstruct",
"feature",
"names",
"based",
"on",
"what",
"it",
"has",
"seen",
"so",
"far",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L67-L85 | train | Returns a list of feature names for the current class entry. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | InvertableHashingVectorizer.column_signs_ | def column_signs_(self):
"""
Return a numpy array with expected signs of features.
Values are
* +1 when all known terms which map to the column have positive sign;
* -1 when all known terms which map to the column have negative sign;
* ``nan`` when there are both positiv... | python | def column_signs_(self):
"""
Return a numpy array with expected signs of features.
Values are
* +1 when all known terms which map to the column have positive sign;
* -1 when all known terms which map to the column have negative sign;
* ``nan`` when there are both positiv... | [
"def",
"column_signs_",
"(",
"self",
")",
":",
"if",
"self",
".",
"_always_positive",
"(",
")",
":",
"return",
"np",
".",
"ones",
"(",
"self",
".",
"n_features",
")",
"self",
".",
"unhasher",
".",
"recalculate_attributes",
"(",
")",
"return",
"self",
"."... | Return a numpy array with expected signs of features.
Values are
* +1 when all known terms which map to the column have positive sign;
* -1 when all known terms which map to the column have negative sign;
* ``nan`` when there are both positive and negative known terms
for this... | [
"Return",
"a",
"numpy",
"array",
"with",
"expected",
"signs",
"of",
"features",
".",
"Values",
"are"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L92-L106 | train | Return a numpy array with expected signs of features. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/unhashing.py | FeatureUnhasher.recalculate_attributes | def recalculate_attributes(self, force=False):
# type: (bool) -> None
"""
Update all computed attributes. It is only needed if you need to access
computed attributes after :meth:`patrial_fit` was called.
"""
if not self._attributes_dirty and not force:
return
... | python | def recalculate_attributes(self, force=False):
# type: (bool) -> None
"""
Update all computed attributes. It is only needed if you need to access
computed attributes after :meth:`patrial_fit` was called.
"""
if not self._attributes_dirty and not force:
return
... | [
"def",
"recalculate_attributes",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"# type: (bool) -> None",
"if",
"not",
"self",
".",
"_attributes_dirty",
"and",
"not",
"force",
":",
"return",
"terms",
"=",
"[",
"term",
"for",
"term",
",",
"_",
"in",
"se... | Update all computed attributes. It is only needed if you need to access
computed attributes after :meth:`patrial_fit` was called. | [
"Update",
"all",
"computed",
"attributes",
".",
"It",
"is",
"only",
"needed",
"if",
"you",
"need",
"to",
"access",
"computed",
"attributes",
"after",
":",
"meth",
":",
"patrial_fit",
"was",
"called",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/unhashing.py#L166-L188 | train | Recalculate all computed attributes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/trees.py | tree2text | def tree2text(tree_obj, indent=4):
# type: (TreeInfo, int) -> str
"""
Return text representation of a decision tree.
"""
parts = []
def _format_node(node, depth=0):
# type: (NodeInfo, int) -> None
def p(*args):
# type: (*str) -> None
parts.append(" " * de... | python | def tree2text(tree_obj, indent=4):
# type: (TreeInfo, int) -> str
"""
Return text representation of a decision tree.
"""
parts = []
def _format_node(node, depth=0):
# type: (NodeInfo, int) -> None
def p(*args):
# type: (*str) -> None
parts.append(" " * de... | [
"def",
"tree2text",
"(",
"tree_obj",
",",
"indent",
"=",
"4",
")",
":",
"# type: (TreeInfo, int) -> str",
"parts",
"=",
"[",
"]",
"def",
"_format_node",
"(",
"node",
",",
"depth",
"=",
"0",
")",
":",
"# type: (NodeInfo, int) -> None",
"def",
"p",
"(",
"*",
... | Return text representation of a decision tree. | [
"Return",
"text",
"representation",
"of",
"a",
"decision",
"tree",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/trees.py#L7-L49 | train | Return text representation of a decision tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/trees.py | _format_array | def _format_array(x, fmt):
# type: (Any, str) -> str
"""
>>> _format_array([0, 1.0], "{:0.3f}")
'[0.000, 1.000]'
"""
value_repr = ", ".join(fmt.format(v) for v in x)
return "[{}]".format(value_repr) | python | def _format_array(x, fmt):
# type: (Any, str) -> str
"""
>>> _format_array([0, 1.0], "{:0.3f}")
'[0.000, 1.000]'
"""
value_repr = ", ".join(fmt.format(v) for v in x)
return "[{}]".format(value_repr) | [
"def",
"_format_array",
"(",
"x",
",",
"fmt",
")",
":",
"# type: (Any, str) -> str",
"value_repr",
"=",
"\", \"",
".",
"join",
"(",
"fmt",
".",
"format",
"(",
"v",
")",
"for",
"v",
"in",
"x",
")",
"return",
"\"[{}]\"",
".",
"format",
"(",
"value_repr",
... | >>> _format_array([0, 1.0], "{:0.3f}")
'[0.000, 1.000]' | [
">>>",
"_format_array",
"(",
"[",
"0",
"1",
".",
"0",
"]",
"{",
":",
"0",
".",
"3f",
"}",
")",
"[",
"0",
".",
"000",
"1",
".",
"000",
"]"
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/trees.py#L68-L75 | train | Format an array of values. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dataframe.py | explain_weights_df | def explain_weights_df(estimator, **kwargs):
# type: (...) -> pd.DataFrame
""" Explain weights and export them to ``pandas.DataFrame``.
All keyword arguments are passed to :func:`eli5.explain_weights`.
Weights of all features are exported by default.
"""
kwargs = _set_defaults(kwargs)
return... | python | def explain_weights_df(estimator, **kwargs):
# type: (...) -> pd.DataFrame
""" Explain weights and export them to ``pandas.DataFrame``.
All keyword arguments are passed to :func:`eli5.explain_weights`.
Weights of all features are exported by default.
"""
kwargs = _set_defaults(kwargs)
return... | [
"def",
"explain_weights_df",
"(",
"estimator",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> pd.DataFrame",
"kwargs",
"=",
"_set_defaults",
"(",
"kwargs",
")",
"return",
"format_as_dataframe",
"(",
"eli5",
".",
"explain_weights",
"(",
"estimator",
",",
"*",... | Explain weights and export them to ``pandas.DataFrame``.
All keyword arguments are passed to :func:`eli5.explain_weights`.
Weights of all features are exported by default. | [
"Explain",
"weights",
"and",
"export",
"them",
"to",
"pandas",
".",
"DataFrame",
".",
"All",
"keyword",
"arguments",
"are",
"passed",
"to",
":",
"func",
":",
"eli5",
".",
"explain_weights",
".",
"Weights",
"of",
"all",
"features",
"are",
"exported",
"by",
... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L15-L23 | train | Explain weights and export them to pandas. DataFrame. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dataframe.py | explain_weights_dfs | def explain_weights_dfs(estimator, **kwargs):
# type: (...) -> Dict[str, pd.DataFrame]
""" Explain weights and export them to a dict with ``pandas.DataFrame``
values (as :func:`eli5.formatters.as_dataframe.format_as_dataframes` does).
All keyword arguments are passed to :func:`eli5.explain_weights`.
... | python | def explain_weights_dfs(estimator, **kwargs):
# type: (...) -> Dict[str, pd.DataFrame]
""" Explain weights and export them to a dict with ``pandas.DataFrame``
values (as :func:`eli5.formatters.as_dataframe.format_as_dataframes` does).
All keyword arguments are passed to :func:`eli5.explain_weights`.
... | [
"def",
"explain_weights_dfs",
"(",
"estimator",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Dict[str, pd.DataFrame]",
"kwargs",
"=",
"_set_defaults",
"(",
"kwargs",
")",
"return",
"format_as_dataframes",
"(",
"eli5",
".",
"explain_weights",
"(",
"estimator",
... | Explain weights and export them to a dict with ``pandas.DataFrame``
values (as :func:`eli5.formatters.as_dataframe.format_as_dataframes` does).
All keyword arguments are passed to :func:`eli5.explain_weights`.
Weights of all features are exported by default. | [
"Explain",
"weights",
"and",
"export",
"them",
"to",
"a",
"dict",
"with",
"pandas",
".",
"DataFrame",
"values",
"(",
"as",
":",
"func",
":",
"eli5",
".",
"formatters",
".",
"as_dataframe",
".",
"format_as_dataframes",
"does",
")",
".",
"All",
"keyword",
"a... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L26-L35 | train | Explain weights and export them to a dict with pandas. DataFrame. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dataframe.py | explain_prediction_df | def explain_prediction_df(estimator, doc, **kwargs):
# type: (...) -> pd.DataFrame
""" Explain prediction and export explanation to ``pandas.DataFrame``
All keyword arguments are passed to :func:`eli5.explain_prediction`.
Weights of all features are exported by default.
"""
kwargs = _set_default... | python | def explain_prediction_df(estimator, doc, **kwargs):
# type: (...) -> pd.DataFrame
""" Explain prediction and export explanation to ``pandas.DataFrame``
All keyword arguments are passed to :func:`eli5.explain_prediction`.
Weights of all features are exported by default.
"""
kwargs = _set_default... | [
"def",
"explain_prediction_df",
"(",
"estimator",
",",
"doc",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> pd.DataFrame",
"kwargs",
"=",
"_set_defaults",
"(",
"kwargs",
")",
"return",
"format_as_dataframe",
"(",
"eli5",
".",
"explain_prediction",
"(",
"est... | Explain prediction and export explanation to ``pandas.DataFrame``
All keyword arguments are passed to :func:`eli5.explain_prediction`.
Weights of all features are exported by default. | [
"Explain",
"prediction",
"and",
"export",
"explanation",
"to",
"pandas",
".",
"DataFrame",
"All",
"keyword",
"arguments",
"are",
"passed",
"to",
":",
"func",
":",
"eli5",
".",
"explain_prediction",
".",
"Weights",
"of",
"all",
"features",
"are",
"exported",
"b... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L38-L46 | train | Explain prediction and export explanation to pandas. DataFrame | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dataframe.py | explain_prediction_dfs | def explain_prediction_dfs(estimator, doc, **kwargs):
# type: (...) -> Dict[str, pd.DataFrame]
""" Explain prediction and export explanation
to a dict with ``pandas.DataFrame`` values
(as :func:`eli5.formatters.as_dataframe.format_as_dataframes` does).
All keyword arguments are passed to :func:`eli5... | python | def explain_prediction_dfs(estimator, doc, **kwargs):
# type: (...) -> Dict[str, pd.DataFrame]
""" Explain prediction and export explanation
to a dict with ``pandas.DataFrame`` values
(as :func:`eli5.formatters.as_dataframe.format_as_dataframes` does).
All keyword arguments are passed to :func:`eli5... | [
"def",
"explain_prediction_dfs",
"(",
"estimator",
",",
"doc",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Dict[str, pd.DataFrame]",
"kwargs",
"=",
"_set_defaults",
"(",
"kwargs",
")",
"return",
"format_as_dataframes",
"(",
"eli5",
".",
"explain_prediction",
... | Explain prediction and export explanation
to a dict with ``pandas.DataFrame`` values
(as :func:`eli5.formatters.as_dataframe.format_as_dataframes` does).
All keyword arguments are passed to :func:`eli5.explain_prediction`.
Weights of all features are exported by default. | [
"Explain",
"prediction",
"and",
"export",
"explanation",
"to",
"a",
"dict",
"with",
"pandas",
".",
"DataFrame",
"values",
"(",
"as",
":",
"func",
":",
"eli5",
".",
"formatters",
".",
"as_dataframe",
".",
"format_as_dataframes",
"does",
")",
".",
"All",
"keyw... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L49-L59 | train | Explain prediction and export explanation
to a dict with pandas. DataFrame values. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dataframe.py | format_as_dataframes | def format_as_dataframes(explanation):
# type: (Explanation) -> Dict[str, pd.DataFrame]
""" Export an explanation to a dictionary with ``pandas.DataFrame`` values
and string keys that correspond to explanation attributes.
Use this method if several dataframes can be exported from a single
explanatio... | python | def format_as_dataframes(explanation):
# type: (Explanation) -> Dict[str, pd.DataFrame]
""" Export an explanation to a dictionary with ``pandas.DataFrame`` values
and string keys that correspond to explanation attributes.
Use this method if several dataframes can be exported from a single
explanatio... | [
"def",
"format_as_dataframes",
"(",
"explanation",
")",
":",
"# type: (Explanation) -> Dict[str, pd.DataFrame]",
"result",
"=",
"{",
"}",
"for",
"attr",
"in",
"_EXPORTED_ATTRIBUTES",
":",
"value",
"=",
"getattr",
"(",
"explanation",
",",
"attr",
")",
"if",
"value",
... | Export an explanation to a dictionary with ``pandas.DataFrame`` values
and string keys that correspond to explanation attributes.
Use this method if several dataframes can be exported from a single
explanation (e.g. for CRF explanation with has both feature weights
and transition matrix).
Note that ... | [
"Export",
"an",
"explanation",
"to",
"a",
"dictionary",
"with",
"pandas",
".",
"DataFrame",
"values",
"and",
"string",
"keys",
"that",
"correspond",
"to",
"explanation",
"attributes",
".",
"Use",
"this",
"method",
"if",
"several",
"dataframes",
"can",
"be",
"e... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L72-L89 | train | Export an explanation to a dictionary with pandas. DataFrame values that correspond to the attributes of the explanation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/formatters/as_dataframe.py | format_as_dataframe | def format_as_dataframe(explanation):
# type: (Explanation) -> Optional[pd.DataFrame]
""" Export an explanation to a single ``pandas.DataFrame``.
In case several dataframes could be exported by
:func:`eli5.formatters.as_dataframe.format_as_dataframes`,
a warning is raised. If no dataframe can be exp... | python | def format_as_dataframe(explanation):
# type: (Explanation) -> Optional[pd.DataFrame]
""" Export an explanation to a single ``pandas.DataFrame``.
In case several dataframes could be exported by
:func:`eli5.formatters.as_dataframe.format_as_dataframes`,
a warning is raised. If no dataframe can be exp... | [
"def",
"format_as_dataframe",
"(",
"explanation",
")",
":",
"# type: (Explanation) -> Optional[pd.DataFrame]",
"for",
"attr",
"in",
"_EXPORTED_ATTRIBUTES",
":",
"value",
"=",
"getattr",
"(",
"explanation",
",",
"attr",
")",
"if",
"value",
":",
"other_attrs",
"=",
"[... | Export an explanation to a single ``pandas.DataFrame``.
In case several dataframes could be exported by
:func:`eli5.formatters.as_dataframe.format_as_dataframes`,
a warning is raised. If no dataframe can be exported, ``None`` is returned.
This function also accepts some components of the explanation as ... | [
"Export",
"an",
"explanation",
"to",
"a",
"single",
"pandas",
".",
"DataFrame",
".",
"In",
"case",
"several",
"dataframes",
"could",
"be",
"exported",
"by",
":",
"func",
":",
"eli5",
".",
"formatters",
".",
"as_dataframe",
".",
"format_as_dataframes",
"a",
"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L93-L116 | train | Exports an explanation to a single pandas. DataFrame. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/permutation_importance.py | iter_shuffled | def iter_shuffled(X, columns_to_shuffle=None, pre_shuffle=False,
random_state=None):
"""
Return an iterator of X matrices which have one or more columns shuffled.
After each iteration yielded matrix is mutated inplace, so
if you want to use multiple of them at the same time, make copie... | python | def iter_shuffled(X, columns_to_shuffle=None, pre_shuffle=False,
random_state=None):
"""
Return an iterator of X matrices which have one or more columns shuffled.
After each iteration yielded matrix is mutated inplace, so
if you want to use multiple of them at the same time, make copie... | [
"def",
"iter_shuffled",
"(",
"X",
",",
"columns_to_shuffle",
"=",
"None",
",",
"pre_shuffle",
"=",
"False",
",",
"random_state",
"=",
"None",
")",
":",
"rng",
"=",
"check_random_state",
"(",
"random_state",
")",
"if",
"columns_to_shuffle",
"is",
"None",
":",
... | Return an iterator of X matrices which have one or more columns shuffled.
After each iteration yielded matrix is mutated inplace, so
if you want to use multiple of them at the same time, make copies.
``columns_to_shuffle`` is a sequence of column numbers to shuffle.
By default, all columns are shuffled... | [
"Return",
"an",
"iterator",
"of",
"X",
"matrices",
"which",
"have",
"one",
"or",
"more",
"columns",
"shuffled",
".",
"After",
"each",
"iteration",
"yielded",
"matrix",
"is",
"mutated",
"inplace",
"so",
"if",
"you",
"want",
"to",
"use",
"multiple",
"of",
"t... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/permutation_importance.py#L20-L52 | train | Yields the matrix X with one or more columns shuffled. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/permutation_importance.py | get_score_importances | def get_score_importances(
score_func, # type: Callable[[Any, Any], float]
X,
y,
n_iter=5, # type: int
columns_to_shuffle=None,
random_state=None
):
# type: (...) -> Tuple[float, List[np.ndarray]]
"""
Return ``(base_score, score_decreases)`` tuple with t... | python | def get_score_importances(
score_func, # type: Callable[[Any, Any], float]
X,
y,
n_iter=5, # type: int
columns_to_shuffle=None,
random_state=None
):
# type: (...) -> Tuple[float, List[np.ndarray]]
"""
Return ``(base_score, score_decreases)`` tuple with t... | [
"def",
"get_score_importances",
"(",
"score_func",
",",
"# type: Callable[[Any, Any], float]",
"X",
",",
"y",
",",
"n_iter",
"=",
"5",
",",
"# type: int",
"columns_to_shuffle",
"=",
"None",
",",
"random_state",
"=",
"None",
")",
":",
"# type: (...) -> Tuple[float, Lis... | Return ``(base_score, score_decreases)`` tuple with the base score and
score decreases when a feature is not available.
``base_score`` is ``score_func(X, y)``; ``score_decreases``
is a list of length ``n_iter`` with feature importance arrays
(each array is of shape ``n_features``); feature importances ... | [
"Return",
"(",
"base_score",
"score_decreases",
")",
"tuple",
"with",
"the",
"base",
"score",
"and",
"score",
"decreases",
"when",
"a",
"feature",
"is",
"not",
"available",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/permutation_importance.py#L55-L94 | train | Basic algorithm for calculating the score of the set of features in the current language. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/ipython.py | show_weights | def show_weights(estimator, **kwargs):
""" Return an explanation of estimator parameters (weights)
as an IPython.display.HTML object. Use this function
to show classifier weights in IPython.
:func:`show_weights` accepts all
:func:`eli5.explain_weights` arguments and all
:func:`eli5.formatters.h... | python | def show_weights(estimator, **kwargs):
""" Return an explanation of estimator parameters (weights)
as an IPython.display.HTML object. Use this function
to show classifier weights in IPython.
:func:`show_weights` accepts all
:func:`eli5.explain_weights` arguments and all
:func:`eli5.formatters.h... | [
"def",
"show_weights",
"(",
"estimator",
",",
"*",
"*",
"kwargs",
")",
":",
"format_kwargs",
",",
"explain_kwargs",
"=",
"_split_kwargs",
"(",
"kwargs",
")",
"expl",
"=",
"explain_weights",
"(",
"estimator",
",",
"*",
"*",
"explain_kwargs",
")",
"html",
"=",... | Return an explanation of estimator parameters (weights)
as an IPython.display.HTML object. Use this function
to show classifier weights in IPython.
:func:`show_weights` accepts all
:func:`eli5.explain_weights` arguments and all
:func:`eli5.formatters.html.format_as_html`
keyword arguments, so i... | [
"Return",
"an",
"explanation",
"of",
"estimator",
"parameters",
"(",
"weights",
")",
"as",
"an",
"IPython",
".",
"display",
".",
"HTML",
"object",
".",
"Use",
"this",
"function",
"to",
"show",
"classifier",
"weights",
"in",
"IPython",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/ipython.py#L17-L121 | train | Return an explanation of the classifier weights in an IPython. display. HTML object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/ipython.py | show_prediction | def show_prediction(estimator, doc, **kwargs):
""" Return an explanation of estimator prediction
as an IPython.display.HTML object. Use this function
to show information about classifier prediction in IPython.
:func:`show_prediction` accepts all
:func:`eli5.explain_prediction` arguments and all
... | python | def show_prediction(estimator, doc, **kwargs):
""" Return an explanation of estimator prediction
as an IPython.display.HTML object. Use this function
to show information about classifier prediction in IPython.
:func:`show_prediction` accepts all
:func:`eli5.explain_prediction` arguments and all
... | [
"def",
"show_prediction",
"(",
"estimator",
",",
"doc",
",",
"*",
"*",
"kwargs",
")",
":",
"format_kwargs",
",",
"explain_kwargs",
"=",
"_split_kwargs",
"(",
"kwargs",
")",
"expl",
"=",
"explain_prediction",
"(",
"estimator",
",",
"doc",
",",
"*",
"*",
"ex... | Return an explanation of estimator prediction
as an IPython.display.HTML object. Use this function
to show information about classifier prediction in IPython.
:func:`show_prediction` accepts all
:func:`eli5.explain_prediction` arguments and all
:func:`eli5.formatters.html.format_as_html`
keywor... | [
"Return",
"an",
"explanation",
"of",
"estimator",
"prediction",
"as",
"an",
"IPython",
".",
"display",
".",
"HTML",
"object",
".",
"Use",
"this",
"function",
"to",
"show",
"information",
"about",
"classifier",
"prediction",
"in",
"IPython",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/ipython.py#L124-L272 | train | Return an explanation of estimator prediction as an IPython. display. HTML object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/treeinspect.py | get_tree_info | def get_tree_info(decision_tree,
feature_names=None,
**export_graphviz_kwargs):
# type: (...) -> TreeInfo
"""
Convert DecisionTreeClassifier or DecisionTreeRegressor
to an inspectable object.
"""
return TreeInfo(
criterion=decision_tree.criterion,
... | python | def get_tree_info(decision_tree,
feature_names=None,
**export_graphviz_kwargs):
# type: (...) -> TreeInfo
"""
Convert DecisionTreeClassifier or DecisionTreeRegressor
to an inspectable object.
"""
return TreeInfo(
criterion=decision_tree.criterion,
... | [
"def",
"get_tree_info",
"(",
"decision_tree",
",",
"feature_names",
"=",
"None",
",",
"*",
"*",
"export_graphviz_kwargs",
")",
":",
"# type: (...) -> TreeInfo",
"return",
"TreeInfo",
"(",
"criterion",
"=",
"decision_tree",
".",
"criterion",
",",
"tree",
"=",
"_get... | Convert DecisionTreeClassifier or DecisionTreeRegressor
to an inspectable object. | [
"Convert",
"DecisionTreeClassifier",
"or",
"DecisionTreeRegressor",
"to",
"an",
"inspectable",
"object",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/treeinspect.py#L16-L31 | train | Converts DecisionTreeClassifier or DecisionTreeRegressor
to an inspectable object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/textutils.py | generate_samples | def generate_samples(text, # type: TokenizedText
n_samples=500, # type: int
bow=True, # type: bool
random_state=None,
replacement='', # type: str
min_replace=1, # type: Uni... | python | def generate_samples(text, # type: TokenizedText
n_samples=500, # type: int
bow=True, # type: bool
random_state=None,
replacement='', # type: str
min_replace=1, # type: Uni... | [
"def",
"generate_samples",
"(",
"text",
",",
"# type: TokenizedText",
"n_samples",
"=",
"500",
",",
"# type: int",
"bow",
"=",
"True",
",",
"# type: bool",
"random_state",
"=",
"None",
",",
"replacement",
"=",
"''",
",",
"# type: str",
"min_replace",
"=",
"1",
... | Return ``n_samples`` changed versions of text (with some words removed),
along with distances between the original text and a generated
examples. If ``bow=False``, all tokens are considered unique
(i.e. token position matters). | [
"Return",
"n_samples",
"changed",
"versions",
"of",
"text",
"(",
"with",
"some",
"words",
"removed",
")",
"along",
"with",
"distances",
"between",
"the",
"original",
"text",
"and",
"a",
"generated",
"examples",
".",
"If",
"bow",
"=",
"False",
"all",
"tokens"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/textutils.py#L23-L55 | train | Generates n_samples changed versions of text and a generated
. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/textutils.py | cosine_similarity_vec | def cosine_similarity_vec(num_tokens, num_removed_vec):
"""
Return cosine similarity between a binary vector with all ones
of length ``num_tokens`` and vectors of the same length with
``num_removed_vec`` elements set to zero.
"""
remaining = -np.array(num_removed_vec) + num_tokens
return rem... | python | def cosine_similarity_vec(num_tokens, num_removed_vec):
"""
Return cosine similarity between a binary vector with all ones
of length ``num_tokens`` and vectors of the same length with
``num_removed_vec`` elements set to zero.
"""
remaining = -np.array(num_removed_vec) + num_tokens
return rem... | [
"def",
"cosine_similarity_vec",
"(",
"num_tokens",
",",
"num_removed_vec",
")",
":",
"remaining",
"=",
"-",
"np",
".",
"array",
"(",
"num_removed_vec",
")",
"+",
"num_tokens",
"return",
"remaining",
"/",
"(",
"np",
".",
"sqrt",
"(",
"num_tokens",
"+",
"1e-6"... | Return cosine similarity between a binary vector with all ones
of length ``num_tokens`` and vectors of the same length with
``num_removed_vec`` elements set to zero. | [
"Return",
"cosine",
"similarity",
"between",
"a",
"binary",
"vector",
"with",
"all",
"ones",
"of",
"length",
"num_tokens",
"and",
"vectors",
"of",
"the",
"same",
"length",
"with",
"num_removed_vec",
"elements",
"set",
"to",
"zero",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/textutils.py#L58-L65 | train | Return cosine similarity between a binary vector with all ones
of length num_tokens and vectors of the same length with num_removed_vec elements set to zero. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/textutils.py | TokenizedText.replace_random_tokens | def replace_random_tokens(self,
n_samples, # type: int
replacement='', # type: str
random_state=None,
min_replace=1, # type: Union[int, float]
max_replace=1.0, # type... | python | def replace_random_tokens(self,
n_samples, # type: int
replacement='', # type: str
random_state=None,
min_replace=1, # type: Union[int, float]
max_replace=1.0, # type... | [
"def",
"replace_random_tokens",
"(",
"self",
",",
"n_samples",
",",
"# type: int",
"replacement",
"=",
"''",
",",
"# type: str",
"random_state",
"=",
"None",
",",
"min_replace",
"=",
"1",
",",
"# type: Union[int, float]",
"max_replace",
"=",
"1.0",
",",
"# type: U... | Return a list of ``(text, replaced_count, mask)``
tuples with n_samples versions of text with some words replaced.
By default words are replaced with '', i.e. removed. | [
"Return",
"a",
"list",
"of",
"(",
"text",
"replaced_count",
"mask",
")",
"tuples",
"with",
"n_samples",
"versions",
"of",
"text",
"with",
"some",
"words",
"replaced",
".",
"By",
"default",
"words",
"are",
"replaced",
"with",
"i",
".",
"e",
".",
"removed",
... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/textutils.py#L75-L110 | train | Return a list of tuples with n_samples versions of text with some words replaced with a random number of replacement words. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/textutils.py | TokenizedText.replace_random_tokens_bow | def replace_random_tokens_bow(self,
n_samples, # type: int
replacement='', # type: str
random_state=None,
min_replace=1, # type: Union[int, float]
... | python | def replace_random_tokens_bow(self,
n_samples, # type: int
replacement='', # type: str
random_state=None,
min_replace=1, # type: Union[int, float]
... | [
"def",
"replace_random_tokens_bow",
"(",
"self",
",",
"n_samples",
",",
"# type: int",
"replacement",
"=",
"''",
",",
"# type: str",
"random_state",
"=",
"None",
",",
"min_replace",
"=",
"1",
",",
"# type: Union[int, float]",
"max_replace",
"=",
"1.0",
",",
"# typ... | Return a list of ``(text, replaced_words_count, mask)`` tuples with
n_samples versions of text with some words replaced.
If a word is replaced, all duplicate words are also replaced
from the text. By default words are replaced with '', i.e. removed. | [
"Return",
"a",
"list",
"of",
"(",
"text",
"replaced_words_count",
"mask",
")",
"tuples",
"with",
"n_samples",
"versions",
"of",
"text",
"with",
"some",
"words",
"replaced",
".",
"If",
"a",
"word",
"is",
"replaced",
"all",
"duplicate",
"words",
"are",
"also",... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/textutils.py#L112-L144 | train | Replaces random tokens in the vocabulary with some words replaced. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/lime.py | TextExplainer.fit | def fit(self,
doc, # type: str
predict_proba, # type: Callable[[Any], Any]
):
# type: (...) -> TextExplainer
"""
Explain ``predict_proba`` probabilistic classification function
for the ``doc`` example. This method fits a local classificat... | python | def fit(self,
doc, # type: str
predict_proba, # type: Callable[[Any], Any]
):
# type: (...) -> TextExplainer
"""
Explain ``predict_proba`` probabilistic classification function
for the ``doc`` example. This method fits a local classificat... | [
"def",
"fit",
"(",
"self",
",",
"doc",
",",
"# type: str",
"predict_proba",
",",
"# type: Callable[[Any], Any]",
")",
":",
"# type: (...) -> TextExplainer",
"self",
".",
"doc_",
"=",
"doc",
"if",
"self",
".",
"position_dependent",
":",
"samples",
",",
"sims",
",... | Explain ``predict_proba`` probabilistic classification function
for the ``doc`` example. This method fits a local classification
pipeline following LIME approach.
To get the explanation use :meth:`show_prediction`,
:meth:`show_weights`, :meth:`explain_prediction` or
:meth:`expla... | [
"Explain",
"predict_proba",
"probabilistic",
"classification",
"function",
"for",
"the",
"doc",
"example",
".",
"This",
"method",
"fits",
"a",
"local",
"classification",
"pipeline",
"following",
"LIME",
"approach",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/lime.py#L206-L267 | train | Fits the local classification pipeline to get the explanation of the given doc. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/lime.py | TextExplainer.show_prediction | def show_prediction(self, **kwargs):
"""
Call :func:`eli5.show_prediction` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_prediction`.
:func:`fit` must be called before using this method.
"""
self._fix_target_names(k... | python | def show_prediction(self, **kwargs):
"""
Call :func:`eli5.show_prediction` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_prediction`.
:func:`fit` must be called before using this method.
"""
self._fix_target_names(k... | [
"def",
"show_prediction",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_fix_target_names",
"(",
"kwargs",
")",
"return",
"eli5",
".",
"show_prediction",
"(",
"self",
".",
"clf_",
",",
"self",
".",
"doc_",
",",
"vec",
"=",
"self",
".",
... | Call :func:`eli5.show_prediction` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_prediction`.
:func:`fit` must be called before using this method. | [
"Call",
":",
"func",
":",
"eli5",
".",
"show_prediction",
"for",
"the",
"locally",
"-",
"fit",
"classification",
"pipeline",
".",
"Keyword",
"arguments",
"are",
"passed",
"to",
":",
"func",
":",
"eli5",
".",
"show_prediction",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/lime.py#L269-L279 | train | Call eli5. show_prediction for the locally - fit
classification pipeline. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/lime.py | TextExplainer.show_weights | def show_weights(self, **kwargs):
"""
Call :func:`eli5.show_weights` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_weights`.
:func:`fit` must be called before using this method.
"""
self._fix_target_names(kwargs)
... | python | def show_weights(self, **kwargs):
"""
Call :func:`eli5.show_weights` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_weights`.
:func:`fit` must be called before using this method.
"""
self._fix_target_names(kwargs)
... | [
"def",
"show_weights",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_fix_target_names",
"(",
"kwargs",
")",
"return",
"eli5",
".",
"show_weights",
"(",
"self",
".",
"clf_",
",",
"vec",
"=",
"self",
".",
"vec_",
",",
"*",
"*",
"kwargs... | Call :func:`eli5.show_weights` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_weights`.
:func:`fit` must be called before using this method. | [
"Call",
":",
"func",
":",
"eli5",
".",
"show_weights",
"for",
"the",
"locally",
"-",
"fit",
"classification",
"pipeline",
".",
"Keyword",
"arguments",
"are",
"passed",
"to",
":",
"func",
":",
"eli5",
".",
"show_weights",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/lime.py#L293-L302 | train | Call eli5. show_weights for the locally - fit
classification pipeline. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/lime.py | TextExplainer.explain_weights | def explain_weights(self, **kwargs):
"""
Call :func:`eli5.show_weights` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_weights`.
:func:`fit` must be called before using this method.
"""
self._fix_target_names(kwargs)... | python | def explain_weights(self, **kwargs):
"""
Call :func:`eli5.show_weights` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_weights`.
:func:`fit` must be called before using this method.
"""
self._fix_target_names(kwargs)... | [
"def",
"explain_weights",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_fix_target_names",
"(",
"kwargs",
")",
"return",
"eli5",
".",
"explain_weights",
"(",
"self",
".",
"clf_",
",",
"vec",
"=",
"self",
".",
"vec_",
",",
"*",
"*",
"... | Call :func:`eli5.show_weights` for the locally-fit
classification pipeline. Keyword arguments are passed
to :func:`eli5.show_weights`.
:func:`fit` must be called before using this method. | [
"Call",
":",
"func",
":",
"eli5",
".",
"show_weights",
"for",
"the",
"locally",
"-",
"fit",
"classification",
"pipeline",
".",
"Keyword",
"arguments",
"are",
"passed",
"to",
":",
"func",
":",
"eli5",
".",
"show_weights",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/lime.py#L304-L313 | train | Return the classification weights for the locally - fit
. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/utils.py | fit_proba | def fit_proba(clf, X, y_proba, expand_factor=10, sample_weight=None,
shuffle=True, random_state=None,
**fit_params):
"""
Fit classifier ``clf`` to return probabilities close to ``y_proba``.
scikit-learn can't optimize cross-entropy directly if target
probability values are n... | python | def fit_proba(clf, X, y_proba, expand_factor=10, sample_weight=None,
shuffle=True, random_state=None,
**fit_params):
"""
Fit classifier ``clf`` to return probabilities close to ``y_proba``.
scikit-learn can't optimize cross-entropy directly if target
probability values are n... | [
"def",
"fit_proba",
"(",
"clf",
",",
"X",
",",
"y_proba",
",",
"expand_factor",
"=",
"10",
",",
"sample_weight",
"=",
"None",
",",
"shuffle",
"=",
"True",
",",
"random_state",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"X",
",",
"y",
",",
... | Fit classifier ``clf`` to return probabilities close to ``y_proba``.
scikit-learn can't optimize cross-entropy directly if target
probability values are not indicator vectors. As a workaround this function
expands the dataset according to target probabilities.
Use expand_factor=None to turn it off
... | [
"Fit",
"classifier",
"clf",
"to",
"return",
"probabilities",
"close",
"to",
"y_proba",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/utils.py#L16-L36 | train | Fit classifier clf to return probabilities close to y_proba. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/utils.py | with_sample_weight | def with_sample_weight(clf, sample_weight, fit_params):
"""
Return fit_params with added "sample_weight" argument.
Unlike `fit_params['sample_weight'] = sample_weight` it
handles a case where ``clf`` is a pipeline.
"""
param_name = _get_classifier_prefix(clf) + "sample_weight"
params = {para... | python | def with_sample_weight(clf, sample_weight, fit_params):
"""
Return fit_params with added "sample_weight" argument.
Unlike `fit_params['sample_weight'] = sample_weight` it
handles a case where ``clf`` is a pipeline.
"""
param_name = _get_classifier_prefix(clf) + "sample_weight"
params = {para... | [
"def",
"with_sample_weight",
"(",
"clf",
",",
"sample_weight",
",",
"fit_params",
")",
":",
"param_name",
"=",
"_get_classifier_prefix",
"(",
"clf",
")",
"+",
"\"sample_weight\"",
"params",
"=",
"{",
"param_name",
":",
"sample_weight",
"}",
"params",
".",
"updat... | Return fit_params with added "sample_weight" argument.
Unlike `fit_params['sample_weight'] = sample_weight` it
handles a case where ``clf`` is a pipeline. | [
"Return",
"fit_params",
"with",
"added",
"sample_weight",
"argument",
".",
"Unlike",
"fit_params",
"[",
"sample_weight",
"]",
"=",
"sample_weight",
"it",
"handles",
"a",
"case",
"where",
"clf",
"is",
"a",
"pipeline",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/utils.py#L39-L48 | train | Return fit_params with added sample_weight argument. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/utils.py | fix_multiclass_predict_proba | def fix_multiclass_predict_proba(y_proba, # type: np.ndarray
seen_classes,
complete_classes
):
# type: (...) -> np.ndarray
"""
Add missing columns to predict_proba result.
When a multiclass class... | python | def fix_multiclass_predict_proba(y_proba, # type: np.ndarray
seen_classes,
complete_classes
):
# type: (...) -> np.ndarray
"""
Add missing columns to predict_proba result.
When a multiclass class... | [
"def",
"fix_multiclass_predict_proba",
"(",
"y_proba",
",",
"# type: np.ndarray",
"seen_classes",
",",
"complete_classes",
")",
":",
"# type: (...) -> np.ndarray",
"assert",
"set",
"(",
"complete_classes",
")",
">=",
"set",
"(",
"seen_classes",
")",
"y_proba_fixed",
"="... | Add missing columns to predict_proba result.
When a multiclass classifier is fit on a dataset which only contains
a subset of possible classes its predict_proba result only has columns
corresponding to seen classes. This function adds missing columns. | [
"Add",
"missing",
"columns",
"to",
"predict_proba",
"result",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/utils.py#L51-L70 | train | This function fixes the predict_proba column in the multiclass classifier. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/utils.py | expanded_X_y_sample_weights | def expanded_X_y_sample_weights(X, y_proba, expand_factor=10,
sample_weight=None, shuffle=True,
random_state=None):
"""
scikit-learn can't optimize cross-entropy directly if target
probability values are not indicator vectors.
As a workarou... | python | def expanded_X_y_sample_weights(X, y_proba, expand_factor=10,
sample_weight=None, shuffle=True,
random_state=None):
"""
scikit-learn can't optimize cross-entropy directly if target
probability values are not indicator vectors.
As a workarou... | [
"def",
"expanded_X_y_sample_weights",
"(",
"X",
",",
"y_proba",
",",
"expand_factor",
"=",
"10",
",",
"sample_weight",
"=",
"None",
",",
"shuffle",
"=",
"True",
",",
"random_state",
"=",
"None",
")",
":",
"rng",
"=",
"check_random_state",
"(",
"random_state",
... | scikit-learn can't optimize cross-entropy directly if target
probability values are not indicator vectors.
As a workaround this function expands the dataset according to
target probabilities. ``expand_factor=None`` means no dataset
expansion. | [
"scikit",
"-",
"learn",
"can",
"t",
"optimize",
"cross",
"-",
"entropy",
"directly",
"if",
"target",
"probability",
"values",
"are",
"not",
"indicator",
"vectors",
".",
"As",
"a",
"workaround",
"this",
"function",
"expands",
"the",
"dataset",
"according",
"to"... | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/utils.py#L94-L129 | train | Expands the dataset X and y according to the target probabilities y_proba. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/lime/utils.py | expand_dataset | def expand_dataset(X, y_proba, factor=10, random_state=None, extra_arrays=None):
"""
Convert a dataset with float multiclass probabilities to a dataset
with indicator probabilities by duplicating X rows and sampling
true labels.
"""
rng = check_random_state(random_state)
extra_arrays = extra... | python | def expand_dataset(X, y_proba, factor=10, random_state=None, extra_arrays=None):
"""
Convert a dataset with float multiclass probabilities to a dataset
with indicator probabilities by duplicating X rows and sampling
true labels.
"""
rng = check_random_state(random_state)
extra_arrays = extra... | [
"def",
"expand_dataset",
"(",
"X",
",",
"y_proba",
",",
"factor",
"=",
"10",
",",
"random_state",
"=",
"None",
",",
"extra_arrays",
"=",
"None",
")",
":",
"rng",
"=",
"check_random_state",
"(",
"random_state",
")",
"extra_arrays",
"=",
"extra_arrays",
"or",
... | Convert a dataset with float multiclass probabilities to a dataset
with indicator probabilities by duplicating X rows and sampling
true labels. | [
"Convert",
"a",
"dataset",
"with",
"float",
"multiclass",
"probabilities",
"to",
"a",
"dataset",
"with",
"indicator",
"probabilities",
"by",
"duplicating",
"X",
"rows",
"and",
"sampling",
"true",
"labels",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/lime/utils.py#L132-L146 | train | Convert a dataset with float multiclass probabilities to a dataset with indicator probabilities by duplicating X rows and sampling
true labels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/transform.py | transform_feature_names | def transform_feature_names(transformer, in_names=None):
"""Get feature names for transformer output as a function of input names.
Used by :func:`explain_weights` when applied to a scikit-learn Pipeline,
this ``singledispatch`` should be registered with custom name
transformations for each class of tra... | python | def transform_feature_names(transformer, in_names=None):
"""Get feature names for transformer output as a function of input names.
Used by :func:`explain_weights` when applied to a scikit-learn Pipeline,
this ``singledispatch`` should be registered with custom name
transformations for each class of tra... | [
"def",
"transform_feature_names",
"(",
"transformer",
",",
"in_names",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"transformer",
",",
"'get_feature_names'",
")",
":",
"return",
"transformer",
".",
"get_feature_names",
"(",
")",
"raise",
"NotImplementedError",
"(... | Get feature names for transformer output as a function of input names.
Used by :func:`explain_weights` when applied to a scikit-learn Pipeline,
this ``singledispatch`` should be registered with custom name
transformations for each class of transformer.
If there is no ``singledispatch`` handler reg... | [
"Get",
"feature",
"names",
"for",
"transformer",
"output",
"as",
"a",
"function",
"of",
"input",
"names",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/transform.py#L7-L34 | train | Get feature names for a given transformer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/text.py | get_weighted_spans | def get_weighted_spans(doc, vec, feature_weights):
# type: (Any, Any, FeatureWeights) -> Optional[WeightedSpans]
""" If possible, return a dict with preprocessed document and a list
of spans with weights, corresponding to features in the document.
"""
if isinstance(vec, FeatureUnion):
return... | python | def get_weighted_spans(doc, vec, feature_weights):
# type: (Any, Any, FeatureWeights) -> Optional[WeightedSpans]
""" If possible, return a dict with preprocessed document and a list
of spans with weights, corresponding to features in the document.
"""
if isinstance(vec, FeatureUnion):
return... | [
"def",
"get_weighted_spans",
"(",
"doc",
",",
"vec",
",",
"feature_weights",
")",
":",
"# type: (Any, Any, FeatureWeights) -> Optional[WeightedSpans]",
"if",
"isinstance",
"(",
"vec",
",",
"FeatureUnion",
")",
":",
"return",
"_get_weighted_spans_from_union",
"(",
"doc",
... | If possible, return a dict with preprocessed document and a list
of spans with weights, corresponding to features in the document. | [
"If",
"possible",
"return",
"a",
"dict",
"with",
"preprocessed",
"document",
"and",
"a",
"list",
"of",
"spans",
"with",
"weights",
"corresponding",
"to",
"features",
"in",
"the",
"document",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/text.py#L15-L30 | train | Returns a dict with preprocessed document and a list of weighted spans corresponding to features in the document. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/text.py | add_weighted_spans | def add_weighted_spans(doc, vec, vectorized, target_expl):
# type: (Any, Any, bool, TargetExplanation) -> None
"""
Compute and set ``target_expl.weighted_spans`` attribute, when possible.
"""
if vec is None or vectorized:
return
weighted_spans = get_weighted_spans(doc, vec, target_expl.... | python | def add_weighted_spans(doc, vec, vectorized, target_expl):
# type: (Any, Any, bool, TargetExplanation) -> None
"""
Compute and set ``target_expl.weighted_spans`` attribute, when possible.
"""
if vec is None or vectorized:
return
weighted_spans = get_weighted_spans(doc, vec, target_expl.... | [
"def",
"add_weighted_spans",
"(",
"doc",
",",
"vec",
",",
"vectorized",
",",
"target_expl",
")",
":",
"# type: (Any, Any, bool, TargetExplanation) -> None",
"if",
"vec",
"is",
"None",
"or",
"vectorized",
":",
"return",
"weighted_spans",
"=",
"get_weighted_spans",
"(",... | Compute and set ``target_expl.weighted_spans`` attribute, when possible. | [
"Compute",
"and",
"set",
"target_expl",
".",
"weighted_spans",
"attribute",
"when",
"possible",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/text.py#L33-L43 | train | Compute and set target_expl. weighted_spans attribute when possible. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/text.py | _get_feature_weights_dict | def _get_feature_weights_dict(feature_weights, # type: FeatureWeights
feature_fn # type: Optional[Callable[[str], str]]
):
# type: (...) -> Dict[str, Tuple[float, Tuple[str, int]]]
""" Return {feat_name: (weight, (group, idx))} mapping. """
... | python | def _get_feature_weights_dict(feature_weights, # type: FeatureWeights
feature_fn # type: Optional[Callable[[str], str]]
):
# type: (...) -> Dict[str, Tuple[float, Tuple[str, int]]]
""" Return {feat_name: (weight, (group, idx))} mapping. """
... | [
"def",
"_get_feature_weights_dict",
"(",
"feature_weights",
",",
"# type: FeatureWeights",
"feature_fn",
"# type: Optional[Callable[[str], str]]",
")",
":",
"# type: (...) -> Dict[str, Tuple[float, Tuple[str, int]]]",
"return",
"{",
"# (group, idx) is an unique feature identifier, e.g. ('p... | Return {feat_name: (weight, (group, idx))} mapping. | [
"Return",
"{",
"feat_name",
":",
"(",
"weight",
"(",
"group",
"idx",
"))",
"}",
"mapping",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/text.py#L87-L98 | train | Return a dictionary mapping each feature name to its weight. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/sklearn/permutation_importance.py | PermutationImportance.fit | def fit(self, X, y, groups=None, **fit_params):
# type: (...) -> PermutationImportance
"""Compute ``feature_importances_`` attribute and optionally
fit the base estimator.
Parameters
----------
X : array-like of shape (n_samples, n_features)
The training inpu... | python | def fit(self, X, y, groups=None, **fit_params):
# type: (...) -> PermutationImportance
"""Compute ``feature_importances_`` attribute and optionally
fit the base estimator.
Parameters
----------
X : array-like of shape (n_samples, n_features)
The training inpu... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"groups",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"# type: (...) -> PermutationImportance",
"self",
".",
"scorer_",
"=",
"check_scoring",
"(",
"self",
".",
"estimator",
",",
"scoring",
"=",
... | Compute ``feature_importances_`` attribute and optionally
fit the base estimator.
Parameters
----------
X : array-like of shape (n_samples, n_features)
The training input samples.
y : array-like, shape (n_samples,)
The target values (integers that corres... | [
"Compute",
"feature_importances_",
"attribute",
"and",
"optionally",
"fit",
"the",
"base",
"estimator",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/permutation_importance.py#L163-L208 | train | Fits the base estimator and returns the PermutationImportance object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
TeamHG-Memex/eli5 | eli5/explain.py | explain_prediction | def explain_prediction(estimator, doc, **kwargs):
"""
Return an explanation of an estimator prediction.
:func:`explain_prediction` is not doing any work itself, it dispatches
to a concrete implementation based on estimator type.
Parameters
----------
estimator : object
Estimator in... | python | def explain_prediction(estimator, doc, **kwargs):
"""
Return an explanation of an estimator prediction.
:func:`explain_prediction` is not doing any work itself, it dispatches
to a concrete implementation based on estimator type.
Parameters
----------
estimator : object
Estimator in... | [
"def",
"explain_prediction",
"(",
"estimator",
",",
"doc",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Explanation",
"(",
"estimator",
"=",
"repr",
"(",
"estimator",
")",
",",
"error",
"=",
"\"estimator %r is not supported\"",
"%",
"estimator",
",",
")"
] | Return an explanation of an estimator prediction.
:func:`explain_prediction` is not doing any work itself, it dispatches
to a concrete implementation based on estimator type.
Parameters
----------
estimator : object
Estimator instance. This argument must be positional.
doc : object
... | [
"Return",
"an",
"explanation",
"of",
"an",
"estimator",
"prediction",
"."
] | 371b402a0676295c05e582a2dd591f7af476b86b | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/explain.py#L83-L177 | train | Return an explanation of an estimator prediction. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/directions.py | directions | def directions(client, origin, destination,
mode=None, waypoints=None, alternatives=False, avoid=None,
language=None, units=None, region=None, departure_time=None,
arrival_time=None, optimize_waypoints=False, transit_mode=None,
transit_routing_preference=None,... | python | def directions(client, origin, destination,
mode=None, waypoints=None, alternatives=False, avoid=None,
language=None, units=None, region=None, departure_time=None,
arrival_time=None, optimize_waypoints=False, transit_mode=None,
transit_routing_preference=None,... | [
"def",
"directions",
"(",
"client",
",",
"origin",
",",
"destination",
",",
"mode",
"=",
"None",
",",
"waypoints",
"=",
"None",
",",
"alternatives",
"=",
"False",
",",
"avoid",
"=",
"None",
",",
"language",
"=",
"None",
",",
"units",
"=",
"None",
",",
... | Get directions between an origin point and a destination point.
:param origin: The address or latitude/longitude value from which you wish
to calculate directions.
:type origin: string, dict, list, or tuple
:param destination: The address or latitude/longitude value from which
you wish to ... | [
"Get",
"directions",
"between",
"an",
"origin",
"point",
"and",
"a",
"destination",
"point",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/directions.py#L23-L151 | train | Calculate the directions between two locations. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/geocoding.py | geocode | def geocode(client, address=None, components=None, bounds=None, region=None,
language=None):
"""
Geocoding is the process of converting addresses
(like ``"1600 Amphitheatre Parkway, Mountain View, CA"``) into geographic
coordinates (like latitude 37.423021 and longitude -122.083739), which y... | python | def geocode(client, address=None, components=None, bounds=None, region=None,
language=None):
"""
Geocoding is the process of converting addresses
(like ``"1600 Amphitheatre Parkway, Mountain View, CA"``) into geographic
coordinates (like latitude 37.423021 and longitude -122.083739), which y... | [
"def",
"geocode",
"(",
"client",
",",
"address",
"=",
"None",
",",
"components",
"=",
"None",
",",
"bounds",
"=",
"None",
",",
"region",
"=",
"None",
",",
"language",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"address",
":",
"params",
"... | Geocoding is the process of converting addresses
(like ``"1600 Amphitheatre Parkway, Mountain View, CA"``) into geographic
coordinates (like latitude 37.423021 and longitude -122.083739), which you
can use to place markers or position the map.
:param address: The address to geocode.
:type address: ... | [
"Geocoding",
"is",
"the",
"process",
"of",
"converting",
"addresses",
"(",
"like",
"1600",
"Amphitheatre",
"Parkway",
"Mountain",
"View",
"CA",
")",
"into",
"geographic",
"coordinates",
"(",
"like",
"latitude",
"37",
".",
"423021",
"and",
"longitude",
"-",
"12... | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/geocoding.py#L22-L68 | train | Geocoding for a specific address components bounds and region. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/geocoding.py | reverse_geocode | def reverse_geocode(client, latlng, result_type=None, location_type=None,
language=None):
"""
Reverse geocoding is the process of converting geographic coordinates into a
human-readable address.
:param latlng: The latitude/longitude value or place_id for which you wish
to ob... | python | def reverse_geocode(client, latlng, result_type=None, location_type=None,
language=None):
"""
Reverse geocoding is the process of converting geographic coordinates into a
human-readable address.
:param latlng: The latitude/longitude value or place_id for which you wish
to ob... | [
"def",
"reverse_geocode",
"(",
"client",
",",
"latlng",
",",
"result_type",
"=",
"None",
",",
"location_type",
"=",
"None",
",",
"language",
"=",
"None",
")",
":",
"# Check if latlng param is a place_id string.",
"# place_id strings do not contain commas; latlng strings do... | Reverse geocoding is the process of converting geographic coordinates into a
human-readable address.
:param latlng: The latitude/longitude value or place_id for which you wish
to obtain the closest, human-readable address.
:type latlng: string, dict, list, or tuple
:param result_type: One or m... | [
"Reverse",
"geocoding",
"is",
"the",
"process",
"of",
"converting",
"geographic",
"coordinates",
"into",
"a",
"human",
"-",
"readable",
"address",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/geocoding.py#L71-L109 | train | Reverse geocoding for a given location. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/elevation.py | elevation | def elevation(client, locations):
"""
Provides elevation data for locations provided on the surface of the
earth, including depth locations on the ocean floor (which return negative
values)
:param locations: List of latitude/longitude values from which you wish
to calculate elevation data.
... | python | def elevation(client, locations):
"""
Provides elevation data for locations provided on the surface of the
earth, including depth locations on the ocean floor (which return negative
values)
:param locations: List of latitude/longitude values from which you wish
to calculate elevation data.
... | [
"def",
"elevation",
"(",
"client",
",",
"locations",
")",
":",
"params",
"=",
"{",
"\"locations\"",
":",
"convert",
".",
"shortest_path",
"(",
"locations",
")",
"}",
"return",
"client",
".",
"_request",
"(",
"\"/maps/api/elevation/json\"",
",",
"params",
")",
... | Provides elevation data for locations provided on the surface of the
earth, including depth locations on the ocean floor (which return negative
values)
:param locations: List of latitude/longitude values from which you wish
to calculate elevation data.
:type locations: a single location, or a l... | [
"Provides",
"elevation",
"data",
"for",
"locations",
"provided",
"on",
"the",
"surface",
"of",
"the",
"earth",
"including",
"depth",
"locations",
"on",
"the",
"ocean",
"floor",
"(",
"which",
"return",
"negative",
"values",
")"
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/elevation.py#L23-L37 | train | Provides elevation data for a single location in the order they appear. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/elevation.py | elevation_along_path | def elevation_along_path(client, path, samples):
"""
Provides elevation data sampled along a path on the surface of the earth.
:param path: An encoded polyline string, or a list of latitude/longitude
values from which you wish to calculate elevation data.
:type path: string, dict, list, or tupl... | python | def elevation_along_path(client, path, samples):
"""
Provides elevation data sampled along a path on the surface of the earth.
:param path: An encoded polyline string, or a list of latitude/longitude
values from which you wish to calculate elevation data.
:type path: string, dict, list, or tupl... | [
"def",
"elevation_along_path",
"(",
"client",
",",
"path",
",",
"samples",
")",
":",
"if",
"type",
"(",
"path",
")",
"is",
"str",
":",
"path",
"=",
"\"enc:%s\"",
"%",
"path",
"else",
":",
"path",
"=",
"convert",
".",
"shortest_path",
"(",
"path",
")",
... | Provides elevation data sampled along a path on the surface of the earth.
:param path: An encoded polyline string, or a list of latitude/longitude
values from which you wish to calculate elevation data.
:type path: string, dict, list, or tuple
:param samples: The number of sample points along a pa... | [
"Provides",
"elevation",
"data",
"sampled",
"along",
"a",
"path",
"on",
"the",
"surface",
"of",
"the",
"earth",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/elevation.py#L40-L65 | train | Provides elevation data sampled along a path on the surface of the earth. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | latlng | def latlng(arg):
"""Converts a lat/lon pair to a comma-separated string.
For example:
sydney = {
"lat" : -33.8674869,
"lng" : 151.2069902
}
convert.latlng(sydney)
# '-33.8674869,151.2069902'
For convenience, also accepts lat/lon pair as a string, in
which case it's re... | python | def latlng(arg):
"""Converts a lat/lon pair to a comma-separated string.
For example:
sydney = {
"lat" : -33.8674869,
"lng" : 151.2069902
}
convert.latlng(sydney)
# '-33.8674869,151.2069902'
For convenience, also accepts lat/lon pair as a string, in
which case it's re... | [
"def",
"latlng",
"(",
"arg",
")",
":",
"if",
"is_string",
"(",
"arg",
")",
":",
"return",
"arg",
"normalized",
"=",
"normalize_lat_lng",
"(",
"arg",
")",
"return",
"\"%s,%s\"",
"%",
"(",
"format_float",
"(",
"normalized",
"[",
"0",
"]",
")",
",",
"form... | Converts a lat/lon pair to a comma-separated string.
For example:
sydney = {
"lat" : -33.8674869,
"lng" : 151.2069902
}
convert.latlng(sydney)
# '-33.8674869,151.2069902'
For convenience, also accepts lat/lon pair as a string, in
which case it's returned unchanged.
:... | [
"Converts",
"a",
"lat",
"/",
"lon",
"pair",
"to",
"a",
"comma",
"-",
"separated",
"string",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L57-L80 | train | Converts a lat / lon pair to a comma - separated string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | normalize_lat_lng | def normalize_lat_lng(arg):
"""Take the various lat/lng representations and return a tuple.
Accepts various representations:
1) dict with two entries - "lat" and "lng"
2) list or tuple - e.g. (-33, 151) or [-33, 151]
:param arg: The lat/lng pair.
:type arg: dict or list or tuple
:rtype: t... | python | def normalize_lat_lng(arg):
"""Take the various lat/lng representations and return a tuple.
Accepts various representations:
1) dict with two entries - "lat" and "lng"
2) list or tuple - e.g. (-33, 151) or [-33, 151]
:param arg: The lat/lng pair.
:type arg: dict or list or tuple
:rtype: t... | [
"def",
"normalize_lat_lng",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"if",
"\"lat\"",
"in",
"arg",
"and",
"\"lng\"",
"in",
"arg",
":",
"return",
"arg",
"[",
"\"lat\"",
"]",
",",
"arg",
"[",
"\"lng\"",
"]",
"if",
... | Take the various lat/lng representations and return a tuple.
Accepts various representations:
1) dict with two entries - "lat" and "lng"
2) list or tuple - e.g. (-33, 151) or [-33, 151]
:param arg: The lat/lng pair.
:type arg: dict or list or tuple
:rtype: tuple (lat, lng) | [
"Take",
"the",
"various",
"lat",
"/",
"lng",
"representations",
"and",
"return",
"a",
"tuple",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L83-L107 | train | Normalizes the various lat and lng representations and return a tuple. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | location_list | def location_list(arg):
"""Joins a list of locations into a pipe separated string, handling
the various formats supported for lat/lng values.
For example:
p = [{"lat" : -33.867486, "lng" : 151.206990}, "Sydney"]
convert.waypoint(p)
# '-33.867486,151.206990|Sydney'
:param arg: The lat/lng l... | python | def location_list(arg):
"""Joins a list of locations into a pipe separated string, handling
the various formats supported for lat/lng values.
For example:
p = [{"lat" : -33.867486, "lng" : 151.206990}, "Sydney"]
convert.waypoint(p)
# '-33.867486,151.206990|Sydney'
:param arg: The lat/lng l... | [
"def",
"location_list",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"tuple",
")",
":",
"# Handle the single-tuple lat/lng case.",
"return",
"latlng",
"(",
"arg",
")",
"else",
":",
"return",
"\"|\"",
".",
"join",
"(",
"[",
"latlng",
"(",
"loc... | Joins a list of locations into a pipe separated string, handling
the various formats supported for lat/lng values.
For example:
p = [{"lat" : -33.867486, "lng" : 151.206990}, "Sydney"]
convert.waypoint(p)
# '-33.867486,151.206990|Sydney'
:param arg: The lat/lng list.
:type arg: list
:... | [
"Joins",
"a",
"list",
"of",
"locations",
"into",
"a",
"pipe",
"separated",
"string",
"handling",
"the",
"various",
"formats",
"supported",
"for",
"lat",
"/",
"lng",
"values",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L110-L128 | train | Joins a list of locations into a pipe separated string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | _is_list | def _is_list(arg):
"""Checks if arg is list-like. This excludes strings and dicts."""
if isinstance(arg, dict):
return False
if isinstance(arg, str): # Python 3-only, as str has __iter__
return False
return (not _has_method(arg, "strip")
and _has_method(arg, "__getitem__")
... | python | def _is_list(arg):
"""Checks if arg is list-like. This excludes strings and dicts."""
if isinstance(arg, dict):
return False
if isinstance(arg, str): # Python 3-only, as str has __iter__
return False
return (not _has_method(arg, "strip")
and _has_method(arg, "__getitem__")
... | [
"def",
"_is_list",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"return",
"False",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"# Python 3-only, as str has __iter__",
"return",
"False",
"return",
"(",
"not",
"_has_... | Checks if arg is list-like. This excludes strings and dicts. | [
"Checks",
"if",
"arg",
"is",
"list",
"-",
"like",
".",
"This",
"excludes",
"strings",
"and",
"dicts",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L156-L164 | train | Checks if arg is list - like. This excludes strings and dicts. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | is_string | def is_string(val):
"""Determines whether the passed value is a string, safe for 2/3."""
try:
basestring
except NameError:
return isinstance(val, str)
return isinstance(val, basestring) | python | def is_string(val):
"""Determines whether the passed value is a string, safe for 2/3."""
try:
basestring
except NameError:
return isinstance(val, str)
return isinstance(val, basestring) | [
"def",
"is_string",
"(",
"val",
")",
":",
"try",
":",
"basestring",
"except",
"NameError",
":",
"return",
"isinstance",
"(",
"val",
",",
"str",
")",
"return",
"isinstance",
"(",
"val",
",",
"basestring",
")"
] | Determines whether the passed value is a string, safe for 2/3. | [
"Determines",
"whether",
"the",
"passed",
"value",
"is",
"a",
"string",
"safe",
"for",
"2",
"/",
"3",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L167-L173 | train | Determines whether the passed value is a string safe for 2 or 3. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | time | def time(arg):
"""Converts the value into a unix time (seconds since unix epoch).
For example:
convert.time(datetime.now())
# '1409810596'
:param arg: The time.
:type arg: datetime.datetime or int
"""
# handle datetime instances.
if _has_method(arg, "timetuple"):
ar... | python | def time(arg):
"""Converts the value into a unix time (seconds since unix epoch).
For example:
convert.time(datetime.now())
# '1409810596'
:param arg: The time.
:type arg: datetime.datetime or int
"""
# handle datetime instances.
if _has_method(arg, "timetuple"):
ar... | [
"def",
"time",
"(",
"arg",
")",
":",
"# handle datetime instances.",
"if",
"_has_method",
"(",
"arg",
",",
"\"timetuple\"",
")",
":",
"arg",
"=",
"_time",
".",
"mktime",
"(",
"arg",
".",
"timetuple",
"(",
")",
")",
"if",
"isinstance",
"(",
"arg",
",",
... | Converts the value into a unix time (seconds since unix epoch).
For example:
convert.time(datetime.now())
# '1409810596'
:param arg: The time.
:type arg: datetime.datetime or int | [
"Converts",
"the",
"value",
"into",
"a",
"unix",
"time",
"(",
"seconds",
"since",
"unix",
"epoch",
")",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L176-L193 | train | Converts the value into a unix time. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | _has_method | def _has_method(arg, method):
"""Returns true if the given object has a method with the given name.
:param arg: the object
:param method: the method name
:type method: string
:rtype: bool
"""
return hasattr(arg, method) and callable(getattr(arg, method)) | python | def _has_method(arg, method):
"""Returns true if the given object has a method with the given name.
:param arg: the object
:param method: the method name
:type method: string
:rtype: bool
"""
return hasattr(arg, method) and callable(getattr(arg, method)) | [
"def",
"_has_method",
"(",
"arg",
",",
"method",
")",
":",
"return",
"hasattr",
"(",
"arg",
",",
"method",
")",
"and",
"callable",
"(",
"getattr",
"(",
"arg",
",",
"method",
")",
")"
] | Returns true if the given object has a method with the given name.
:param arg: the object
:param method: the method name
:type method: string
:rtype: bool | [
"Returns",
"true",
"if",
"the",
"given",
"object",
"has",
"a",
"method",
"with",
"the",
"given",
"name",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L196-L206 | train | Returns true if the given object has a method with the given name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | components | def components(arg):
"""Converts a dict of components to the format expected by the Google Maps
server.
For example:
c = {"country": "US", "postal_code": "94043"}
convert.components(c)
# 'country:US|postal_code:94043'
:param arg: The component filter.
:type arg: dict
:rtype: bases... | python | def components(arg):
"""Converts a dict of components to the format expected by the Google Maps
server.
For example:
c = {"country": "US", "postal_code": "94043"}
convert.components(c)
# 'country:US|postal_code:94043'
:param arg: The component filter.
:type arg: dict
:rtype: bases... | [
"def",
"components",
"(",
"arg",
")",
":",
"# Components may have multiple values per type, here we",
"# expand them into individual key/value items, eg:",
"# {\"country\": [\"US\", \"AU\"], \"foo\": 1} -> \"country:AU\", \"country:US\", \"foo:1\"",
"def",
"expand",
"(",
"arg",
")",
":",... | Converts a dict of components to the format expected by the Google Maps
server.
For example:
c = {"country": "US", "postal_code": "94043"}
convert.components(c)
# 'country:US|postal_code:94043'
:param arg: The component filter.
:type arg: dict
:rtype: basestring | [
"Converts",
"a",
"dict",
"of",
"components",
"to",
"the",
"format",
"expected",
"by",
"the",
"Google",
"Maps",
"server",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L209-L237 | train | Converts a dict of components to the format expected by the Google Maps
server. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
googlemaps/google-maps-services-python | googlemaps/convert.py | bounds | def bounds(arg):
"""Converts a lat/lon bounds to a comma- and pipe-separated string.
Accepts two representations:
1) string: pipe-separated pair of comma-separated lat/lon pairs.
2) dict with two entries - "southwest" and "northeast". See convert.latlng
for information on how these can be represent... | python | def bounds(arg):
"""Converts a lat/lon bounds to a comma- and pipe-separated string.
Accepts two representations:
1) string: pipe-separated pair of comma-separated lat/lon pairs.
2) dict with two entries - "southwest" and "northeast". See convert.latlng
for information on how these can be represent... | [
"def",
"bounds",
"(",
"arg",
")",
":",
"if",
"is_string",
"(",
"arg",
")",
"and",
"arg",
".",
"count",
"(",
"\"|\"",
")",
"==",
"1",
"and",
"arg",
".",
"count",
"(",
"\",\"",
")",
"==",
"2",
":",
"return",
"arg",
"elif",
"isinstance",
"(",
"arg",... | Converts a lat/lon bounds to a comma- and pipe-separated string.
Accepts two representations:
1) string: pipe-separated pair of comma-separated lat/lon pairs.
2) dict with two entries - "southwest" and "northeast". See convert.latlng
for information on how these can be represented.
For example:
... | [
"Converts",
"a",
"lat",
"/",
"lon",
"bounds",
"to",
"a",
"comma",
"-",
"and",
"pipe",
"-",
"separated",
"string",
"."
] | 7ed40b4d8df63479794c46ce29d03ed6083071d7 | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L240-L277 | train | Converts a lat - lng bounds dict to a comma - separated string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.