Code Monkey home page Code Monkey logo

perceptron's Introduction

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)
      

perceptron's People

Contributors

rabiawadhwa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.