Skip to main content

Python library for regression graphs using coefficents, confidence intervals and p-values

Project description

README.md:

# Regression Graph

## Overview 

This Python library was designed to create regression graphs for datasets. Instead of using p-values, this library will use the coefficients and confidence interval to plot bars for each variable in the given dataset. The bars will be plotted with their upper and lower confidence interval and will use the p-value for the saturation of the bars. There's optional arguments to standardize the dataset. A table can be created to display the variable, mean and standard deviation of the dataset. 

## Features 

plot_graph: plot the regression graph with manual data or with statsmodel regression

coefficient_distribution_plots: plot any scipy distrabutions

create_table: create a table for the variables, mean and standard deviation

extract_data: use the statsmodel library to pass a fitted regression model which will extact the coefficents, confidence interval and p-value from the model and pass it onto plot_graph to produce the graph. 

regression_plot, call this function and either inpur manaul dataset or statsmodels regression model to produce the graph. This function will either call extract_model if a regression is passed or plot_graph if manual data is passed. Call create_table to produce a table with the variable name, mean and standard devisation of the values. 

## Installation

Install the package using pip install regression_graph

## Example usage 

```python
from regression_graph import regression_plot

Statsmodel

  1. Read file path file
  2. Remove rows with missing values
  3. select the dependent variable (y) and independent variables (X)
  4. Fit the regression model
  5. Give variable names for the y-axis eg x
  6. Plot the regression coefficients with confidence intervals Call regression_plot(ax1, model_result=model, variable_names=variable_names, positive_bar_colour=none, negative_bar_colour=none, title)
  7. Optional table create_table(ax2=position, dataframe, loc=none, font_size=none, col_widths=none, label_cell_loc=none, label_bbox=mandatory)

Manual input

  1. Provide the coefficients, confidence intervals upper and lower bounds, and p-values
  2. Call regression_plot regression_plot(ax1, model_result=model, variable_names=X_cols)
  3. Optional table create_table(ax2=position, dataframe, loc=none, font_size=none, col_widths=none, label_cell_loc=none, label_bbox=mandatory)

Both options allow the values to be standardize by doing standardize=True in the regression_plot argument. If standardize=True then user is required to give an input_X value (this is the indepdenat variable, can be a column from the dataset) for the function to work.

Coefficent distrabution

  1. Read file path file
  2. Remove rows with missing values
  3. select the dependent variable (y) and independent variables (X)
  4. Fit the regression model
  5. Give variable names for the y-axis eg x
  6. Give manual values for coefficents, p-values, std_errs or pass a model to get the values.
  7. Use scipy to pass a distrabution
  8. Call regression_plot (ax1, coefficients=coefficients, distribution=distribution, p_values=p_values)
  9. Optional Paramter for Table
  10. Show graph

Create Table

  1. Call create_table
  2. Provide a paramter for data (independant variable)
  3. Optional paramter to change table size and text.

Customisable options

Plot_graph

  1. xlabel
  2. title
  3. show_yticks
  4. custom_levels
  5. positive_colour, negstive_colour

coefficient_distribution_plots

  1. same as plot_graph with these additional optiond
  2. distribution
  3. num_std
  4. lower_percentile, upper_percentile

create_table

  1. data
  2. dependent_variable
  3. loc
  4. cell_loc
  5. font_size
  6. bbox
  7. col_widths
  8. label_cell_loc
  9. labels_bbox

regression_plot table_kwargs

Requirements

Python 3.6 and above Numpy Matplotlib Pandas Statsmodels (optional)

License

This project is licensed under MIT, view license here - https://choosealicense.com/licenses/mit/

Contact

Please feel free to leave any feedback or questions here: saemakhanom@gmail.com

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

regression_graph-2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

regression_graph-2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file regression_graph-2.tar.gz.

File metadata

  • Download URL: regression_graph-2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for regression_graph-2.tar.gz
Algorithm Hash digest
SHA256 911c250d4b16bcc16b6540ba19ff0f8511dec2929112c487b50e68fcc6a6b358
MD5 0a25bd5fc0cd453d601b5db06395665b
BLAKE2b-256 981bf830361bd2bf7e830aa1d3f5c60a4caa6fdd25ed8ed036a267d0c7397cd5

See more details on using hashes here.

File details

Details for the file regression_graph-2-py3-none-any.whl.

File metadata

  • Download URL: regression_graph-2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for regression_graph-2-py3-none-any.whl
Algorithm Hash digest
SHA256 0643022dce4cf1a38b8936960b61bcc9bc6449ec51831d7f2ee16ba3b744d255
MD5 c58b77901bd994ef49e08ac1cc709134
BLAKE2b-256 ec675b1a59f18966b38b9f5b1d661b3375eb895c6157a2cf0b88206ab485a47d

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