Metadata-Version: 2.2
Name: luvex
Version: 0.1.0
Summary: Regression - Linear(Least Squares Method), Multiple Linear . Classification - KNN, Logistic Regression, Decision Trees, Random Forests 
Home-page: https://github.com/Gladson-K/luvex
Author: Gladson K
Author-email: gladson1414@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scikit-learn
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# luvex
Developing ML Models from scratch : Regression - Linear (Least Squares Method), Multiple Linear. Classification - KNN, Logistic Regression, Decision Trees, Random Forests

# Luvex

Luvex is a Python package for implementing machine learning models such as Decision Tree, Random Forest, and more.

## Installation

You can install `luvex` from PyPI using pip:

```bash
pip install luvex


## Testing Linear Regression

import numpy as np
from luvex import Linearregression  # Import your model

def test_linear_regression():
    X_train = np.array([1, 2, 3])
    y_train = np.array([1, 2, 3])
    X_test = np.array([2])
    
    model = Linearregression()
    model.fit(X_train, y_train)
    predictions = model.predict(X_test)
    
    assert np.allclose(predictions, np.array([2]))  # Test if prediction matches expected value

if __name__ == "__main__":
    test_linear_regression()
    print("All tests passed for Linearregression")

## Testing Logistic Regression

import numpy as np
from luvex import Logisticregression  # Import your model

def test_logistic_regression():
    X_train = np.array([[1, 2], [2, 3], [3, 4]])
    y_train = np.array([0, 1, 0])
    X_test = np.array([[2, 3]])

    model = Logisticregression(learn_rate=0.01, n_iter=1000)
    model.fit(X_train, y_train)
    predictions = model.predict(X_test)

    #assert predictions[0] >= 0  # Corrected to index into the first value of the array


if __name__ == "__main__":
    test_logistic_regression()
    print("All tests passed for Logisticregression")

## Test KNN

import numpy as np
from luvex import KNN  # Import your model

def test_knn():
    X_train = np.array([[1, 2], [2, 3], [3, 4]])
    y_train = np.array([0, 1, 0])
    X_test = np.array([[2, 2]])
    
    model = KNN(k=2)
    model.fit(X_train, y_train)
    predictions = model.predict(X_test)
    
    assert predictions >= [0]  # Test if the prediction is correct

if __name__ == "__main__":
    test_knn()
    print("All tests passed for KNN")

## Test MultiLinear Regression

import numpy as np
from luvex import MultipleLinear  # Import your model

def test_multiple_linear():
    X_train = np.array([[1, 2], [2, 3], [3, 4]])  # Example with two features
    y_train = np.array([1, 2, 3]).reshape(-1, 1)  # Ensure y_train is a 2D array (column vector)
    X_test = np.array([[2, 3]])  # Test sample

    model = MultipleLinear(learning_rate=0.01, iterations=1000)
    model.fit(X_train, y_train)
    predictions = model.predict()

    #assert np.allclose(predictions, np.array([2]))  # Ensure predictions match expected value



if __name__ == "__main__":
    test_multiple_linear()
    print("All tests passed for MultipleLinear")

## testing Decision Tree

import numpy as np
from luvex.node import Node
from luvex.decisiontree import DecisionTree


def test_decision_tree():
    X_train = np.array([[1, 2], [2, 3], [3, 4]])
    y_train = np.array([0, 1, 0])
    X_test = np.array([[2, 2]])

    model = DecisionTree()
    model.fit(X_train, y_train)
    predictions = model.predict(X_test)

    assert predictions[0] >= 1  # Fix the expected prediction here based on your model



if __name__ == "__main__":
    test_decision_tree()
    print("All tests passed for DecisionTree")

## Testing Random Forests

import numpy as np
from luvex import RandomForest  # Import your model
from luvex.decisiontree import DecisionTree
from luvex import RandomForest 

def test_random_forest():
    X_train = np.array([[1, 2], [2, 3], [3, 4]])
    y_train = np.array([0, 1, 0])
    X_test = np.array([[2, 2]])

    model = RandomForest(n_trees=3, max_depth=5, min_samples_split=2, n_features=1)
    model.fit(X_train, y_train)
    predictions = model.predict(X_test)

    assert predictions[0] >= 0  # Modify to check the first value in the returned array


if __name__ == "__main__":
    test_random_forest()
    print("All tests passed for RandomForest")



## License

MIT License

Copyright (c) 2025 Gladson K

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.





### Step 6: Build the Package
Once everything is ready, you need to build your package. Use the following commands:

1. **Install build tools**:
   ```bash
   pip install build
