Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Load Data
- load fisheriris;
- %The variable meas contains measurements on the sepal length, sepal width,
- %petal length, and petal width for 150 iris specimens from the
- %following three species :
- labels = unique(species);
- disp(labels);
- %Train a Linear Discriminant Analysis (LDA) Classifier
- mdl = ClassificationDiscriminant.fit(meas,species);
- %Predict Species Using the LDA Model
- predicted_species = predict(mdl,meas);
- %Compute and Visualize the Confusion Matrix
- Conf_Mat = confusionmat(species,predicted_species);
- disp(Conf_Mat);
- %We can visualize the same using a heat map.
- h = heatmap(Conf_Mat);
- confMat=Conf_Mat;
- %%% précision
- for i =1:size(confMat,1)
- precision(i)=confMat(i,i)/sum(confMat(:,i));
- end
- Precision=sum(precision)/size(confMat,1);
- disp(Precision);
- %%% recall
- for i =1:size(confMat,1)
- recall(i)=confMat(i,i)/sum(confMat(i,:));
- end
- Recall=sum(recall)/size(confMat,1);
- disp(Recall);
- %%% F-score
- F_score=2*Recall*Precision/(Precision+Recall); %%F_score=2*1/((1/Precision)+(1/Recall));
- disp(F_score);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement