0% found this document useful (0 votes)
6 views1 page

AdaSampling for Noisy BRCA Data Analysis

The document loads breast cancer data and introduces noise to create a noisy dataset. It then applies the AdaSampling method to the noisy data using a k-nearest neighbors classifier to clean the labels and calculates the original and improved accuracies.

Uploaded by

ABC DEF
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

AdaSampling for Noisy BRCA Data Analysis

The document loads breast cancer data and introduces noise to create a noisy dataset. It then applies the AdaSampling method to the noisy data using a k-nearest neighbors classifier to clean the labels and calculates the original and improved accuracies.

Uploaded by

ABC DEF
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# Load the example dataset

data(brca)
head(brca)
# First, clean up the dataset to transform into the required format.
[Link] <- apply(X = brca[,-10], MARGIN = 2, FUN = [Link])
[Link] <- sapply(X = brca$cla, FUN = function(x) {ifelse(x == "malignant", 1,
0)})
rownames([Link]) <- paste("p", 1:nrow([Link]), sep="_")
# Introduce 40% noise to positive class and 30% noise to the negative class
[Link](1)
pos <- which([Link] == 1)
neg <- which([Link] == 0)
[Link] <- [Link]
[Link][sample(pos, floor(length(pos) * 0.4))] <- 0
[Link][sample(neg, floor(length(neg) * 0.3))] <- 1
# Identify positive and negative examples from the noisy dataset
Ps <- rownames([Link])[which([Link] == 1)]
Ns <- rownames([Link])[which([Link] == 0)]
# Apply AdaSampling method on the noisy data
[Link] <- adaSample(Ps, Ns, [Link]=[Link], [Link]=[Link], classifier =
"knn")
head([Link])
# Orignal accuracy from the labels
accuracy <- sum([Link] == [Link]) / length([Link])
accuracy
# Accuracy after applying AdaSampling method
accuracyWithAdaSample <- sum(ifelse([Link][,"P"] > 0.5, 1, 0) == [Link]) /
length([Link])
accuracyWithAdaSample

You might also like