Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Machine Learning · Learn / Refresh

← Classification lessons
Margins and rules · ML-C-R2 · 15–20 MIN

Neighbours, margins and rules retrieval

  1. Retrieval 1Compute and inspect the evidenceCurrent exercise
  2. Retrieval 2Compute and inspect the evidence
  3. Retrieval 3Apply the taught distinction

Supplied for this practice

These objects are prepared afresh before your editor runs.

query_id
Supplied query_id; its definition below specifies the values and role.
query_id = 117

Outputs you create

answer
  1. The requested result, with the values, labels and row order described by this task.
Exercise evidence · ML-C-R2-1 · all 4 rows
case_idxlabel
1172A
811A
963B
634B
Your task
  1. Remove the query case from the supplied fitting table into answer before fitting or learning a scale.
  2. Keep its row ID as the table index.
answer
Hints

Think: Removing a self-match only from the displayed neighbour list would not repair the original fit. Fit preparation and the classifier on the separated fitting rows.

Tools: Neighbours, margins and rules retrieval: use the supplied case_id, x, label columns and the pandas or model operations introduced in this lesson.

Approach: Compute answer from the supplied evidence. Preserve the requested labels and row order, then inspect the values before checking.

Explained solution
answer = df.loc[df['case_id'] != query_id].set_index('case_id')
print(answer)

Removing a self-match only from the displayed neighbour list would not repair the original fit. Fit preparation and the classifier on the separated fitting rows.

Ctrl/⌘+Enter: Run · Tab: indent · Esc then Tab: leave editor

Python loads when you run. Code and results stay in this activity only.

Run your code to inspect its output. Check uses that same run.