Skip to main content

A Python package to apply the Benford´s Law analysis

Project Motivation

As part of the Udacity Data Science nanodegree this is a project to create and deploy a Python package, based on this I decided to use the Benford´s Law to create a package using OOP than can apply the analyzis to a dataset, an imgae or a numpy array of numbers.

Installation:

pip intall benford_law

This package uses these libraries

  • pandas
  • numpy
  • matplotlib

The python version used: 3.8

Files in the repository

  • README.md : This file
  • setup.py : Setup file for the package
  • .gitignore : File to ignore files and not load to the GitHub repository
  • LICENSE : The MIT License
  • benford_law
    • bendord_law.py : The Benford Class
    • init.py : Inititalization file for the package
  • tests
    • tests.py : Script for unit tests of the Benford Class
    • Benford_plot_test.ipynb : Jupyter Notebook to test the graphs plotting ot the Benford Class
    • flower.jpg : JPG image to test the Benford Class
    • population.csv : CSV dataset with the Wordl Population to test the Benford Class

How To use the package

  1. Create an instace with the Benford Class

    • benford = Benford()
  2. Load a dataset or an image ,

    • bendford.load_dataset(dataset_name)
    • benford.load_image(image_name)
  3. Do the benford analysis using the benford_analysis method

    • benford.benford_analysis()
  4. Graph or plot the results using plot() method

    • benford.plot()
  5. Save the results using expor_to_csv() method:

    • benford.export_to_csv(filename)

Example using the pakage to analyze an image:

#Import libraries
import pandas as pd
import numpy as np
from benford_law import Benford
import matplotlib.pyplot as plt
from PIL import Image


image_file = 'flower.jpg'      #Read image
image = Benford()              #Create Benford instance
image.load_image(image_file)   #Load image
image.benford_analysis()       #Do Analysis
image.plot()                   #Plot Benford´s analysis

Example

Terms of use:

This is a tool to do an initial analyzis using Benford´s Law and plot how the digit´s probability are distributed on different datasets, it is not a formal analysis or study using the Benford´s Law

License:

The code follows this license: https://opensource.org/licenses/MIT

Metadata

Release files for benford-law 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for benford-law 0.1.2
File Size Uploaded Provenance
benford_law-0.1.2.tar.gz 4.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for benford-law 0.1.2
File Interpreter ABI Platform
benford_law-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / benford_law-0.1.2.tar.gz

Download URL benford_law-0.1.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4438878925ba01cc658fcdb3866d9c46c2d6ba9f424a90d0ada9cee780f91925
BLAKE2b-256 checksum
How to use checksums
f9ba89b409985a2ad908e046cb745913f43246152b097148dc55c121293dbfa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Release files / benford_law-0.1.2-py3-none-any.whl

Download URL benford_law-0.1.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
722d7fe04c378cb7e282859dc30e95f7e5974e4bb961bf6abbff237a469885b9
BLAKE2b-256 checksum
How to use checksums
91f1aa0d954e40f335688f666a5652f0f4cffb9e74d0d9c87fa07097c58db316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Security for benford-law 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page