regression-model-ibrahim 0.1.0__py3-none-any.whl
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.
- regression_model/__init__.py +1 -0
- regression_model/model.py +31 -0
- regression_model_ibrahim-0.1.0.dist-info/METADATA +62 -0
- regression_model_ibrahim-0.1.0.dist-info/RECORD +7 -0
- regression_model_ibrahim-0.1.0.dist-info/WHEEL +5 -0
- regression_model_ibrahim-0.1.0.dist-info/licenses/LICENSE.txt +21 -0
- regression_model_ibrahim-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .model import SimpleLinearRegression
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
class SimpleLinearRegression:
|
|
3
|
+
def __init__(self):
|
|
4
|
+
self.slope = 0
|
|
5
|
+
self.intercept = 0
|
|
6
|
+
|
|
7
|
+
def fit(self, X, y):
|
|
8
|
+
n = len(X)
|
|
9
|
+
|
|
10
|
+
x_mean = sum(X) / n
|
|
11
|
+
y_mean = sum(y) / n
|
|
12
|
+
|
|
13
|
+
numerator = sum(
|
|
14
|
+
(X[i] - x_mean) * (y[i] - y_mean)
|
|
15
|
+
for i in range(n)
|
|
16
|
+
)
|
|
17
|
+
denominator = sum(
|
|
18
|
+
(x - x_mean) ** 2 for x in X
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
if denominator == 0:
|
|
22
|
+
raise ValueError("All X values cannot be identical.")
|
|
23
|
+
|
|
24
|
+
self.slope = numerator / denominator
|
|
25
|
+
self.intercept = y_mean - self.slope * x_mean
|
|
26
|
+
|
|
27
|
+
def predict(self, X):
|
|
28
|
+
return [
|
|
29
|
+
self.intercept + self.slope * x
|
|
30
|
+
for x in X
|
|
31
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: regression-model-ibrahim
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple linear regression model
|
|
5
|
+
Description-Content-Type: text/markdown
|
|
6
|
+
License-File: LICENSE.txt
|
|
7
|
+
Dynamic: description
|
|
8
|
+
Dynamic: description-content-type
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
Dynamic: summary
|
|
11
|
+
|
|
12
|
+
# Simple Linear Regression
|
|
13
|
+
|
|
14
|
+
A lightweight Python package that implements simple linear regression without external dependencies.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Train a linear regression model using `fit()`.
|
|
19
|
+
- Predict values using `predict()`.
|
|
20
|
+
- Estimate the slope and intercept of the best-fit line.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install regression-model-ibrahim
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from regression_model import SimpleLinearRegression
|
|
32
|
+
|
|
33
|
+
model = SimpleLinearRegression()
|
|
34
|
+
|
|
35
|
+
# Training data
|
|
36
|
+
X = [1, 2, 3]
|
|
37
|
+
y = [2, 4, 6]
|
|
38
|
+
|
|
39
|
+
# Train the model
|
|
40
|
+
model.fit(X, y)
|
|
41
|
+
|
|
42
|
+
# Make predictions
|
|
43
|
+
predictions = model.predict([4, 5])
|
|
44
|
+
|
|
45
|
+
print(predictions)
|
|
46
|
+
# [8.0, 10.0]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## How it works
|
|
50
|
+
|
|
51
|
+
The model learns the slope and intercept of the least-squares regression line:
|
|
52
|
+
|
|
53
|
+
\[
|
|
54
|
+
\hat{y} = b_0 + b_1x
|
|
55
|
+
\]
|
|
56
|
+
|
|
57
|
+
- `fit(X, y)`: estimates the model parameters.
|
|
58
|
+
- `predict(X)`: predicts outputs for new input values.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
regression_model/__init__.py,sha256=V9H1tocop-TbWP3uZoIjX0ucR_p6f3sSwtnU7ylmeV0,41
|
|
2
|
+
regression_model/model.py,sha256=AmKfLaN9GKCrF2FxX3V3vGlc---gj3rVXRjORmYZoXM,745
|
|
3
|
+
regression_model_ibrahim-0.1.0.dist-info/licenses/LICENSE.txt,sha256=ruwGgQeOhQiuNz5EjUM3YKEgxvya15AFWs1ehyR9UiU,1092
|
|
4
|
+
regression_model_ibrahim-0.1.0.dist-info/METADATA,sha256=F7vOk_do89CeApyZMD-bdA5d7RnAJCVC8YyIVs7dppQ,1211
|
|
5
|
+
regression_model_ibrahim-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
6
|
+
regression_model_ibrahim-0.1.0.dist-info/top_level.txt,sha256=LJGM0L_SB9KXVONS_R9rxhoKF0pMgj3xtM1Mmt4we8c,17
|
|
7
|
+
regression_model_ibrahim-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Belhamri Ibrahim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
regression_model
|