• Verkeerd document? Gratis ruilen
  • Geschreven door studenten die geslaagd zijn
  • Direct beschikbaar na je betaling
  • Online lezen of als PDF
Verkopen
Kies je studieland
Kies je taal
Document preview thumbnail
Voorbeeld 2 van de 11 pagina's
Samenvatting

Practical 5.1: Advanced Data Analysis: full summary + explanations

Document preview thumbnail
Voorbeeld 2 van de 11 pagina's

PART 1 of Practical 5: Advanced Data Analysis: full summary + explanations, screenshots and answers to questions

Voorbeeld van de inhoud

Supervised classification with Decision Trees
and Random Forests

1 The Breast Cancer dataset
This dataset contains features regarding images of malignant and benign
breast tumors. There are ten continuous features that describe the size and
shape of each tumor. These are a) radius (mean of distances from center to
points on the perimeter) b) texture (standard deviation of gray-scale values)
c) perimeter d) area e) smoothness (local variation in radius lengths) f)
compactness (perimeter
/ area - 1.0) g) concavity (severity of concave portions of the contour) h) con-
cave points (number of concave portions of the contour) i) symmetry j) fractal
dimension ("coastline approximation" - 1).

The goal of this dataset will be to use to provided features to predict if a
sample is malignant (M) or benign (B). The dataset has been split up into
a training data set and a test data set. We can read in the dataset with the
following command:
cancer.train<-read.csv(file="breast-cancer-
train.csv",header=TRUE,stringsAsFactors=T)
cancer.test<-read.csv(file="breast-cancer-
test.csv",header=TRUE,stringsAsFactors=T)
summary(cancer.train)


2 Decision tree
We will use the ’rpart’ R package to learn and apply our decision trees. Install
it from CRAN if you have not already done so. We can load in the library with
the standard command:
library(rpart) library(rpart.plot)
We then need to apply it to the breast cancer dataset. One of the standard
optimizations that is part of the rpart() function is to optimize the number
of branches to include in the decision tree. The more branches, the higher the
chance to overfit, but we need some branches to solve our classification problem.
It does this by running an internal cross-validation, where part of the training
data is held out to validate, to optimize this branch parameter.
tree <-
rpart(diagnosis~.,data=cancer.train,method="class")
#Overview of the optimization
printcp(tree)




1

, #CV optimization of branch
number plotcp(tree)




We needed to set our method to "class" for classification. Now that we have
an optimal decision tree for classification, we can visualize it by using the
following command:
rpart.plot(tree,main="Decision Tree for Cancer Dataset")
This gives a clear overview of the features that are being used in the decision
tree.




2

Documentinformatie

Geüpload op
5 mei 2023
Aantal pagina's
11
Geschreven in
2021/2022
Type
Samenvatting
€4,99

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kan je een ander document kiezen. Je kan het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
Bi0med
4,2
(61)
Verkocht
572
Volgers
202
Items
90
Laatst verkocht
1 maand geleden



Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen