Skip to main content

Implement Perceptron

Project description

Perceptron

References

CI/CD.yml code

# name of the workflow
name: Upload Python Package

#when to execute - when you push changes on "main" branch
on:
  push:
    branches:
    - main
    # - dev  => add for more branches if needed

# what to execute - lists jobs
jobs:
  deploy: # first job ,you can list more jobs as well
    runs-on: ubuntu-latest # CREATE UBUNTU ENVIRONMENT
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python  #sets up python
        uses: actions/setup-python@v2
        with:
          python-version: '3.7'  # python version needed
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install build
      - name: Build package
        run: python -m build
      - name: Publish package
        uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}

        

How to use package

from perceptron_package.perceptron_class import Perceptron 
import pandas as pd

def prepare_data(df):
  """ Used to separate dependent and independent features       

  Args:
      df (pd.dataframe): pandas dataframe

  Returns:
      tuple: returns tuple of dependent & independent variables
  """
  X = df.drop("y",axis=1)
  y = df["y"]
  return X,y



def main(data ,eta,epochs):
       df = pd.DataFrame(data)
       df  # Shape = (4,3)

       X,y = prepare_data(df) 

       model = Perceptron(eta=eta, epochs=epochs)  # Creating object of class Perceptron
       model.fit(X, y) # Weights in last epoch are considered as final weights for prediction

       _ = model.total_loss() # last Epoch's Sum of Errors , '_' indicates dummy variable

       
if __name__ == '__main__': # define entry point of program execution
       AND = {"x1":[0,0,1,1],
              "x2":[0,1,0,1],
              "y" :[0,0,0,1]
              }

       ETA = 0.3 # between 0 and 1
       EPOCHS = 10
       main(AND,ETA,EPOCHS)
      

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Perceptron-RabiaWadhwa-0.0.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

Perceptron_RabiaWadhwa-0.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file Perceptron-RabiaWadhwa-0.0.2.tar.gz.

File metadata

  • Download URL: Perceptron-RabiaWadhwa-0.0.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for Perceptron-RabiaWadhwa-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d23c917b6024d6d2a0f5eb440d64b1d1a5555e9b813c711e2a4a9479b83d0285
MD5 1e87e18f11032a7f9917c3eb72b3bdf5
BLAKE2b-256 51e46e406b46d2a7fdf8a12dedfa85529c8b09905cde32b589b318499296f48e

See more details on using hashes here.

File details

Details for the file Perceptron_RabiaWadhwa-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: Perceptron_RabiaWadhwa-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for Perceptron_RabiaWadhwa-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 161f67cead4c5ec1ab1a54f584091f135ec35c1868907a860d4e7469b73ec9d4
MD5 6463e6061c000f4198afdc625addce0d
BLAKE2b-256 d7b2613b8f335315e35d86a2f0b1a0611c6506703e1341a7d56b6dc04afa46db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page