Posts

Showing posts with the label Python

LSTM-Demo: Bidirectional LSTM with TensorFlow on the Sonar Dataset

Image
LSTM-Demo is a compact, runnable example that trains a bidirectional Long Short-Term Memory (LSTM) network with TensorFlow and Keras on the classic Sonar dataset. The Sonar dataset is a well-known binary classification benchmark: each sample has 60 numeric features from sonar returns, and the task is to tell metal cylinders (mines) from rocks. It is small enough to train quickly while still showing a full pipeline. A bidirectional LSTM reads the input sequence in both directions, which can help the model use context from the whole sequence. The demo is intended as a teaching example you can run, read, and modify. It is archived on Zenodo with a citable DOI. DOI: https://doi.org/10.5281/zenodo.20672929

Links-Extractor: Extract Internal and External Links from a URL in Python

Image
Links-Extractor is a small Python utility that takes a single URL and pulls out every hyperlink on the page, separating them into internal links (pointing to the same domain) and external links (pointing elsewhere). Splitting links this way is useful for SEO audits, for finding broken or outbound links, for mapping the structure of a site, and as a starting point for a larger crawler. You give it a URL and get back two clean lists you can save or process further. The project is open source and meant to be easy to read and adapt. It is archived on Zenodo with a citable DOI. DOI: https://doi.org/10.5281/zenodo.20672987

SEO-Analysis: Gather SEO Insights for Domains and Keywords with Python

Image
SEO-Analysis Keyword + domain insights, driven by a spreadsheet Test.xlsx → Python script → Insights in Excel SEO-Analysis is a small open-source Python script that gathers SEO insights for a set of domains and keywords. It is spreadsheet-driven, so you do not have to touch the code: you list what you want to check in an Excel file, run the script, and it writes the insights back into the spreadsheet. How to use it Open Test.xlsx . Add your keywords and domains, one pair per row. You can repeat the same domain on multiple rows with a different keyword each time. Save Test.xlsx . Run the Python script. The script fills the spreadsheet with the insights for each keyword and domain. Pair it with Links-Extractor For SEO work it pairs well with Links-Extractor , which pulls all the internal and external links from a URL. Links Source: github.com/com-puter-tips/SEO-Analysis License: GPL-3.0

MP3-Stereo-Analyzer: Check, Fix, and Compare MP3 Earbud Audio

Image
MP3-Stereo-Analyzer Make sure both earbuds play the full audio Analyze --fix --compare MP3-Stereo-Analyzer is a Python tool that checks whether your MP3 files are correctly formatted to play in both earbuds. It is published on PyPI and catches a frustrating, common problem: a track where one earbud plays only the music and the other only the vocals, or where the channels are phase-inverted and cancel out. Installation pip install mp3-stereo-analyzer It needs FFmpeg for audio decoding: brew install ffmpeg # macOS Usage # Analyze a single file mp3-stereo-analyzer your_file.mp3 # Analyze every MP3 in a folder mp3-stereo-analyzer *.mp3 # Detect AND fix files that play different audio in each ear mp3-stereo-analyzer --fix your_file.mp3 # Compare versions and pick the best one mp3-stereo-analyzer --compare old.mp3 new.mp3 What it checks The analyzer reports the format (channels, sample rate, bit depth, bitrate) and runs five tests: Channel count: the file actually con...

chiku: Efficient Polynomial Function Approximation in Python

Image
chiku Polynomial function approximation in Python — one API, seven methods Taylor Fourier Pade Chebyshev Remez ANN LR chiku is an open-source Python library for efficient polynomial function approximation. It takes an arbitrary continuous function and returns the coefficients of a polynomial that approximates it, using a unified API across seven different methods. It is available on PyPI and is particularly useful for evaluating non-linear functions (such as sigmoid or tanh) under Fully Homomorphic Encryption, where only additions and multiplications are available and functions must be replaced by polynomials. Installation pip install chiku To enable the optional TensorFlow-based ANN approximator (TensorFlow currently needs Python 3.11): pip install chiku[ann] What it does Complex non-linear functions can be approximated by polynomials so they can be computed in restricted settings such as encrypted (FHE) domains. Deterministic methods like Taylor, Pade, Chebyshev, Remez, and...

Build, Test, and Publish a Python Package to PyPI

Image
Before you push a release to the Python Package Index, it pays to build and test it locally so you catch problems before your users do. This guide walks through the full workflow: setting up an isolated environment, installing your package in editable mode, running the test suite, building the distribution, validating the metadata, uploading with Twine, and tagging the release in Git. (If you are starting from scratch and need to structure the package itself first, see How To Create A Python Package .) Build, Test & Publish a PyPI Package venv create + activate → Install deps + pip -e . → Test pytest -v → Build python -m build → Check twine check → Upload twine upload → Tag git tag + push Test locally and validate metadata before you ever upload to PyPI. 1. Set up an isolated environment Install the Python version you need. If your package depends on TensorFlow, use Python 3.11, since the newest releases are not always supported right away. O...

[SOLVED] Tuple index out of range in TensorFlow model fit function

Image
model.fit(): list vs NumPy array # Problem: plain Python lists model.fit(x_train, y_train) IndexError: tuple index out of range # Fix: wrap with np.array() model.fit(np.array(x_train), np.array(y_train)) training runs When training a Keras or TensorFlow model you may hit an IndexError: tuple index out of range the moment you call model.fit() , even though your data looks fine. The cause is almost always the type of the data you passed in, not the model. This post explains why it happens and the one-line fix. The problem code Here training data is built up as plain Python lists and passed straight to fit : x_train = [] y_train = [] # ... append samples to the lists ... history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs) This raises: IndexError: tuple index out of range Why it happens Keras needs to know the shape of your input to wire up the first layer and to split data into batches. It reads that shape from the .shape attribute of the a...

Simplify Rational Numbers in Python

Image
Real Numbers Rational Numbers 7.92 2/5 1/2 Integers Numbers -3 -2 -9 -7 -10 Whole Numbers {0, 1, 2, 3, ...} Natural Numbers {1, 2, 3, 4, 5, ...} Irrational Numbers √10 π √2 φ The real number system: rational numbers (with natural, whole, and integers nested inside) alongside irrational numbers. What Is a Rational Number? A rational number is any number that can be expressed as a fraction of two integers, where the numerator is a whole number and the denominator is a non-zero integer. The decimal form of a rational number either ends (terminates) or repeats infinitely. [1, 2, 3, 4] Key Characteristics and Forms Rational numbers encompass a wide variety of numbers, which can always be categorized into these four main forms: Integers: All whole numbers, both positive and negative, are rational because they can be written as a fraction over 1 (e.g., 5 = 5/1, -3 = -3/1). Fractions: Any standard or mixed fraction where the top and bottom are integers (with a de...