Giter VIP home page Giter VIP logo

knearest_neighbour_java's Introduction

kNearest_Neighbour_Java

Here is some code for k-Nearest Neighbour algorithm in Java and works with datasets containing numeric input attributes. For this task I used the breast cancer dataset provided. The dataset contains real data related to patients which had a breast tumour which has been classified as malign (cancerous) or benign (non-cancerous). The dataset has the following attributes:

PID is the patient id. CLUMP_THICKNESS, CELL_SIZE, CELL_SHAPE, MARG_ADESION, EPIT_CELL_SIZE, BARE_NUCLEI, BLAND_CHROM, N_NUCLEOLI, MITOSES are input attributes whose values are numeric and indicate various measures related to the tumour's cells. CLASS is the output attribute with the values benign and malign.

The dataset was randomly split in a training dataset containing 70% of the data, and a test dataset containing 30% of the data, and then the rows containing missing values were removed to simplify this task. The code reads from the keyboard the number of nearest neighbours k. The code also reads the training and the test dataset files, and rescale's the numeric input attributes to make sure there is no bias in their contribution to the distances computed in the k-Nearest Neighbour algorithm.

The code then classifies any patients from the test dataset using the k-nearest neighbour algorithm. The code then saves the test dataset and the computed classes for these patients in a comma separated values file called predictions.csv. Moreover, the code computes and displays on the screen the value of k, and the confusion matrix and the following performance indicators: accuracy, sensitivity, precision and specificity with respect to the class 'malign'.

knearest_neighbour_java's People

Watchers

James Cloos avatar Conor Okus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.