simple-regression-nadjib 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: simple-regression-nadjib
3
+ Version: 0.1.0
4
+ Summary: Simple Linear Regression package built from scratch
5
+ Author: Your Name
6
+ Requires-Python: >=3.6
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.txt
9
+ Dynamic: author
10
+ Dynamic: description
11
+ Dynamic: description-content-type
12
+ Dynamic: license-file
13
+ Dynamic: requires-python
14
+ Dynamic: summary
15
+
16
+ # Simple Linear Regression Package
17
+
18
+ A pure Python implementation of Simple Linear Regression built from scratch.
19
+
20
+ ## Usage
21
+ ```python
22
+ from simple_regression import SimpleLinearRegression
23
+
24
+ X = [1, 2, 3, 4, 5]
25
+ y = [2, 4, 5, 4, 5]
26
+
27
+ model = SimpleLinearRegression()
28
+ model.fit(X, y)
29
+ print(model.predict([6, 7]))
@@ -0,0 +1,14 @@
1
+ # Simple Linear Regression Package
2
+
3
+ A pure Python implementation of Simple Linear Regression built from scratch.
4
+
5
+ ## Usage
6
+ ```python
7
+ from simple_regression import SimpleLinearRegression
8
+
9
+ X = [1, 2, 3, 4, 5]
10
+ y = [2, 4, 5, 4, 5]
11
+
12
+ model = SimpleLinearRegression()
13
+ model.fit(X, y)
14
+ print(model.predict([6, 7]))
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ setup(
4
+ name="simple-regression-nadjib", # Unique name on PyPI
5
+ version="0.1.0",
6
+ author="Your Name",
7
+ description="Simple Linear Regression package built from scratch",
8
+ long_description=open("README.md").read(),
9
+ long_description_content_type="text/markdown",
10
+ packages=find_packages(),
11
+ install_requires=[],
12
+ python_requires=">=3.6",
13
+ )
@@ -0,0 +1,3 @@
1
+ from .model import SimpleLinearRegression
2
+
3
+ __all__ = ["SimpleLinearRegression"]
@@ -0,0 +1,38 @@
1
+ class SimpleLinearRegression:
2
+
3
+ def __init__(self):
4
+ self.slope = None
5
+ self.intercept = None
6
+
7
+ def fit(self, X, y):
8
+ if len(X) != len(y) or len(X) == 0:
9
+ raise ValueError("X and y must be non-empty and of equal length.")
10
+
11
+ n = len(X)
12
+ mean_x = sum(X) / n
13
+ mean_y = sum(y) / n
14
+
15
+ numerator = sum((X[i] - mean_x) * (y[i] - mean_y) for i in range(n))
16
+ denominator = sum((X[i] - mean_x) ** 2 for i in range(n))
17
+
18
+ if denominator == 0:
19
+ raise ValueError(
20
+ "Variance of X is zero; cannot compute line of best fit."
21
+ )
22
+
23
+ self.slope = numerator / denominator
24
+ self.intercept = mean_y - (self.slope * mean_x)
25
+
26
+ def predict(self, X):
27
+ if self.slope is None or self.intercept is None:
28
+ raise RuntimeError("Model must be fitted before calling predict().")
29
+
30
+ if isinstance(X, (int, float)):
31
+ return self.slope * X + self.intercept
32
+
33
+ return [self.slope * x + self.intercept for x in X]
34
+
35
+ def __repr__(self):
36
+ if self.slope is None:
37
+ return "SimpleLinearRegression(unfitted)"
38
+ return f"SimpleLinearRegression(y = {self.slope:.4f}x + {self.intercept:.4f})"
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: simple-regression-nadjib
3
+ Version: 0.1.0
4
+ Summary: Simple Linear Regression package built from scratch
5
+ Author: Your Name
6
+ Requires-Python: >=3.6
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.txt
9
+ Dynamic: author
10
+ Dynamic: description
11
+ Dynamic: description-content-type
12
+ Dynamic: license-file
13
+ Dynamic: requires-python
14
+ Dynamic: summary
15
+
16
+ # Simple Linear Regression Package
17
+
18
+ A pure Python implementation of Simple Linear Regression built from scratch.
19
+
20
+ ## Usage
21
+ ```python
22
+ from simple_regression import SimpleLinearRegression
23
+
24
+ X = [1, 2, 3, 4, 5]
25
+ y = [2, 4, 5, 4, 5]
26
+
27
+ model = SimpleLinearRegression()
28
+ model.fit(X, y)
29
+ print(model.predict([6, 7]))
@@ -0,0 +1,9 @@
1
+ LICENSE.txt
2
+ README.md
3
+ setup.py
4
+ simple_regression/__init__.py
5
+ simple_regression/model.py
6
+ simple_regression_nadjib.egg-info/PKG-INFO
7
+ simple_regression_nadjib.egg-info/SOURCES.txt
8
+ simple_regression_nadjib.egg-info/dependency_links.txt
9
+ simple_regression_nadjib.egg-info/top_level.txt