Astrodetection
Astrodetection is a Python library designed for detecting astroturfing clues from lists of posts (mainly on X up to now, but not exclusively)
Installation
Pip
pip install "astrodetection[standard]"
or
pip install "astrodetection[light]"
Conda
-
Use the YAML file to configure the environment with conda:
conda create -n astrodetection_env conda activate astrodetection_env conda env update -f environment_standard.yml
Note: the environment_standard.yml configuration file uses FAISS and Fasttext libraries for VIGINUM D3LTA implementation
**If you have compatibility issues, prefer environment_light.yml and use astrodetection_light module
Usage
You can import directly the main functions:
from astrodetection import semantic_faiss, prepare_input_data, compute_bot_likelihood_metrics, create_network
Or use them directly:
import glob
import pandas as pd
import os
import numpy as np
import astrodetection
# Load a single JSON file into a DataFrame
file = "file_path" # Select the first file
df = pd.read_json(file)
df.index = df.index.astype(str) # Compatibility with d3lta
# Preprocess the DataFrame
df = df[df['tweet'].str.len() > 100]
df = df[df['username'] != 'grok']
df.index = df.index.astype(str)
# Compute matches and scores
df_filtered, df_emb = astrodetection.prepare_input_data(df, embeddings=df['emb'])
matches, df_cluster = astrodetection.semantic_faiss(
df_filtered.rename(columns={'tweet': 'original'}),
min_size_txt=0,
df_embeddings_use=df_emb,
threshold_grapheme=0.8,
threshold_language=0.715,
threshold_semantic=0.9
) #function taken from D3LTA
scores = astrodetection.compute_bot_likelihood_metrics(df, matches=matches)
# Create a network
network = astrodetection.create_network(matches, df)
New changes
-
semantic_faissfunction can now take detect only copypastas based on levenshtein distance, ignoring embeddings, if "skip" is passed as argument in df_embeddings_use field. -
compute_bot_likelihood_metricsfunction can now take columns' names as arguments for more customization
Release files for astrodetection 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| astrodetection-0.2.5.tar.gz | 42.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| astrodetection-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.9 kB
Release files / astrodetection-0.2.5.tar.gz
| Download URL | astrodetection-0.2.5.tar.gz |
|---|---|
| Size | 42.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edb60b3b3f5b1857c00cc6eaa52c7aea6cc702d69849e5398efdc494c13b6bb4
|
|
BLAKE2b-256 checksum How to use checksums |
5859364e5302ee877f9613ce8c6782597a31c0c3590cdad45d3f8552d1d6d623
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.4
|
Release files / astrodetection-0.2.5-py3-none-any.whl
| Download URL | astrodetection-0.2.5-py3-none-any.whl |
|---|---|
| Size | 43.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
868a58c41a8f1d9e91983e782dbf3e4d51bf8bc2b578d8ac89c7cabda4181577
|
|
BLAKE2b-256 checksum How to use checksums |
1df18eb92629f830d7ff313aeb2f4f02f935449d0eac0c65ac0a59ed7e87c40f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.4
|