Skip to content

Feat/stochastic gradient descent - #1067

Open
Indrapal-70 wants to merge 3 commits into
TheAlgorithms:masterfrom
Indrapal-70:feat/stochastic-gradient-descent
Open

Feat/stochastic gradient descent#1067
Indrapal-70 wants to merge 3 commits into
TheAlgorithms:masterfrom
Indrapal-70:feat/stochastic-gradient-descent

Conversation

@Indrapal-70

Copy link
Copy Markdown

Pull Request Template

Description

This PR implements Stochastic Gradient Descent (SGD) under src/machine_learning/optimization/stochastic_gradient_descent.rs, addressing issue #578 ("Suggestion: Add optimization functions, ml algorithms under machine_learning folder").

Algorithm Overview

Stochastic Gradient Descent is an iterative optimization algorithm used to find the minimum of an objective function. Unlike batch gradient descent (which computes the loss gradient over the entire dataset before making a single update), SGD updates parameters incrementally after evaluating the gradient for each individual training sample.

For a parameter vector x and sample d_i, the update equation is:

x_{k+1} = x_k - learning_rate * gradient(x_k, d_i)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I ran below commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked CONTRIBUTING.md and my code follows its guidelines.

@Indrapal-70
Indrapal-70 requested a review from imp2002 as a code owner August 27, 2026 21:38
@codecov-commenter

codecov-commenter commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.90%. Comparing base (2345c66) to head (028d10a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1067      +/-   ##
==========================================
+ Coverage   95.89%   95.90%   +0.01%     
==========================================
  Files         396      397       +1     
  Lines       30440    30541     +101     
==========================================
+ Hits        29191    29291     +100     
- Misses       1249     1250       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants