Skip to content

tamilatiurina/PerceptronProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Perceptron Classifier (Iris Data)

This is a simple Java implementation of a Perceptron binary classifier trained to distinguish between two Iris species: Iris-versicolor and Iris-virginica. It reads training and test data from CSV files and allows users to evaluate accuracy or classify custom vectors.

πŸ›  How It Works

  • A Parceptron class handles training, weight updates, and predictions using the perceptron learning algorithm.
  • The Main class:
    • Loads data from CSV files.
    • Trains the perceptron.
    • Provides a CLI menu to evaluate accuracy or classify a user-defined vector.

πŸ“ Dataset Format

Each line in the CSV should be:

sepal_length,sepal_width,petal_length,petal_width,class_label
  • Last column must be either Iris-versicolor or Iris-virginica.

Example:

6.3,2.8,5.1,1.5,Iris-virginica
5.7,2.8,4.1,1.3,Iris-versicolor

πŸš€ How to Run

  1. Compile the code:
javac Main.java Parceptron.java
  1. Run with training and test files:
java Main iris_train.csv iris_test.csv
  1. CLI Options:
  • 0 β†’ Show accuracy on test set
  • 1 β†’ Manually classify a new vector
  • 2 β†’ Exit program

🧠 Example Manual Classification

After selecting 1 in the CLI:

Type vector's dimension:
4
Type coordinate:
6.1
Type coordinate:
2.9
Type coordinate:
4.7
Type coordinate:
1.4
Vector is classified to class Iris-versicolor

βœ… Notes

  • The perceptron uses a fixed learning rate (0.01) and number of epochs (500).
  • Bias and weights are initialized randomly.
  • File path must be relative to src/ directory.

Enjoy experimenting with machine learning in Java!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages