Skip to main content

A python function to mine pairwise correlations from a dataframe with many features and targets. Exports the results to a CSV.

Project description

pairwise_correlation_miner

Pairwise Correlation Miner

Last Update: 12/21/23

Summary

The Pairwise_Correlation_Miner package provides the execute_feature_target_pair_analysis function, designed to analyze statistical relationships between multiple features and targets in a dataframe, outputting the results in CSV format.

Installation

Available as a package at PyPi.org. https://pypi.org/project/pairwise-correlation-miner/. Install via pip: pip install pairwise-correlation-miner

Function Usage

execute_feature_target_pair_analysis(dataframe, feature_list, target_list, export_file_path)

  • dataframe: DataFrame containing non-null, numeric feature and target values.
  • feature_list: List of column names to be treated as features.
  • target_list: List of column names to be treated as targets.
  • export_file_path: File path for exporting results (e.g., "data.csv").

Function returns

  • dataloader_df: The results of the analysis in a dataframe
  • Exports a CSV file to the path and file you define when submitting the function.

Example

# Example usage of the function
import pairwise_correlation_miner as pcm

dataframe = ...
feature_list = ['feature1', 'feature2']
target_list = ['target1', 'target2']
export_file_path = "results.csv"

pcm.execute_feature_target_pair_analysis(dataframe, feature_list, target_list, export_file_path)

Analysis Overview

The function loops through all of the possible feature-target pairs and performs 3 analyses:

  1. Linear Regression: Uses scikit-learn's linear regression, with an m-test for p-value calculation.
  2. Polynomial Regression: 2nd degree polynomial regression, also with m-test based p-value calculation.
  3. Autobucketed Welches t Test: Buckets data points for binary and non-binary targets to perform a t-test. The m-test is a way to generate a p value for the probability that a given feature predicts a target, baed on a regression equation. For each data point, we calculate an estimate of the probability that the datapoint is as close to the regression line as it actually is, and the probability that it is as close to the null hypothesis line as it actually is. Once we have these 2 probability values for each datapoint, we run a t test to compare whether the prediction probabilities are different than the null probabilities. The null hypothesis line is set at y = (target mean + target median) / 2.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pairwise_correlation_miner-2.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pairwise_correlation_miner-2.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pairwise_correlation_miner-2.1.tar.gz.

File metadata

File hashes

Hashes for pairwise_correlation_miner-2.1.tar.gz
Algorithm Hash digest
SHA256 52452c4aa7d9b6fb4dfae3f6e50c485a3f3a0073e031fc9ed9ca20c619b76838
MD5 13bf50912fcea25a07d3105c0db67759
BLAKE2b-256 bbfc30e88971932591032a8e77e7261a82b414bde417c6f63f49052dbd4d245c

See more details on using hashes here.

File details

Details for the file pairwise_correlation_miner-2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pairwise_correlation_miner-2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4096abf36957fc0f47a479da6c56b33bb0ec632294de49fa0381c8c94e8a9746
MD5 ef0fbcbecd1803e2f085d5b8c1a2a480
BLAKE2b-256 4b555f3f3d143dad728d93bd981eb7fd8ffe1319f78edf366f148db24ba49047

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page