Results and Formatting
DataFrame Results
Both rthor.test() and rthor.compare() return pandas DataFrames containing all test results and metadata.
rthor.test() Returns
A single DataFrame with columns:
matrix: Matrix identifier (1-indexed)predictions: Number of hypothesized predictionsagreements: Number of predictions satisfiedties: Number of tied correlationsci: Correspondence Index (-1 to +1)p_value: Randomization test p-valuelabel: Descriptive label for matrixn_permutations: Number of permutations testedn_variables: Number of variables per matrix
Each row represents one tested matrix. Metadata columns (n_permutations, n_variables) are repeated for tidy data principles.
rthor.compare() Returns
A tuple of two DataFrames: (individual_results, pairwise_comparisons)
individual_results has the same structure as test() output.
pairwise_comparisons DataFrame columns:
matrix1,matrix2: Matrix identifiers being comparedboth_agree: Predictions satisfied by both matricesonly1: Predictions satisfied only by matrix 1only2: Predictions satisfied only by matrix 2neither: Predictions satisfied by neitherci: Comparison CI (positive means matrix 2 fits better)p_value: Statistical significance of differencen_permutations,n_variables: Metadata columns
Formatting Functions
Optional functions for compact, interpretable result display:
print_results()
Print compact, interpreted output of rthor.test() results with CI interpretation and significance:
import rthor
df = rthor.test(data, order="circular6")
rthor.print_results(df) # Pretty-print the results
Or use the convenience parameter:
print_comparison()
Print compact, interpreted output of comparison results with winner determination:
individual, pairwise = rthor.compare(data, order="circular6")
rthor.print_comparison(individual, pairwise)
Or use the convenience parameter:
Both functions support rich formatting (if the rich package is installed) or plain text.
Working with DataFrames
Since results are standard pandas DataFrames, you can use all pandas functionality:
# Filter significant results
significant = df[df['p_value'] < 0.05]
# Export to various formats
df.to_csv("results.csv")
df.to_excel("results.xlsx")
df.to_latex("results.tex")
# Get specific values
n_perms = df['n_permutations'].iloc[0]
mean_ci = df['ci'].mean()
# Plotting
import matplotlib.pyplot as plt
df.plot.bar(x='label', y='ci')
rthor.formatting.print_results
Print RTHOR test results in a compact, interpretable format.
Source code in src/rthor/formatting.py
:::
rthor.formatting.print_comparison
Print comparison results in a compact, interpretable format.
Source code in src/rthor/formatting.py
:::