warming up your workspace

R practice in Machine Learning

Browse the rooms before signing in. Opening a room requires an account and follows your existing access. Practice does not issue certificates.

  • Code the Categories

    For non-missing character x, return integer positions in sort(unique(x)), preserving observation order. Empty x gives integer(0). This is label encoding, not an ordinal low/medium/high ordering.

    encoding. Free room.

  • Fill the Holes

    For numeric x with at least one finite observation and optional NA/NaN gaps, replace only the gaps with the observed mean. Preserve length, values already present, order and names. This operation fits on x, so use it on training data.

    missing. Free room.

  • Hold Out the Test

    For nonnegative integer n, return floor(n*0.2). The test fraction is fixed at twenty percent. Return a count only; this function does not sample row identities or guarantee nonempty train/test sets.

    split. Free room.

  • Level the Features

    For finite x with at least two observations and positive sample sd, return (x-mean(x))/sd(x) in input order. Fit on training data; no constant-column guarantee is implied by this formula.

    scaling. Free room.

  • Count the Votes

    For nonempty non-missing character labels, return the most frequent label as a character scalar. On equal counts, take the first level in table order.

    classify. Account access required.

  • Measure the Distance

    Return the scalar Euclidean distance from the origin to b. Use finite coordinates at representable arithmetic magnitudes. Accept any nonempty coordinate vector.

    distance. Account access required.

  • Smooth the Counts

    For a nonempty vector of finite nonnegative token counts in a fixed vocabulary, return (counts+1)/(sum(counts)+length(counts)). Keep the same order and names. All-zero counts give a uniform distribution.

    smoothing. Account access required.

  • Weigh the Neighbors

    For finite nonnegative distances, return 1/(dists+1e-9) in order. These weights are not normalized. Zero distance gives a large finite weight, not an exclusive exact-match rule.

    weighted. Account access required.

  • Measure a Cluster Assignment Cost

    Return scalar squared Euclidean distance from the origin to finite coordinates b with representable squared sum. Accept any nonempty coordinate vector. This cost alone does not assign a cluster.

    assign. Account access required.

  • Find the Elbow

    For at least three finite nonnegative inertias corresponding to consecutive k=1..length(inertias), return which.max(diff(diff(inertias)))+1. Ties select the first position; even a flat second-difference curve returns a position. This is a heuristic, not an optimum guarantee.

    choosing. Account access required.

  • Rate the Learner

    For a finite weighted error err strictly between zero and one, return 0.5*log((1-err)/err). The value is positive below 0.5, zero at 0.5 and negative above. A full trainer must separately handle perfect-learner stopping.

    adaboost. Account access required.

  • Score the Split

    For nonempty non-missing character labels, return 1 minus the sum of squared empirical class fractions. This is the impurity of one group, not the complete score of a proposed split.

    impurity. Account access required.

  • Merge the Clusters

    For nonempty finite nonnegative cross containing all cross-cluster distances, return its minimum. Duplicate observations may make this zero. This helper calculates a distance; it does not merge a hierarchy.

    linkage. Account access required.

  • Rank the Components

    For finite nonnegative eigenvalues ev with positive total, return ev/sum(ev), preserving order. A descending input remains descending; the operation does not sort or fit PCA.

    howmany. Account access required.

  • Score the Model

    For a 2-by-2 nonnegative finite confusion matrix M with positive total, return sum(diag(M))/sum(M). Rows are predicted positive/negative and columns actual positive/negative: [[TP,FP],[FN,TN]].

    confusion. Account access required.

  • Spread the Variance

    For a finite numeric matrix X with at least two rows and one feature, return the sum of sample feature variances, equivalently sum(diag(cov(X))). Constant features contribute zero.

    covariance. Account access required.

  • Average the Folds

    For a nonempty finite vector of fold scores, return its unweighted arithmetic mean. Each fold gets equal weight, which differs from pooled row accuracy for unequal fold sizes.

    crossval. Account access required.

  • Apply Illustrative Accuracy Bands

    For finite accuracy acc in [0,1], return "strong" at >=0.90, "acceptable" at >=0.75, otherwise "weak". Compare the raw value before rounding. These are illustrative bands, not deployment judgments; this task does not execute a pipeline.

    evaluate. Account access required.

  • Apply One ROC Threshold

    For finite scores, return integer labels using the fixed inclusive threshold 0.5. Larger scores mean more positive evidence. Empty input gives integer(0). This is one operating point, not a full ROC curve.

    roc. Account access required.

  • Measure the AUC

    Take exactly four finite scores whose fixed truth is c(0,0,1,1). Return the mean credit across all four positive-negative pairs: one for positive greater, half for equal, zero otherwise. Scores need not be probabilities.

    roc. Account access required.