TheAlgorithms / TheAlgorithms/Java
[FEATURE REQUEST] Add Perceptron binary classifier
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 66.3k
- フォーク
- 21.3k
- 平均マージ
- 16時間 57分
- マージ済み PR(30日)
- 23
説明
What would you like to Propose?
Add a Perceptron classifier to src/main/java/com/thealgorithms/machinelearning. The Perceptron is the simplest neural network and would provide an educational binary linear-classification algorithm alongside the existing LinearRegression, KNearestNeighbors, and MultinomialNaiveBayesClassifier implementations.
Issue details
Algorithm name: Perceptron
Problem statement: Given a set of feature vectors and binary class labels, learn a linear decision boundary using the Perceptron learning rule, then classify previously unseen samples. The implementation should make the bias term explicit and document that convergence is guaranteed only for linearly separable data.
Suggested scope:
- Add
Perceptron.javain the machinelearning package. - Use only the Java standard library; no external machine-learning dependency is needed.
- Provide a small, clear API for fitting, predicting one sample, and predicting a batch.
- Support configurable learning rate and maximum epochs, with deterministic zero-weight and zero-bias initialization.
- Validate null or empty data, inconsistent feature dimensions, invalid labels, and invalid hyperparameters with clear exceptions.
- Document the update rule, label convention, and limitations in Javadoc.
Acceptance tests:
- Train on a linearly separable toy dataset such as AND or OR and classify all training samples correctly.
- Verify predictions for unseen samples and batch prediction.
- Verify that prediction before fitting fails clearly.
- Verify invalid labels, mismatched dimensions, null or empty input, and invalid learning-rate or epoch values.
- Include a non-separable-data test that checks documented behavior, such as stopping after the epoch limit without claiming convergence.
A historical pull request, #187, attempted a Perceptron implementation in 2018, but there is no current implementation in the package. This request is for a current Java 21 implementation with tests that follow the repository conventions.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず src/main/java/com/thealgorithms/machinelearning 配下にある既存の LinearRegression、KNearestNeighbors、MultinomialNaiveBayesClassifier の実装を読み、次に背景を把握するために過去の pull request を確認してください。リポジトリの規約に従ったテストとともに Perceptron.java を追加してください。分離可能なデータ、未知のデータおよびバッチに対する予測、fit 前および無効な入力に対する失敗、そして文書化された非分離データの動作がすべて機能すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- machine-learning
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 78/100