feat: add ml/base/loss/float64/hinge#11953
Open
nakul-krishnakumar wants to merge 4 commits intostdlib-js:developfrom
Open
feat: add ml/base/loss/float64/hinge#11953nakul-krishnakumar wants to merge 4 commits intostdlib-js:developfrom
ml/base/loss/float64/hinge#11953nakul-krishnakumar wants to merge 4 commits intostdlib-js:developfrom
Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: passed
- task: lint_c_benchmarks
status: passed
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
Contributor
Coverage ReportNo coverage information available. |
Member
Author
|
Clarifications required:
|
Member
Author
|
/stdlib update-copyright-years |
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: passed
- task: lint_c_benchmarks
status: passed
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
kgryte
reviewed
May 5, 2026
| * limitations under the License. | ||
| */ | ||
|
|
||
| #ifndef STDLIB_ML_BASE_FLOAT64_HINGE_H |
Member
There was a problem hiding this comment.
Suggested change
| #ifndef STDLIB_ML_BASE_FLOAT64_HINGE_H | |
| #ifndef STDLIB_ML_BASE_LOSS_FLOAT64_HINGE_H |
Guards need to match the package name, NOT the function name. Applies here and below.
kgryte
reviewed
May 5, 2026
| // MAIN // | ||
|
|
||
| /** | ||
| * Computes the hinge loss between two double-precision floating-point number. |
Member
There was a problem hiding this comment.
Suggested change
| * Computes the hinge loss between two double-precision floating-point number. | |
| * Computes the hinge loss between two double-precision floating-point numbers. |
kgryte
reviewed
May 5, 2026
Comment on lines
+62
to
+65
| if ( isnan( y ) || isnan( p ) ) { | ||
| return NaN; | ||
| } | ||
| if ( y !== -1.0 && y !== 1.0 ) { |
Member
There was a problem hiding this comment.
Suggested change
| if ( isnan( y ) || isnan( p ) ) { | |
| return NaN; | |
| } | |
| if ( y !== -1.0 && y !== 1.0 ) { | |
| if ( isnan( y ) || isnan( p ) || y !== -1.0 && y !== 1.0 ) { |
kgryte
reviewed
May 5, 2026
| // MAIN // | ||
|
|
||
| /** | ||
| * Computes the hinge loss between two double-precision floating-point number. |
Member
There was a problem hiding this comment.
Suggested change
| * Computes the hinge loss between two double-precision floating-point number. | |
| * Computes the hinge loss between two double-precision floating-point numbers. |
Applies here and throughout this PR.
kgryte
reviewed
May 5, 2026
Comment on lines
+36
to
+39
| if ( stdlib_base_is_nan( y ) || stdlib_base_is_nan( p ) ) { | ||
| return STDLIB_CONSTANT_FLOAT64_NAN; | ||
| } | ||
| if ( y != -1.0 && y != 1.0 ) { |
Member
There was a problem hiding this comment.
Suggested change
| if ( stdlib_base_is_nan( y ) || stdlib_base_is_nan( p ) ) { | |
| return STDLIB_CONSTANT_FLOAT64_NAN; | |
| } | |
| if ( y != -1.0 && y != 1.0 ) { | |
| if ( stdlib_base_is_nan( y ) || stdlib_base_is_nan( p ) || y != -1.0 && y != 1.0 ) { |
kgryte
reviewed
May 5, 2026
| if ( y != -1.0 && y != 1.0 ) { | ||
| return STDLIB_CONSTANT_FLOAT64_NAN; | ||
| } | ||
| return stdlib_base_max( 0, 1 - ( y*p ) ); |
Member
There was a problem hiding this comment.
Suggested change
| return stdlib_base_max( 0, 1 - ( y*p ) ); | |
| return stdlib_base_max( 0.0, 1.0 - ( y*p ) ); |
Floating-point values should have decimals; otherwise, you force implicit casts.
kgryte
reviewed
May 5, 2026
| if ( y !== -1.0 && y !== 1.0 ) { | ||
| return NaN; | ||
| } | ||
| return max( 0, 1 - ( y*p ) ); |
Member
There was a problem hiding this comment.
Suggested change
| return max( 0, 1 - ( y*p ) ); | |
| return max( 0.0, 1.0 - ( y*p ) ); |
kgryte
reviewed
May 5, 2026
| Computes the hinge loss between two double-precision floating-point number. | ||
|
|
||
| If either argument is `NaN`, the function returns `NaN`. | ||
| If `y` is not +1 or -1, the function returns `NaN`. |
Member
There was a problem hiding this comment.
Suggested change
| If `y` is not +1 or -1, the function returns `NaN`. | |
| If `y` is not +1 or -1, the function returns `NaN`. |
kgryte
reviewed
May 5, 2026
| hinge( 1.0, ( x: number ): number => x ); // $ExpectError | ||
| } | ||
|
|
||
| // The compiler throws an error if the function is provided insufficient arguments... |
Member
There was a problem hiding this comment.
Suggested change
| // The compiler throws an error if the function is provided insufficient arguments... | |
| // The compiler throws an error if the function is provided an unsupported number of arguments... |
kgryte
reviewed
May 5, 2026
Comment on lines
+97
to
+99
| return 1; | ||
| } | ||
| return -1; |
Member
There was a problem hiding this comment.
Suggested change
| return 1; | |
| } | |
| return -1; | |
| return 1.0; | |
| } | |
| return -1.0; |
Avoid implicit casts.
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: passed
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves None.
Description
This pull request:
ml/base/loss/float64/hinge.Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
None.
@stdlib-js/reviewers