The README screenshot showcases a LinearRegression implementation - Python on the left, C# on the right.
This is what NumSharp was built for: enabling near-identical code translation from Python to C#.

What This Demonstrates
The screenshot proves NumSharp's core promise: you can take NumPy code and translate it to C# with minimal changes:
| Python/NumPy |
C#/NumSharp |
np.hstack(...) |
np.hstack(...) |
np.mean(X, 0) |
np.mean(X, 0) |
np.std(X, 0) |
np.std(X, 0) |
np.expand_dims(y, -1) |
np.expand_dims(y, -1) |
np.zeros(...) |
np.zeros(...) |
X @ self.params |
np.matmul(X, @params) |
(y - y_pred)**2 |
np.power(y - y_pred, 2) |
The entire LinearRegression class - constructor, fit(), score(), and predict() methods - translates almost 1-to-1.
Achievement Unlocked 🏆
This example should be preserved, tested, and maintained as a canonical demonstration of NumSharp's capabilities.
Tasks
The README screenshot showcases a LinearRegression implementation - Python on the left, C# on the right.
This is what NumSharp was built for: enabling near-identical code translation from Python to C#.
What This Demonstrates
The screenshot proves NumSharp's core promise: you can take NumPy code and translate it to C# with minimal changes:
np.hstack(...)np.hstack(...)np.mean(X, 0)np.mean(X, 0)np.std(X, 0)np.std(X, 0)np.expand_dims(y, -1)np.expand_dims(y, -1)np.zeros(...)np.zeros(...)X @ self.paramsnp.matmul(X, @params)(y - y_pred)**2np.power(y - y_pred, 2)The entire
LinearRegressionclass - constructor,fit(),score(), andpredict()methods - translates almost 1-to-1.Achievement Unlocked 🏆
This example should be preserved, tested, and maintained as a canonical demonstration of NumSharp's capabilities.
Tasks
LinearRegressionexample to test suite to ensure it never breaks