id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
2,601 | config | def config(self) -> Dict[str, Any]:
if self._config is not None:
return deepcopy(self._config)
self._config = {k: v["config"] for (k, v) in self._entries.items()}
return deepcopy(self._config) | python | wandb/testing/relay.py | 180 | 185 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,602 | get_run_telemetry | def get_run_telemetry(self, run_id: str) -> Dict[str, Any]:
return self.config.get(run_id, {}).get("_wandb", {}).get("value", {}).get("t") | python | wandb/testing/relay.py | 201 | 202 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,603 | get_run_metrics | def get_run_metrics(self, run_id: str) -> Dict[str, Any]:
return self.config.get(run_id, {}).get("_wandb", {}).get("value", {}).get("m") | python | wandb/testing/relay.py | 204 | 205 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,604 | get_run_summary | def get_run_summary(
self, run_id: str, include_private: bool = False
) -> Dict[str, Any]:
# run summary dataframe must have only one row
# for the given run id, so we convert it to dict
# and extract the first (and only) row.
mask_run = self.summary["__run_id"] == run_id
... | python | wandb/testing/relay.py | 207 | 220 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,605 | get_run_history | def get_run_history(
self, run_id: str, include_private: bool = False
) -> pd.DataFrame:
mask_run = self.history["__run_id"] == run_id
run_history = self.history[mask_run]
return (
run_history.filter(regex="^[^_]", axis=1)
if not include_private
el... | python | wandb/testing/relay.py | 222 | 231 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,606 | get_run_uploaded_files | def get_run_uploaded_files(self, run_id: str) -> Dict[str, Any]:
return self.entries.get(run_id, {}).get("uploaded", []) | python | wandb/testing/relay.py | 233 | 234 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,607 | get_run_stats | def get_run_stats(self, run_id: str) -> pd.DataFrame:
mask_run = self.events["__run_id"] == run_id
run_stats = self.events[mask_run]
return run_stats | python | wandb/testing/relay.py | 236 | 239 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,608 | __init__ | def __init__(self):
self.resolvers: List["Resolver"] = [
{
"name": "upsert_bucket",
"resolver": self.resolve_upsert_bucket,
},
{
"name": "upload_files",
"resolver": self.resolve_upload_files,
},
... | python | wandb/testing/relay.py | 250 | 275 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,609 | resolve_upsert_bucket | def resolve_upsert_bucket(
request_data: Dict[str, Any], response_data: Dict[str, Any], **kwargs: Any
) -> Optional[Dict[str, Any]]:
if not isinstance(request_data, dict) or not isinstance(response_data, dict):
return None
query = response_data.get("data", {}).get("upsertBucket")... | python | wandb/testing/relay.py | 278 | 288 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,610 | resolve_upload_files | def resolve_upload_files(
request_data: Dict[str, Any], response_data: Dict[str, Any], **kwargs: Any
) -> Optional[Dict[str, Any]]:
if not isinstance(request_data, dict):
return None
query = request_data.get("files") is not None
if query:
# todo: refactor this... | python | wandb/testing/relay.py | 291 | 317 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,611 | resolve_uploaded_files | def resolve_uploaded_files(
request_data: Dict[str, Any], response_data: Dict[str, Any], **kwargs: Any
) -> Optional[Dict[str, Any]]:
if not isinstance(request_data, dict) or not isinstance(response_data, dict):
return None
query = "RunUploadUrls" in request_data.get("query", "")... | python | wandb/testing/relay.py | 320 | 342 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,612 | resolve_preempting | def resolve_preempting(
request_data: Dict[str, Any], response_data: Dict[str, Any], **kwargs: Any
) -> Optional[Dict[str, Any]]:
if not isinstance(request_data, dict):
return None
query = "preempting" in request_data
if query:
name = kwargs.get("path").split(... | python | wandb/testing/relay.py | 345 | 358 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,613 | resolve_upsert_sweep | def resolve_upsert_sweep(
request_data: Dict[str, Any], response_data: Dict[str, Any], **kwargs: Any
) -> Optional[Dict[str, Any]]:
if not isinstance(response_data, dict):
return None
query = response_data.get("data", {}).get("upsertSweep") is not None
if query:
... | python | wandb/testing/relay.py | 361 | 370 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,614 | resolve_create_artifact | def resolve_create_artifact(
self, request_data: Dict[str, Any], response_data: Dict[str, Any], **kwargs: Any
) -> Optional[Dict[str, Any]]:
if not isinstance(request_data, dict):
return None
query = (
"createArtifact(" in request_data.get("query", "")
and... | python | wandb/testing/relay.py | 372 | 394 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,615 | resolve | def resolve(
self,
request_data: Dict[str, Any],
response_data: Dict[str, Any],
**kwargs: Any,
) -> Optional[Dict[str, Any]]:
for resolver in self.resolvers:
result = resolver.get("resolver")(request_data, response_data, **kwargs)
if result is not None... | python | wandb/testing/relay.py | 396 | 406 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,616 | __init__ | def __init__(self, pattern: str):
known_tokens = {self.APPLY_TOKEN, self.PASS_TOKEN, self.STOP_TOKEN}
if not pattern:
raise ValueError("Pattern cannot be empty")
if set(pattern) - known_tokens:
raise ValueError(f"Pattern can only contain {known_tokens}")
self.pat... | python | wandb/testing/relay.py | 414 | 421 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,617 | next | def next(self):
if self.pattern[0] == self.STOP_TOKEN:
return
self.pattern.rotate(-1) | python | wandb/testing/relay.py | 423 | 426 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,618 | should_apply | def should_apply(self) -> bool:
return self.pattern[0] == self.APPLY_TOKEN | python | wandb/testing/relay.py | 428 | 429 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,619 | __eq__ | def __eq__(
self,
other: Union["InjectedResponse", requests.Request, requests.PreparedRequest],
):
"""Check InjectedResponse object equality.
We use this to check if this response should be injected as a replacement of
`other`.
:param other:
:return:
... | python | wandb/testing/relay.py | 467 | 489 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,620 | to_dict | def to_dict(self):
excluded_fields = {"application_pattern", "custom_match_fn"}
return {
k: self.__getattribute__(k)
for k in self.__dict__
if (not k.startswith("_") and k not in excluded_fields)
} | python | wandb/testing/relay.py | 491 | 497 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,621 | process | def process(self, request: "flask.Request") -> None:
... # pragma: no cover | python | wandb/testing/relay.py | 501 | 502 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,622 | control | def control(self, request: "flask.Request") -> Mapping[str, str]:
... # pragma: no cover | python | wandb/testing/relay.py | 504 | 505 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,623 | __init__ | def __init__(
self,
base_url: str,
inject: Optional[List[InjectedResponse]] = None,
control: Optional[RelayControlProtocol] = None,
) -> None:
# todo for the future:
# - consider switching from Flask to Quart
# - async app will allow for better failure injec... | python | wandb/testing/relay.py | 509 | 568 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,624 | handle_http_exception | def handle_http_exception(e):
response = e.get_response()
return response | python | wandb/testing/relay.py | 571 | 573 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,625 | _get_free_port | def _get_free_port() -> int:
sock = socket.socket()
sock.bind(("", 0))
_, port = sock.getsockname()
return port | python | wandb/testing/relay.py | 576 | 581 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,626 | start | def start(self) -> None:
# run server in a separate thread
relay_server_thread = threading.Thread(
target=self.app.run,
kwargs={"port": self.port},
daemon=True,
)
relay_server_thread.start() | python | wandb/testing/relay.py | 583 | 590 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,627 | after_request_fn | def after_request_fn(self, response: "requests.Response") -> "requests.Response":
# todo: this is useful for debugging, but should be removed in the future
# flask.request.url = self.relay_url + flask.request.url
print(flask.request)
print(flask.request.get_json())
print(response... | python | wandb/testing/relay.py | 592 | 599 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,628 | relay | def relay(
self,
request: "flask.Request",
) -> Union["responses.Response", "requests.Response"]:
# replace the relay url with the real backend url (self.base_url)
url = (
urllib.parse.urlparse(request.url)
._replace(netloc=self.base_url.netloc, scheme=self.ba... | python | wandb/testing/relay.py | 601 | 637 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,629 | snoop_context | def snoop_context(
self,
request: "flask.Request",
response: "requests.Response",
time_elapsed: float,
**kwargs: Any,
) -> None:
request_data = request.get_json()
response_data = response.json() or {}
if self.relay_control:
self.relay_cont... | python | wandb/testing/relay.py | 639 | 665 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,630 | graphql | def graphql(self) -> Mapping[str, str]:
request = flask.request
with Timer() as timer:
relayed_response = self.relay(request)
# print("*****************")
# print("GRAPHQL REQUEST:")
# print(request.get_json())
# print("GRAPHQL RESPONSE:")
# print(rela... | python | wandb/testing/relay.py | 667 | 685 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,631 | file_stream | def file_stream(self, path) -> Mapping[str, str]:
request = flask.request
with Timer() as timer:
relayed_response = self.relay(request)
# print("*****************")
# print("FILE STREAM REQUEST:")
# print("********PATH*********")
# print(path)
# print(... | python | wandb/testing/relay.py | 687 | 704 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,632 | storage | def storage(self) -> Mapping[str, str]:
request = flask.request
with Timer() as timer:
relayed_response = self.relay(request)
# print("*****************")
# print("STORAGE REQUEST:")
# print(request.get_json())
# print("STORAGE RESPONSE:")
# print(rela... | python | wandb/testing/relay.py | 706 | 719 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,633 | storage_file | def storage_file(self, path) -> Mapping[str, str]:
request = flask.request
with Timer() as timer:
relayed_response = self.relay(request)
# print("*****************")
# print("STORAGE FILE REQUEST:")
# print("********PATH*********")
# print(path)
# prin... | python | wandb/testing/relay.py | 721 | 737 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,634 | control | def control(self) -> Mapping[str, str]:
assert self.relay_control
return self.relay_control.control(flask.request) | python | wandb/testing/relay.py | 739 | 741 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,635 | check_against_limit | def check_against_limit(count, chart, limit=None):
if limit is None:
limit = chart_limit
if count > limit:
warn_chart_limit(limit, chart)
return True
else:
return False | python | wandb/sklearn/utils.py | 14 | 21 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,636 | warn_chart_limit | def warn_chart_limit(limit, chart):
warning = f"using only the first {limit} datapoints to create chart {chart}"
wandb.termwarn(warning) | python | wandb/sklearn/utils.py | 24 | 26 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,637 | encode_labels | def encode_labels(df):
le = sklearn.preprocessing.LabelEncoder()
# apply le on categorical feature columns
categorical_cols = df.select_dtypes(
exclude=["int", "float", "float64", "float32", "int32", "int64"]
).columns
df[categorical_cols] = df[categorical_cols].apply(lambda col: le.fit_tran... | python | wandb/sklearn/utils.py | 29 | 35 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,638 | test_types | def test_types(**kwargs):
test_passed = True
for k, v in kwargs.items():
# check for incorrect types
if (
(k == "X")
or (k == "X_test")
or (k == "y")
or (k == "y_test")
or (k == "y_true")
or (k == "y_probas")
):
... | python | wandb/sklearn/utils.py | 38 | 86 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,639 | test_fitted | def test_fitted(model):
try:
model.predict(np.zeros((7, 3)))
except sklearn.exceptions.NotFittedError:
wandb.termerror("Please fit the model before passing it in.")
return False
except AttributeError:
# Some clustering models (LDA, PCA, Agglomerative) don't implement ``predic... | python | wandb/sklearn/utils.py | 89 | 122 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,640 | test_missing | def test_missing(**kwargs):
test_passed = True
for k, v in kwargs.items():
# Missing/empty params/datapoint arrays
if v is None:
wandb.termerror("%s is None. Please try again." % (k))
test_passed = False
if (k == "X") or (k == "X_test"):
if isinstance(... | python | wandb/sklearn/utils.py | 126 | 174 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,641 | round_3 | def round_3(n):
return round(n, 3) | python | wandb/sklearn/utils.py | 177 | 178 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,642 | round_2 | def round_2(n):
return round(n, 2) | python | wandb/sklearn/utils.py | 181 | 182 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,643 | classifier | def classifier(
model,
X_train,
X_test,
y_train,
y_test,
y_pred,
y_probas,
labels,
is_binary=False,
model_name="Classifier",
feature_names=None,
log_learning_curve=False,
):
"""Generate all sklearn classifier plots supported by W&B.
The following plots are genera... | python | wandb/sklearn/plot/classifier.py | 17 | 106 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,644 | roc | def roc(
y_true=None,
y_probas=None,
labels=None,
plot_micro=True,
plot_macro=True,
classes_to_plot=None,
):
"""Log the receiver-operating characteristic curve.
Arguments:
y_true: (arr) Test set labels.
y_probas: (arr) Test set predicted probabilities.
labels: (l... | python | wandb/sklearn/plot/classifier.py | 109 | 139 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,645 | confusion_matrix | def confusion_matrix(
y_true=None,
y_pred=None,
labels=None,
true_labels=None,
pred_labels=None,
normalize=False,
):
"""Log a confusion matrix to W&B.
Confusion matrices depict the pattern of misclassifications by a model.
Arguments:
y_true: (arr) Test set labels.
y... | python | wandb/sklearn/plot/classifier.py | 142 | 187 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,646 | precision_recall | def precision_recall(
y_true=None, y_probas=None, labels=None, plot_micro=True, classes_to_plot=None
):
"""Log a precision-recall curve to W&B.
Precision-recall curves depict the tradeoff between positive predictive value (precision)
and true positive rate (recall) as the threshold of a classifier is s... | python | wandb/sklearn/plot/classifier.py | 190 | 219 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,647 | feature_importances | def feature_importances(
model=None, feature_names=None, title="Feature Importance", max_num_features=50
):
"""Log a plot depicting the relative importance of each feature for a classifier's decisions.
Should only be called with a fitted classifer (otherwise an error is thrown).
Only works with classif... | python | wandb/sklearn/plot/classifier.py | 222 | 250 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,648 | class_proportions | def class_proportions(y_train=None, y_test=None, labels=None):
"""Plot the distribution of target classses in training and test sets.
Useful for detecting imbalanced classes.
Arguments:
y_train: (arr) Training set labels.
y_test: (arr) Test set labels.
labels: (list) Named labels f... | python | wandb/sklearn/plot/classifier.py | 253 | 281 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,649 | calibration_curve | def calibration_curve(clf=None, X=None, y=None, clf_name="Classifier"):
"""Log a plot depicting how well-calibrated the predicted probabilities of a classifier are.
Also suggests how to calibrate an uncalibrated classifier. Compares estimated predicted
probabilities by a baseline logistic regression model,... | python | wandb/sklearn/plot/classifier.py | 284 | 330 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,650 | summary_metrics | def summary_metrics(model=None, X=None, y=None, X_test=None, y_test=None):
"""Logs a chart depicting summary metrics for a model.
Should only be called with a fitted model (otherwise an error is thrown).
Arguments:
model: (clf or reg) Takes in a fitted regressor or classifier.
X: (arr) Tra... | python | wandb/sklearn/plot/shared.py | 13 | 44 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,651 | learning_curve | def learning_curve(
model=None,
X=None,
y=None,
cv=None,
shuffle=False,
random_state=None,
train_sizes=None,
n_jobs=1,
scoring=None,
):
"""Logs a plot depicting model performance against dataset size.
Please note this function fits the model to datasets of varying sizes when... | python | wandb/sklearn/plot/shared.py | 47 | 90 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,652 | regressor | def regressor(model, X_train, X_test, y_train, y_test, model_name="Regressor"):
"""Generates all sklearn regressor plots supported by W&B.
The following plots are generated:
learning curve, summary metrics, residuals plot, outlier candidates.
Should only be called with a fitted regressor (otherwis... | python | wandb/sklearn/plot/regressor.py | 15 | 52 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,653 | outlier_candidates | def outlier_candidates(regressor=None, X=None, y=None):
"""Measures a datapoint's influence on regression model via cook's distance.
Instances with high influences could potentially be outliers.
Should only be called with a fitted regressor (otherwise an error is thrown).
Please note this function fi... | python | wandb/sklearn/plot/regressor.py | 55 | 86 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,654 | residuals | def residuals(regressor=None, X=None, y=None):
"""Measures and plots the regressor's predicted value against the residual.
The marginal distribution of residuals is also calculated and plotted.
Should only be called with a fitted regressor (otherwise an error is thrown).
Please note this function fit... | python | wandb/sklearn/plot/regressor.py | 89 | 120 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,655 | clusterer | def clusterer(model, X_train, cluster_labels, labels=None, model_name="Clusterer"):
"""Generates all sklearn clusterer plots supported by W&B.
The following plots are generated:
elbow curve, silhouette plot.
Should only be called with a fitted clusterer (otherwise an error is thrown).
Argumen... | python | wandb/sklearn/plot/clusterer.py | 14 | 52 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,656 | elbow_curve | def elbow_curve(
clusterer=None, X=None, cluster_ranges=None, n_jobs=1, show_cluster_time=True
):
"""Measures and plots variance explained as a function of the number of clusters.
Useful in picking the optimal number of clusters.
Should only be called with a fitted clusterer (otherwise an error is thr... | python | wandb/sklearn/plot/clusterer.py | 55 | 94 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,657 | silhouette | def silhouette(
clusterer=None,
X=None,
cluster_labels=None,
labels=None,
metric="euclidean",
kmeans=True,
):
"""Measures & plots silhouette coefficients.
Silhouette coefficients near +1 indicate that the sample is far away from
the neighboring clusters. A value near 0 indicates tha... | python | wandb/sklearn/plot/clusterer.py | 97 | 141 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,658 | learning_curve | def learning_curve(
model,
X,
y,
cv=None,
shuffle=False,
random_state=None,
train_sizes=None,
n_jobs=1,
scoring=None,
):
"""Train model on datasets of varying size and generates plot of score vs size.
Called by plot_learning_curve to visualize learning curve. Please use the ... | python | wandb/sklearn/calculate/learning_curve.py | 13 | 46 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,659 | make_table | def make_table(train, test, train_sizes):
data = []
for i in range(len(train)):
if utils.check_against_limit(
i,
"learning_curve",
utils.chart_limit / 2,
):
break
train_set = ["train", utils.round_2(train[i]), train_sizes[i]]
test_s... | python | wandb/sklearn/calculate/learning_curve.py | 49 | 64 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,660 | class_proportions | def class_proportions(y_train, y_test, labels):
# Get the unique values from the dataset
targets = (y_train,) if y_test is None else (y_train, y_test)
class_ids = np.array(unique_labels(*targets))
# Compute the class counts
counts_train = np.array([(y_train == c).sum() for c in class_ids])
coun... | python | wandb/sklearn/calculate/class_proportions.py | 13 | 34 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,661 | make_table | def make_table(class_column, dataset_column, count_column):
columns = ["class", "dataset", "count"]
data = list(zip(class_column, dataset_column, count_column))
return wandb.Table(data=data, columns=columns) | python | wandb/sklearn/calculate/class_proportions.py | 37 | 41 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,662 | make_columns | def make_columns(class_ids, counts_train, counts_test):
class_column, dataset_column, count_column = [], [], []
for i in range(len(class_ids)):
# add class counts from training set
class_column.append(class_ids[i])
dataset_column.append("train")
count_column.append(counts_train[... | python | wandb/sklearn/calculate/class_proportions.py | 44 | 64 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,663 | get_named_labels | def get_named_labels(labels, numeric_labels):
return np.array([labels[num_label] for num_label in numeric_labels]) | python | wandb/sklearn/calculate/class_proportions.py | 67 | 68 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,664 | silhouette | def silhouette(clusterer, X, cluster_labels, labels, metric, kmeans):
# Run clusterer for n_clusters in range(len(cluster_ranges), get cluster labels
# TODO - keep/delete once we decide if we should train clusterers
# or ask for trained models
# clusterer.set_params(n_clusters=n_clusters, random_state=4... | python | wandb/sklearn/calculate/silhouette.py | 14 | 83 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,665 | make_table | def make_table(x, y, colors, centerx, centery, y_sil, x_sil, color_sil, silhouette_avg):
columns = [
"x",
"y",
"colors",
"centerx",
"centery",
"y_sil",
"x1",
"x2",
"color_sil",
"silhouette_avg",
]
data = [
[
... | python | wandb/sklearn/calculate/silhouette.py | 86 | 118 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,666 | calibration_curves | def calibration_curves(clf, X, y, clf_name):
# ComplementNB (introduced in 0.20.0) requires non-negative features
if int(sklearn.__version__.split(".")[1]) >= 20 and isinstance(
clf, naive_bayes.ComplementNB
):
X = X - X.min()
# Calibrated with isotonic calibration
isotonic = Calibr... | python | wandb/sklearn/calculate/calibration_curves.py | 16 | 98 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,667 | make_table | def make_table(
model_column,
frac_positives_column,
mean_pred_value_column,
hist_column,
edge_column,
):
columns = [
"model",
"fraction_of_positives",
"mean_predicted_value",
"hist_dict",
"edge_dict",
]
data = list(
zip(
model... | python | wandb/sklearn/calculate/calibration_curves.py | 101 | 126 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,668 | outlier_candidates | def outlier_candidates(regressor, X, y):
# Fit a linear model to X and y to compute MSE
regressor.fit(X, y)
# Leverage is computed as the diagonal of the projection matrix of X
leverage = (X * np.linalg.pinv(X).T).sum(1)
# Compute the rank and the degrees of freedom of the OLS model
rank = np.... | python | wandb/sklearn/calculate/outlier_candidates.py | 12 | 51 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,669 | make_table | def make_table(distance, outlier_percentage, influence_threshold):
columns = [
"distance",
"instance_indicies",
"outlier_percentage",
"influence_threshold",
]
data = [
[distance[i], i, utils.round_3(outlier_percentage), influence_threshold]
for i in range(len... | python | wandb/sklearn/calculate/outlier_candidates.py | 54 | 69 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,670 | residuals | def residuals(regressor, X, y):
# Create the train and test splits
X_train, X_test, y_train, y_test = model_selection.train_test_split(
X, y, test_size=0.2
)
# Store labels and colors for the legend ordered by call
regressor.fit(X_train, y_train)
train_score_ = regressor.score(X_train, ... | python | wandb/sklearn/calculate/residuals.py | 12 | 39 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,671 | make_table | def make_table(
y_pred_train,
residuals_train,
y_pred_test,
residuals_test,
train_score_,
test_score_,
):
y_pred_column, dataset_column, residuals_column = [], [], []
datapoints, max_datapoints_train = 0, 100
for pred, residual in zip(y_pred_train, residuals_train):
# add cl... | python | wandb/sklearn/calculate/residuals.py | 42 | 86 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,672 | decision_boundaries | def decision_boundaries(
decision_boundary_x,
decision_boundary_y,
decision_boundary_color,
train_x,
train_y,
train_color,
test_x,
test_y,
test_color,
):
x_dict, y_dict, color_dict = [], [], []
for i in range(min(len(decision_boundary_x), 100)):
x_dict.append(decision... | python | wandb/sklearn/calculate/decision_boundaries.py | 9 | 40 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,673 | elbow_curve | def elbow_curve(clusterer, X, cluster_ranges, n_jobs, show_cluster_time):
if cluster_ranges is None:
cluster_ranges = range(1, 10, 2)
else:
cluster_ranges = sorted(cluster_ranges)
clfs, times = _compute_results_parallel(n_jobs, clusterer, X, cluster_ranges)
clfs = np.absolute(clfs)
... | python | wandb/sklearn/calculate/elbow_curve.py | 14 | 27 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,674 | make_table | def make_table(cluster_ranges, clfs, times):
columns = ["cluster_ranges", "errors", "clustering_time"]
data = list(zip(cluster_ranges, clfs, times))
table = wandb.Table(columns=columns, data=data)
return table | python | wandb/sklearn/calculate/elbow_curve.py | 30 | 37 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,675 | _compute_results_parallel | def _compute_results_parallel(n_jobs, clusterer, X, cluster_ranges):
parallel_runner = Parallel(n_jobs=n_jobs)
_cluster_scorer = delayed(_clone_and_score_clusterer)
results = parallel_runner(_cluster_scorer(clusterer, X, i) for i in cluster_ranges)
clfs, times = zip(*results)
return clfs, times | python | wandb/sklearn/calculate/elbow_curve.py | 40 | 47 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,676 | _clone_and_score_clusterer | def _clone_and_score_clusterer(clusterer, X, n_clusters):
start = time.time()
clusterer = clone(clusterer)
setattr(clusterer, "n_clusters", n_clusters)
return clusterer.fit(X).score(X), time.time() - start | python | wandb/sklearn/calculate/elbow_curve.py | 50 | 55 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,677 | summary_metrics | def summary_metrics(model=None, X=None, y=None, X_test=None, y_test=None):
"""Calculate summary metrics for both regressors and classifiers.
Called by plot_summary_metrics to visualize metrics. Please use the function
plot_summary_metrics() if you wish to visualize your summary metrics.
"""
y, y_te... | python | wandb/sklearn/calculate/summary_metrics.py | 13 | 53 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,678 | make_table | def make_table(metrics, model_name):
columns = ["metric_name", "metric_value", "model_name"]
table_content = [[name, value, model_name] for name, value in metrics.items()]
table = wandb.Table(columns=columns, data=table_content)
return table | python | wandb/sklearn/calculate/summary_metrics.py | 56 | 62 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,679 | feature_importances | def feature_importances(model, feature_names):
attributes_to_check = ["feature_importances_", "feature_log_prob_", "coef_"]
found_attribute = check_for_attribute_on(model, attributes_to_check)
if found_attribute is None:
wandb.termwarn(
f"could not find any of attributes {', '.join(attri... | python | wandb/sklearn/calculate/feature_importances.py | 11 | 52 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,680 | make_table | def make_table(feature_names, importances):
table = wandb.Table(
columns=["feature_names", "importances"],
data=[[feature_names[i], importances[i]] for i in range(len(feature_names))],
)
return table | python | wandb/sklearn/calculate/feature_importances.py | 55 | 60 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,681 | check_for_attribute_on | def check_for_attribute_on(model, attributes_to_check):
for attr in attributes_to_check:
if hasattr(model, attr):
return attr
return None | python | wandb/sklearn/calculate/feature_importances.py | 63 | 67 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,682 | validate_labels | def validate_labels(*args, **kwargs): # FIXME
assert False | python | wandb/sklearn/calculate/confusion_matrix.py | 15 | 16 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,683 | confusion_matrix | def confusion_matrix(
y_true=None,
y_pred=None,
labels=None,
true_labels=None,
pred_labels=None,
normalize=False,
):
"""Compute the confusion matrix to evaluate the performance of a classification.
Called by plot_confusion_matrix to visualize roc curves. Please use the function
plot... | python | wandb/sklearn/calculate/confusion_matrix.py | 19 | 67 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,684 | make_table | def make_table(cm, pred_classes, true_classes, labels):
data, count = [], 0
for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
if labels is not None and (
isinstance(pred_classes[i], int) or isinstance(pred_classes[0], np.integer)
):
pred = labels[pred... | python | wandb/sklearn/calculate/confusion_matrix.py | 70 | 92 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,685 | __init__ | def __init__(self):
object.__setattr__(self, "_items", dict())
object.__setattr__(self, "_locked", dict())
object.__setattr__(self, "_users", dict())
object.__setattr__(self, "_users_inv", dict())
object.__setattr__(self, "_users_cnt", 0)
object.__setattr__(self, "_callba... | python | wandb/sdk/wandb_config.py | 95 | 105 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,686 | _set_callback | def _set_callback(self, cb):
object.__setattr__(self, "_callback", cb) | python | wandb/sdk/wandb_config.py | 107 | 108 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,687 | _set_artifact_callback | def _set_artifact_callback(self, cb):
object.__setattr__(self, "_artifact_callback", cb) | python | wandb/sdk/wandb_config.py | 110 | 111 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,688 | _set_settings | def _set_settings(self, settings):
object.__setattr__(self, "_settings", settings) | python | wandb/sdk/wandb_config.py | 113 | 114 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,689 | __repr__ | def __repr__(self):
return str(dict(self)) | python | wandb/sdk/wandb_config.py | 116 | 117 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,690 | keys | def keys(self):
return [k for k in self._items.keys() if not k.startswith("_")] | python | wandb/sdk/wandb_config.py | 119 | 120 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,691 | _as_dict | def _as_dict(self):
return self._items | python | wandb/sdk/wandb_config.py | 122 | 123 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,692 | as_dict | def as_dict(self):
# TODO: add telemetry, deprecate, then remove
return dict(self) | python | wandb/sdk/wandb_config.py | 125 | 127 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,693 | __getitem__ | def __getitem__(self, key):
return self._items[key] | python | wandb/sdk/wandb_config.py | 129 | 130 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,694 | _check_locked | def _check_locked(self, key, ignore_locked=False) -> bool:
locked = self._locked.get(key)
if locked is not None:
locked_user = self._users_inv[locked]
if not ignore_locked:
wandb.termwarn(
"Config item '%s' was locked by '%s' (ignored update)."... | python | wandb/sdk/wandb_config.py | 132 | 142 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,695 | __setitem__ | def __setitem__(self, key, val):
if self._check_locked(key):
return
with wandb.sdk.lib.telemetry.context() as tel:
tel.feature.set_config_item = True
self._raise_value_error_on_nested_artifact(val, nested=True)
key, val = self._sanitize(key, val)
self._ite... | python | wandb/sdk/wandb_config.py | 144 | 154 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,696 | items | def items(self):
return [(k, v) for k, v in self._items.items() if not k.startswith("_")] | python | wandb/sdk/wandb_config.py | 156 | 157 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,697 | __getattr__ | def __getattr__(self, key):
try:
return self.__getitem__(key)
except KeyError as ke:
raise AttributeError(
f"{self.__class__!r} object has no attribute {key!r}"
) from ke | python | wandb/sdk/wandb_config.py | 161 | 167 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,698 | __contains__ | def __contains__(self, key):
return key in self._items | python | wandb/sdk/wandb_config.py | 169 | 170 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,699 | _update | def _update(self, d, allow_val_change=None, ignore_locked=None):
parsed_dict = wandb_helper.parse_config(d)
locked_keys = set()
for key in list(parsed_dict):
if self._check_locked(key, ignore_locked=ignore_locked):
locked_keys.add(key)
sanitized = self._saniti... | python | wandb/sdk/wandb_config.py | 172 | 182 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,700 | update | def update(self, d, allow_val_change=None):
sanitized = self._update(d, allow_val_change)
if self._callback:
self._callback(data=sanitized) | python | wandb/sdk/wandb_config.py | 184 | 187 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.