analysistoolbox 2.1.8__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. analysistoolbox-2.2.0/PKG-INFO +2227 -0
  2. analysistoolbox-2.2.0/README.md +2209 -0
  3. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/ConductEntityMatching.py +28 -6
  4. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/ConductPropensityScoreMatching.py +158 -137
  5. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/llm/SendPromptToChatGPT.py +1 -1
  6. analysistoolbox-2.2.0/analysistoolbox.egg-info/PKG-INFO +2227 -0
  7. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/setup.py +1 -1
  8. analysistoolbox-2.1.8/PKG-INFO +0 -990
  9. analysistoolbox-2.1.8/README.md +0 -972
  10. analysistoolbox-2.1.8/analysistoolbox.egg-info/PKG-INFO +0 -990
  11. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/LICENSE.md +0 -0
  12. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/__init__.py +0 -0
  13. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/calculus/FindDerivative.py +0 -0
  14. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/calculus/FindLimitOfFunction.py +0 -0
  15. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/calculus/FindMinimumSquareLoss.py +0 -0
  16. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/calculus/PlotFunction.py +0 -0
  17. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/calculus/__init__.py +0 -0
  18. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/ExtractTextFromPDF.py +0 -0
  19. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/FetchPDFFromURL.py +0 -0
  20. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/FetchUSShapefile.py +0 -0
  21. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/FetchWebsiteText.py +0 -0
  22. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/GetCompanyFilings.py +0 -0
  23. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/GetGoogleSearchResults.py +0 -0
  24. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/GetZipFile.py +0 -0
  25. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_collection/__init__.py +0 -0
  26. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/AddDateNumberColumns.py +0 -0
  27. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/AddLeadingZeros.py +0 -0
  28. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/AddRowCountColumn.py +0 -0
  29. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/AddTPeriodColumn.py +0 -0
  30. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/AddTukeyOutlierColumn.py +0 -0
  31. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CleanTextColumns.py +0 -0
  32. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/ConductAnomalyDetection.py +0 -0
  33. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/ConvertOddsToProbability.py +0 -0
  34. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CountMissingDataByGroup.py +0 -0
  35. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CreateBinnedColumn.py +0 -0
  36. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CreateDataOverview.py +0 -0
  37. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CreateRandomSampleGroups.py +0 -0
  38. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CreateRareCategoryColumn.py +0 -0
  39. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/CreateStratifiedRandomSampleGroups.py +0 -0
  40. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/GeocodeUSAddresses.py +0 -0
  41. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/ImputeMissingValuesUsingNearestNeighbors.py +0 -0
  42. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/VerifyGranularity.py +0 -0
  43. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/data_processing/__init__.py +0 -0
  44. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/ConductManifoldLearning.py +0 -0
  45. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/ConductPrincipalComponentAnalysis.py +0 -0
  46. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/CreateAssociationRules.py +0 -0
  47. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/CreateGaussianMixtureClusters.py +0 -0
  48. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/CreateHierarchicalClusters.py +0 -0
  49. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/CreateKMeansClusters.py +0 -0
  50. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/GenerateEDAWithLIDA.py +0 -0
  51. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/descriptive_analytics/__init__.py +0 -0
  52. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/file_management/ConvertWordDocsToPDF.py +0 -0
  53. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/file_management/CreateCopyOfPDF.py +0 -0
  54. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/file_management/CreateFileTree.py +0 -0
  55. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/file_management/ImportDataFromFolder.py +0 -0
  56. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/file_management/__init__.py +0 -0
  57. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/ChiSquareTestOfIndependence.py +0 -0
  58. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/ChiSquareTestOfIndependenceFromTable.py +0 -0
  59. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/ConductCoxProportionalHazardRegression.py +0 -0
  60. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/ConductLinearRegressionAnalysis.py +0 -0
  61. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/ConductLogisticRegressionAnalysis.py +0 -0
  62. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/ConductSurvivalAnalysis.py +0 -0
  63. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/OneSampleTTest.py +0 -0
  64. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/OneWayANOVA.py +0 -0
  65. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/TTestOfMeanFromStats.py +0 -0
  66. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/TTestOfProportionFromStats.py +0 -0
  67. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/TTestOfTwoMeansFromStats.py +0 -0
  68. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/TwoSampleTTestOfIndependence.py +0 -0
  69. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/TwoSampleTTestPaired.py +0 -0
  70. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/hypothesis_testing/__init__.py +0 -0
  71. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/CalculateEigenvalues.py +0 -0
  72. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/ConvertMatrixToRowEchelonForm.py +0 -0
  73. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/ConvertSystemOfEquationsToMatrix.py +0 -0
  74. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/PlotVectors.py +0 -0
  75. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/SolveSystemOfEquations.py +0 -0
  76. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/VisualizeMatrixAsLinearTransformation.py +0 -0
  77. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/linear_algebra/__init__.py +0 -0
  78. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/llm/SendPromptToAnthropic.py +0 -0
  79. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/llm/__init__.py +0 -0
  80. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/CreateARIMAModel.py +0 -0
  81. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/CreateBoostedTreeModel.py +0 -0
  82. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/CreateDecisionTreeModel.py +0 -0
  83. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/CreateLinearRegressionModel.py +0 -0
  84. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/CreateLogisticRegressionModel.py +0 -0
  85. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/CreateNeuralNetwork_SingleOutcome.py +0 -0
  86. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/predictive_analytics/__init__.py +0 -0
  87. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/prescriptive_analytics/CreateContentBasedRecommender.py +0 -0
  88. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/prescriptive_analytics/__init__.py +0 -0
  89. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/probability/ProbabilityOfAtLeastOne.py +0 -0
  90. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/probability/__init__.py +0 -0
  91. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/CreateMetalogDistribution.py +0 -0
  92. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/CreateMetalogDistributionFromPercentiles.py +0 -0
  93. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/CreateSIPDataframe.py +0 -0
  94. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/CreateSLURPDistribution.py +0 -0
  95. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateCountOfSuccesses.py +0 -0
  96. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateCountOutcome.py +0 -0
  97. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateCountUntilFirstSuccess.py +0 -0
  98. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateNormallyDistributedOutcome.py +0 -0
  99. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateTDistributedOutcome.py +0 -0
  100. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateTimeBetweenEvents.py +0 -0
  101. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/SimulateTimeUntilNEvents.py +0 -0
  102. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/simulations/__init__.py +0 -0
  103. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/statistics/CalculateConfidenceIntervalOfMean.py +0 -0
  104. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/statistics/CalculateConfidenceIntervalOfProportion.py +0 -0
  105. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/statistics/__init__.py +0 -0
  106. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/Plot100PercentStackedBarChart.py +0 -0
  107. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotBarChart.py +0 -0
  108. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotBoxWhiskerByGroup.py +0 -0
  109. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotBulletChart.py +0 -0
  110. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotCard.py +0 -0
  111. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotClusteredBarChart.py +0 -0
  112. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotContingencyHeatmap.py +0 -0
  113. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotCorrelationMatrix.py +0 -0
  114. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotDensityByGroup.py +0 -0
  115. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotDotPlot.py +0 -0
  116. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotHeatmap.py +0 -0
  117. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotOverlappingAreaChart.py +0 -0
  118. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotRiskTolerance.py +0 -0
  119. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotScatterplot.py +0 -0
  120. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotSingleVariableCountPlot.py +0 -0
  121. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotSingleVariableHistogram.py +0 -0
  122. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/PlotTimeSeries.py +0 -0
  123. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/RenderTableOne.py +0 -0
  124. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox/visualizations/__init__.py +0 -0
  125. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox.egg-info/SOURCES.txt +0 -0
  126. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox.egg-info/dependency_links.txt +0 -0
  127. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox.egg-info/requires.txt +0 -0
  128. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/analysistoolbox.egg-info/top_level.txt +0 -0
  129. {analysistoolbox-2.1.8 → analysistoolbox-2.2.0}/setup.cfg +0 -0
@@ -0,0 +1,2227 @@
1
+ Metadata-Version: 2.1
2
+ Name: analysistoolbox
3
+ Version: 2.2.0
4
+ Summary: A collection tools in Python for data collection and processing, statistics, analytics, and intelligence analysis.
5
+ Home-page: https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox
6
+ Author: Kyle Protho
7
+ Author-email: kyletprotho@gmail.com
8
+ License: GNU GPLv3
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE.md
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest>=3.7; extra == "dev"
17
+ Requires-Dist: twine>=4.0.2; extra == "dev"
18
+
19
+ # Analysis Tool Box
20
+
21
+ <p align="center">
22
+ <img src="Square logo - White background.png" width="40%">
23
+ </p>
24
+
25
+ ## Description
26
+
27
+ Analysis Tool Box (i.e. "analysistoolbox") is a collection of tools in Python for data collection and processing, statisitics, analytics, and intelligence analysis.
28
+
29
+ ## Getting Started
30
+
31
+ To install the package, run the following command in the root directory of the project:
32
+
33
+ ```bash
34
+ pip install analysistoolbox
35
+ ```
36
+
37
+ Visualizations are created using the matplotlib and seaborn libraries. While you can select whichever seaborn style you'd like, the following Seaborn style tends to get the best looking plots:
38
+
39
+ ```python
40
+ sns.set(
41
+ style="white",
42
+ font="Arial",
43
+ context="paper"
44
+ )
45
+ ```
46
+
47
+ ## Table of Contents / Usage
48
+
49
+ There are many modules in the analysistoolbox package, each with their own functions. The following is a list of the modules:
50
+
51
+ - [Calculus](#calculus)
52
+ - [FindDerivative](#findderivative)
53
+ - [FindLimitOfFunction](#findlimitoffunction)
54
+ - [FindMinimumSquareLoss](#findminimumsquareloss)
55
+ - [PlotFunction](#plotfunction)
56
+ - [Data Collection](#data-collection)
57
+ - [ExtractTextFromPDF](#extracttextfrompdf)
58
+ - [FetchPDFFromURL](#fetchpdffromurl)
59
+ - [FetchUSShapefile](#fetchusshapefile)
60
+ - [FetchWebsiteText](#fetchwebsitetext)
61
+ - [GetCompanyFilings](#getcompanyfilings)
62
+ - [GetGoogleSearchResults](#getgooglesearchresults)
63
+ - [GetZipFile](#getzipfile)
64
+ - [Data Processing](#data-processing)
65
+ - [AddDateNumberColumns](#adddatenumbercolumns)
66
+ - [AddLeadingZeros](#addleadingzeros)
67
+ - [AddRowCountColumn](#addrowcountcolumn)
68
+ - [AddTPeriodColumn](#addtperiodcolumn)
69
+ - [AddTukeyOutlierColumn](#addtukeyoutliercolumn)
70
+ - [CleanTextColumns](#cleantextcolumns)
71
+ - [ConductAnomalyDetection](#conductanomalydetection)
72
+ - [ConductEntityMatching](#conductentitymatching)
73
+ - [ConvertOddsToProbability](#convertdoddsprobability)
74
+ - [CountMissingDataByGroup](#countmissingdatabygroup)
75
+ - [CreateBinnedColumn](#createbinnedcolumn)
76
+ - [CreateDataOverview](#createdataoverview)
77
+ - [CreateRandomSampleGroups](#createrandomsamplegroups)
78
+ - [CreateRareCategoryColumn](#createrarecategorycolumn)
79
+ - [CreateStratifiedRandomSampleGroups](#createstratifiedrandomsamplegroups)
80
+ - [ImputeMissingValuesUsingNearestNeighbors](#imputemissingvaluesusingnearestneighbors)
81
+ - [VerifyGranularity](#verifygranularity)
82
+ - [Descriptive Analytics](#descriptive-analytics)
83
+ - [ConductManifoldLearning](#conductmanifoldlearning)
84
+ - [ConductPrincipalComponentAnalysis](#conductprincipalcomponentanalysis)
85
+ - [ConductPropensityScoreMatching](#conductpropensityscorematching)
86
+ - [CreateAssociationRules](#createassociationrules)
87
+ - [CreateGaussianMixtureClusters](#creategaussianmixtureclusters)
88
+ - [CreateHierarchicalClusters](#createhierarchicalclusters)
89
+ - [CreateKMeansClusters](#createkmeansclusters)
90
+ - [GenerateEDAWithLIDA](#generatedewithlida)
91
+ - [File Management](#file-management)
92
+ - [ImportDataFromFolder](#importdatafromfolder)
93
+ - [CreateFileTree](#createfiletree)
94
+ - [CreateCopyOfPDF](#createcopyofpdf)
95
+ - [ConvertWordDocsToPDF](#convertworddocstopdf)
96
+ - [Hypothesis Testing](#hypothesis-testing)
97
+ - [ChiSquareTestOfIndependence](#chisquaretestofindependence)
98
+ - [ChiSquareTestOfIndependenceFromTable](#chisquaretestofindependencefromtable)
99
+ - [ConductCoxProportionalHazardRegression](#conductcoxproportionalhazardregression)
100
+ - [ConductLinearRegressionAnalysis](#conductlinearregressionanalysis)
101
+ - [ConductLogisticRegressionAnalysis](#conductlogisticregressionanalysis)
102
+ - [OneSampleTTest](#onesamplettest)
103
+ - [OneWayANOVA](#onewayanova)
104
+ - [TTestOfMeanFromStats](#ttestofmeanfromstats)
105
+ - [TTestOfProportionFromStats](#ttestofproportionfromstats)
106
+ - [TTestOfTwoMeansFromStats](#ttestoftwomeansfromstats)
107
+ - [TwoSampleTTestOfIndependence](#twosampletestofindependence)
108
+ - [TwoSampleTTestPaired](#twosampletestpaired)
109
+ - [Linear Algebra](#linear-algebra)
110
+ - [CalculateEigenvalues](#calculateeigenvalues)
111
+ - [ConvertMatrixToRowEchelonForm](#convertmatrixtorowechelonform)
112
+ - [ConvertSystemOfEquationsToMatrix](#convertsystemofequationstomatrix)
113
+ - [PlotVectors](#plotvectors)
114
+ - [SolveSystemOfEquations](#solvesystemofequations)
115
+ - [VisualizeMatrixAsLinearTransformation](#visualizematrixaslineartransformation)
116
+ - [LLM](#llm)
117
+ - [SendPromptToAnthropic](#sendprompttoanthropic)
118
+ - [SendPromptToChatGPT](#sendprompttochatgpt)
119
+ - [Predictive Analytics](#predictive-analytics)
120
+ - [CreateARIMAModel](#createarimamodel)
121
+ - [CreateBoostedTreeModel](#createboostedtreemodel)
122
+ - [CreateDecisionTreeModel](#createdecisiontreemodel)
123
+ - [CreateLinearRegressionModel](#createlinearregressionmodel)
124
+ - [CreateLogisticRegressionModel](#createlogisticregressionmodel)
125
+ - [CreateNeuralNetwork_SingleOutcome](#createneuralnetwork_singleoutcome)
126
+ - [Prescriptive Analytics](#prescriptive-analytics)
127
+ - [CreateContentBasedRecommender](#createcontentbasedrecommender)
128
+ - [Probability](#probability)
129
+ - [ProbabilityOfAtLeastOne](#probabilityofatleastone)
130
+ - [Simulations](#simulations)
131
+ - [CreateMetalogDistribution](#createmetalogdistribution)
132
+ - [CreateMetalogDistributionFromPercentiles](#createmetalogdistributionfrompercentiles)
133
+ - [CreateSIPDataframe](#createsipdataframe)
134
+ - [CreateSLURPDistribution](#createslurpdistribution)
135
+ - [SimulateCountOfSuccesses](#simulatecountofsuccesses)
136
+ - [SimulateCountOutcome](#simulatecountoutcome)
137
+ - [SimulateCountUntilFirstSuccess](#simulatecountuntilfirstsuccess)
138
+ - [SimulateNormallyDistributedOutcome](#simulatenormallydistributedoutcome)
139
+ - [SimulateTDistributedOutcome](#simulatetdistributedoutcome)
140
+ - [SimulateTimeBetweenEvents](#simulatetimebetweenevents)
141
+ - [SimulateTimeUntilNEvents](#simulatetimeuntilnevents)
142
+ - [Statistics](#statistics)
143
+ - [CalculateConfidenceIntervalOfMean](#calculateconfidenceintervalofmean)
144
+ - [CalculateConfidenceIntervalOfProportion](#calculateconfidenceintervalofproportion)
145
+ - [Visualizations](#visualizations)
146
+ - [Plot100PercentStackedBarChart](#plot100percentstackedbarchart)
147
+ - [PlotBarChart](#plotbarchart)
148
+ - [PlotBoxWhiskerByGroup](#plotboxwhiskerbygroup)
149
+ - [PlotBulletChart](#plotbulletchart)
150
+ - [PlotCard](#plotcard)
151
+ - [PlotClusteredBarChart](#plotclusteredbarchart)
152
+ - [PlotContingencyHeatmap](#plotcontingencyheatmap)
153
+ - [PlotCorrelationMatrix](#plotcorrelationmatrix)
154
+ - [PlotDensityByGroup](#plotdensitybygroup)
155
+ - [PlotDotPlot](#plotdotplot)
156
+ - [PlotHeatmap](#plotheatmap)
157
+ - [PlotOverlappingAreaChart](#plotoverlappingareachart)
158
+ - [PlotRiskTolerance](#plotrisktolerance)
159
+ - [PlotScatterplot](#plotscatterplot)
160
+ - [PlotSingleVariableCountPlot](#plotsinglevariablecountplot)
161
+ - [PlotSingleVariableHistogram](#plotsinglevariablehistogram)
162
+ - [PlotTimeSeries](#plottimeseries)
163
+ - [RenderTableOne](#rendertableone)
164
+
165
+
166
+ ### Calculus
167
+
168
+ #### FindDerivative
169
+
170
+ The **FindDerivative** function calculates the derivative of a given function. It uses the sympy library, a Python library for symbolic mathematics, to perform the differentiation. The function also has the capability to print the original function and its derivative, return the derivative function, and plot both the original function and its derivative.
171
+
172
+ ```python
173
+ # Load the FindDerivative function from the Calculus submodule
174
+ from analysistoolbox.calculus import FindDerivative
175
+ import sympy
176
+
177
+ # Define a symbolic variable
178
+ x = sympy.symbols('x')
179
+
180
+ # Define a function
181
+ f_of_x = x**3 + 2*x**2 + 3*x + 4
182
+
183
+ # Use the FindDerivative function
184
+ FindDerivative(
185
+ f_of_x,
186
+ print_functions=True,
187
+ return_derivative_function=True,
188
+ plot_functions=True
189
+ )
190
+ ```
191
+
192
+ #### FindLimitOfFunction
193
+
194
+ The **FindLimitOfFunction** function finds the limit of a function at a specific point and optionally plot the function and its tangent line at that point. The script uses the matplotlib and numpy libraries for plotting and numerical operations respectively.
195
+
196
+ ```python
197
+ # Import the necessary libraries
198
+ from analysistoolbox.calculus import FindLimitOfFunction
199
+ import numpy as np
200
+ import sympy
201
+
202
+ # Define a symbolic variable
203
+ x = sympy.symbols('x')
204
+
205
+ # Define a function
206
+ f_of_x = np.sin(x) / x
207
+
208
+ # Use the FindLimitOfFunction function
209
+ FindLimitOfFunction(
210
+ f_of_x,
211
+ point=0,
212
+ step=0.01,
213
+ plot_function=True,
214
+ x_minimum=-10,
215
+ x_maximum=10,
216
+ n=1000,
217
+ tangent_line_window=1
218
+ )
219
+ ```
220
+
221
+ #### FindMinimumSquareLoss
222
+
223
+ The **FindMinimumSquareLoss** function calculates the minimum square loss between observed and predicted values. This function is often used in machine learning and statistics to measure the average squared difference between the actual and predicted outcomes.
224
+
225
+ ```python
226
+ # Import the necessary libraries
227
+ from analysistoolbox.calculus import FindMinimumSquareLoss
228
+
229
+ # Define observed and predicted values
230
+ observed_values = [1, 2, 3, 4, 5]
231
+ predicted_values = [1.1, 1.9, 3.2, 3.7, 5.1]
232
+
233
+ # Use the FindMinimumSquareLoss function
234
+ minimum_square_loss = FindMinimumSquareLoss(
235
+ observed_values,
236
+ predicted_values,
237
+ show_plot=True
238
+ )
239
+
240
+ # Print the minimum square loss
241
+ print(f"The minimum square loss is: {minimum_square_loss}")
242
+ ```
243
+
244
+ #### PlotFunction
245
+
246
+ The **PlotFunction** function plots a mathematical function of x. It takes a lambda function as input and allows for customization of the plot.
247
+
248
+ ```python
249
+ # Import the necessary libraries
250
+ from analysistoolbox.calculus import PlotFunction
251
+ import sympy
252
+
253
+ # Set x as a symbolic variable
254
+ x = sympy.symbols('x')
255
+
256
+ # Define the function to plot
257
+ f_of_x = lambda x: x**2
258
+
259
+ # Plot the function with default settings
260
+ PlotFunction(f_of_x)
261
+ ```
262
+
263
+ ### Data Collection
264
+
265
+ #### ExtractTextFromPDF
266
+
267
+ The **ExtractTextFromPDF** function extracts text from a PDF file, cleans it, then saves it to a text file.
268
+
269
+ ```python
270
+ # Import the function
271
+ from analysistoolbox.data_collection import ExtractTextFromPDF
272
+
273
+ # Call the function
274
+ ExtractTextFromPDF(
275
+ filepath_to_pdf="/path/to/your/input.pdf",
276
+ filepath_for_exported_text="/path/to/your/output.txt",
277
+ start_page=1,
278
+ end_page=None
279
+ )
280
+ ```
281
+
282
+ #### FetchPDFFromURL
283
+
284
+ The **FetchPDFFromURL** function downloads a PDF file from a URL and saves it to a specified location.
285
+
286
+ ```python
287
+ # Import the function
288
+ from analysistoolbox.data_collection import FetchPDFFromURL
289
+
290
+ # Call the function to download the PDF
291
+ FetchPDFFromURL(
292
+ url="https://example.com/sample.pdf",
293
+ filename="C:/folder/sample.pdf"
294
+ )
295
+ ```
296
+
297
+ #### FetchUSShapefile
298
+
299
+ The **FetchUSShapefile** function fetches a geographical shapefile from the TIGER database of the U.S. Census Bureau.
300
+
301
+ ```python
302
+ # Import the function
303
+ from analysistoolbox.data_collection import FetchUSShapefile
304
+
305
+ # Fetch the shapefile for the census tracts in King County, Washington, for the 2021 census year
306
+ shapefile = FetchUSShapefile(
307
+ state='PA',
308
+ county='Allegheny',
309
+ geography='tract',
310
+ census_year=2021
311
+ )
312
+
313
+ # Print the first few rows of the shapefile
314
+ print(shapefile.head())
315
+ ```
316
+
317
+ #### FetchWebsiteText
318
+
319
+ The **FetchWebsiteText** function fetches the text from a website and saves it to a text file.
320
+
321
+ ```python
322
+ # Import the function
323
+ from analysistoolbox.data_collection import FetchWebsiteText
324
+
325
+ # Call the function
326
+ text = FetchWebsiteText(
327
+ url="https://www.example.com",
328
+ browserless_api_key="your_browserless_api_key"
329
+ )
330
+
331
+ # Print the fetched text
332
+ print(text)
333
+ ```
334
+
335
+ #### GetCompanyFilings
336
+
337
+ The **GetCompanyFilings** function fetches company filings from the SEC EDGAR database. It returns a list of filings for a given company CIK (Central Index Key) and filing type.
338
+
339
+ ```python
340
+ # Import the function
341
+ from analysistoolbox.data_collection import GetCompanyFilings
342
+
343
+ # Call the function to get company filings for 'Online Dating' companies in 2024
344
+ results = GetCompanyFilings(
345
+ search_keywords="Online Dating",
346
+ start_date="2024-01-01",
347
+ end_date="2024-12-31",
348
+ filing_type="all",
349
+ )
350
+
351
+ # Print the results
352
+ print(results)
353
+ ```
354
+
355
+ #### GetGoogleSearchResults
356
+
357
+ The **GetGoogleSearchResults** function fetches Google search results for a given query using the Serper API.
358
+
359
+ ```python
360
+ # Import the function
361
+ from analysistoolbox.data_collection import GetGoogleSearchResults
362
+
363
+ # Call the function with the query
364
+ # Make sure to replace 'your_serper_api_key' with your actual Serper API key
365
+ results = GetGoogleSearchResults(
366
+ query="Python programming",
367
+ serper_api_key='your_serper_api_key',
368
+ number_of_results=5,
369
+ apply_autocorrect=True,
370
+ display_results=True
371
+ )
372
+
373
+ # Print the results
374
+ print(results)
375
+ ```
376
+
377
+ #### GetZipFile
378
+
379
+ The **GetZipFile** function downloads a zip file from a url and saves it to a specified folder. It can also unzip the file and print the contents of the zip file.
380
+
381
+ ```python
382
+ # Import the function
383
+ from analysistoolbox.data_collection import GetZipFile
384
+
385
+ # Call the function
386
+ GetZipFile(
387
+ url="http://example.com/file.zip",
388
+ path_to_save_folder="/path/to/save/folder"
389
+ )
390
+ ```
391
+
392
+ ### Data Processing
393
+
394
+ #### AddDateNumberColumns
395
+
396
+ The **AddDateNumberColumns** function adds columns for the year, month, quarter, week, day of the month, and day of the week to a dataframe.
397
+
398
+ ```python
399
+ # Import necessary packages
400
+ from analysistoolbox.data_processing import AddDateNumberColumns
401
+ from datetime import datetime
402
+ import pandas as pd
403
+
404
+ # Create a sample dataframe
405
+ data = {'Date': [datetime(2020, 1, 1), datetime(2020, 2, 1), datetime(2020, 3, 1), datetime(2020, 4, 1)]}
406
+ df = pd.DataFrame(data)
407
+
408
+ # Use the function on the sample dataframe
409
+ df = AddDateNumberColumns(
410
+ dataframe=df,
411
+ date_column_name='Date'
412
+ )
413
+
414
+ # Print the updated dataframe
415
+ print(df)
416
+ ```
417
+
418
+ #### AddLeadingZeros
419
+
420
+ The **AddLeadingZeros** function adds leading zeros to a column. If fixed_length is not specified, the longest string in the column is used as the fixed length. If add_as_new_column is set to True, the new column is added to the dataframe. Otherwise, the original column is updated.
421
+
422
+ ```python
423
+ # Import necessary packages
424
+ from analysistoolbox.data_processing import AddLeadingZeros
425
+ import pandas as pd
426
+
427
+ # Create a sample dataframe
428
+ data = {'ID': [1, 23, 456, 7890]}
429
+ df = pd.DataFrame(data)
430
+
431
+ # Use the AddLeadingZeros function
432
+ df = AddLeadingZeros(
433
+ dataframe=df,
434
+ column_name='ID',
435
+ add_as_new_column=True
436
+ )
437
+
438
+ # Print updated dataframe
439
+ print(df)
440
+ ```
441
+
442
+ #### AddRowCountColumn
443
+
444
+ The **AddRowCountColumn** function adds a column to a dataframe that contains the row number for each row, based on a group (or groups) of columns. The function can also sort the dataframe by a column or columns before adding the row count column.
445
+
446
+ ```python
447
+ # Import necessary packages
448
+ from analysistoolbox.data_processing import AddRowCountColumn
449
+ import pandas as pd
450
+
451
+ # Create a sample dataframe
452
+ data = {
453
+ 'Payment Method': ['Check', 'Credit Card', 'Check', 'Credit Card', 'Check', 'Credit Card', 'Check', 'Credit Card'],
454
+ 'Transaction Value': [100, 200, 300, 400, 500, 600, 700, 800],
455
+ 'Transaction Order': [1, 2, 3, 4, 5, 6, 7, 8]
456
+ }
457
+ df = pd.DataFrame(data)
458
+
459
+ # Call the function
460
+ df_updated = AddRowCountColumn(
461
+ dataframe=df,
462
+ list_of_grouping_variables=['Payment Method'],
463
+ list_of_order_columns=['Transaction Order'],
464
+ list_of_ascending_order_args=[True]
465
+ )
466
+
467
+ # Print the updated dataframe
468
+ print(df_updated)
469
+ ```
470
+
471
+ #### AddTPeriodColumn
472
+
473
+ The **AddTPeriodColumn** function adds a T-period column to a dataframe. The T-period column is the number of intervals (e.g., days or weeks) since the earliest date in the dataframe.
474
+
475
+ ```python
476
+ # Import necessary libraries
477
+ from analysistoolbox.data_processing import AddTPeriodColumn
478
+ from datetime import datetime
479
+ import pandas as pd
480
+
481
+ # Create a sample dataframe
482
+ data = {
483
+ 'date': pd.date_range(start='1/1/2020', end='1/10/2020'),
484
+ 'value': range(1, 11)
485
+ }
486
+ df = pd.DataFrame(data)
487
+
488
+ # Use the function
489
+ df_updated = AddTPeriodColumn(
490
+ dataframe=df,
491
+ date_column_name='date',
492
+ t_period_interval='days'
493
+ )
494
+
495
+ # Print the updated dataframe
496
+ print(df_updated)
497
+ ```
498
+
499
+ #### AddTukeyOutlierColumn
500
+
501
+ The **AddTukeyOutlierColumn** function adds a column to a dataframe that indicates whether a value is an outlier. The function uses the Tukey method to identify outliers.
502
+
503
+ ```python
504
+ # Import necessary libraries
505
+ from analysistoolbox.data_processing import AddTukeyOutlierColumn
506
+ import pandas as pd
507
+
508
+ # Create a sample dataframe
509
+ data = pd.DataFrame({'values': [1, 2, 3, 4, 5, 6, 7, 8, 9, 20]})
510
+
511
+ # Use the function
512
+ df_updated = AddTukeyOutlierColumn(
513
+ dataframe=data,
514
+ value_column_name='values',
515
+ tukey_boundary_multiplier=1.5,
516
+ plot_tukey_outliers=True
517
+ )
518
+
519
+ # Print the updated dataframe
520
+ print(df_updated)
521
+ ```
522
+
523
+ #### CleanTextColumns
524
+
525
+ The **CleanTextColumns** function cleans string-type columns in a pandas DataFrame by removing all leading and trailing spaces.
526
+
527
+ ```python
528
+ # Import necessary libraries
529
+ from analysistoolbox.data_processing import CleanTextColumns
530
+ import pandas as pd
531
+
532
+ # Create a sample dataframe
533
+ df = pd.DataFrame({
534
+ 'A': [' hello', 'world ', ' python '],
535
+ 'B': [1, 2, 3],
536
+ })
537
+
538
+ # Clean the dataframe
539
+ df_clean = CleanTextColumns(df)
540
+ ```
541
+
542
+ #### ConductAnomalyDetection
543
+
544
+ The **ConductAnomalyDetection** function performs anomaly detection on a given dataset using the z-score method.
545
+
546
+ ```python
547
+ # Import necessary libraries
548
+ from analysistoolbox.data_processing import ConductAnomalyDetection
549
+ import pandas as pd
550
+
551
+ # Create a sample dataframe
552
+ df = pd.DataFrame({
553
+ 'A': [1, 2, 3, 1000],
554
+ 'B': [4, 5, 6, 2000],
555
+ })
556
+
557
+ # Conduct anomaly detection
558
+ df_anomaly_detected = ConductAnomalyDetection(
559
+ dataframe=df,
560
+ list_of_columns_to_analyze=['A', 'B']
561
+ )
562
+
563
+ # Print the updated dataframe
564
+ print(df_anomaly_detected)
565
+ ```
566
+
567
+ #### ConductEntityMatching
568
+
569
+ The **ConductEntityMatching** function performs entity matching between two dataframes using various fuzzy matching algorithms.
570
+
571
+ ```python
572
+ from analysistoolbox.data_processing import ConductEntityMatching
573
+ import pandas as pd
574
+
575
+ # Create two dataframes
576
+ dataframe_1 = pd.DataFrame({
577
+ 'ID': ['1', '2', '3'],
578
+ 'Name': ['John Doe', 'Jane Smith', 'Bob Johnson'],
579
+ 'City': ['New York', 'Los Angeles', 'Chicago']
580
+ })
581
+
582
+ dataframe_2 = pd.DataFrame({
583
+ 'ID': ['a', 'b', 'c'],
584
+ 'Name': ['Jon Doe', 'Jane Smyth', 'Robert Johnson'],
585
+ 'City': ['NYC', 'LA', 'Chicago']
586
+ })
587
+
588
+ # Conduct entity matching
589
+ matched_entities = ConductEntityMatching(
590
+ dataframe_1=dataframe_1,
591
+ dataframe_1_primary_key='ID',
592
+ dataframe_2=dataframe_2,
593
+ dataframe_2_primary_key='ID',
594
+ levenshtein_distance_filter=3,
595
+ match_score_threshold=80,
596
+ columns_to_compare=['Name', 'City'],
597
+ match_methods=['Partial Token Set Ratio', 'Weighted Ratio']
598
+ )
599
+ ```
600
+
601
+ #### ConvertOddsToProbability
602
+
603
+ The **ConvertOddsToProbability** function converts odds to probability in a new column.
604
+
605
+ ```python
606
+ # Import necessary packages
607
+ from analysistoolbox.data_processing import ConvertOddsToProbability
608
+ import pandas as pd
609
+
610
+ # Create a sample dataframe
611
+ data = {
612
+ 'Team': ['Team1', 'Team2', 'Team3', 'Team4'],
613
+ 'Odds': [2.5, 1.5, 3.0, np.nan]
614
+ }
615
+ df = pd.DataFrame(data)
616
+
617
+ # Print the original dataframe
618
+ print("Original DataFrame:")
619
+ print(df)
620
+
621
+ # Use the function to convert odds to probability
622
+ df = ConvertOddsToProbability(
623
+ dataframe=df,
624
+ odds_column='Odds'
625
+ )
626
+ ```
627
+
628
+ #### CountMissingDataByGroup
629
+
630
+ The **CountMissingDataByGroup** function counts the number of records with missing data in a Pandas dataframe, grouped by specified columns.
631
+
632
+ ```python
633
+ # Import necessary packages
634
+ from analysistoolbox.data_processing import CountMissingDataByGroup
635
+ import pandas as pd
636
+ import numpy as np
637
+
638
+ # Create a sample dataframe with some missing values
639
+ data = {
640
+ 'Group': ['A', 'B', 'A', 'B', 'A', 'B'],
641
+ 'Value1': [1, 2, np.nan, 4, 5, np.nan],
642
+ 'Value2': [np.nan, 8, 9, 10, np.nan, 12]
643
+ }
644
+ df = pd.DataFrame(data)
645
+
646
+ # Use the function to count missing data by group
647
+ CountMissingDataByGroup(
648
+ dataframe=df,
649
+ list_of_grouping_columns=['Group']
650
+ )
651
+ ```
652
+
653
+ #### CreateBinnedColumn
654
+
655
+ The **CreateBinnedColumn** function creates a new column in a Pandas dataframe based on a numeric variable. Binning is a process of transforming continuous numerical variables into discrete categorical 'bins'.
656
+
657
+ ```python
658
+ # Import necessary packages
659
+ from analysistoolbox.data_processing import CreateBinnedColumn
660
+ import pandas as pd
661
+ import numpy as np
662
+
663
+ # Create a sample dataframe
664
+ data = {
665
+ 'Group': ['A', 'B', 'A', 'B', 'A', 'B'],
666
+ 'Value1': [1, 2, 3, 4, 5, 6],
667
+ 'Value2': [7, 8, 9, 10, 11, 12]
668
+ }
669
+ df = pd.DataFrame(data)
670
+
671
+ # Use the function to create a binned column
672
+ df_binned = CreateBinnedColumn(
673
+ dataframe=df,
674
+ numeric_column_name='Value1',
675
+ number_of_bins=3,
676
+ binning_strategy='uniform'
677
+ )
678
+ ```
679
+
680
+ #### CreateDataOverview
681
+
682
+ The **CreateDataOverview** function creates an overview of a Pandas dataframe, including the data type, missing count, missing percentage, and summary statistics for each variable in the DataFrame.
683
+
684
+ ```python
685
+ # Import necessary packages
686
+ from analysistoolbox.data_processing import CreateDataOverview
687
+ import pandas as pd
688
+ import numpy as np
689
+
690
+ # Create a sample dataframe
691
+ data = {
692
+ 'Column1': [1, 2, 3, np.nan, 5, 6],
693
+ 'Column2': ['a', 'b', 'c', 'd', np.nan, 'f'],
694
+ 'Column3': [7.1, 8.2, 9.3, 10.4, np.nan, 12.5]
695
+ }
696
+ df = pd.DataFrame(data)
697
+
698
+ # Use the function to create an overview of the dataframe
699
+ CreateDataOverview(
700
+ dataframe=df,
701
+ plot_missingness=True
702
+ )
703
+ ```
704
+
705
+ #### CreateRandomSampleGroups
706
+
707
+ The **CreateRandomSampleGroups** function a takes a pandas DataFrame, shuffle its rows, assign each row to one of n groups, and then return the updated DataFrame with an additional column indicating the group number.
708
+
709
+ ```python
710
+ # Import necessary packages
711
+ from analysistoolbox.data_processing import CreateRandomSampleGroups
712
+ import pandas as pd
713
+
714
+ # Create a sample DataFrame
715
+ data = {
716
+ 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
717
+ 'Age': [25, 31, 35, 19, 45],
718
+ 'Score': [85, 95, 78, 81, 92]
719
+ }
720
+ df = pd.DataFrame(data)
721
+
722
+ # Use the function
723
+ grouped_df = CreateRandomSampleGroups(
724
+ dataframe=df,
725
+ number_of_groups=2,
726
+ random_seed=123
727
+ )
728
+ ```
729
+
730
+ #### CreateRareCategoryColumn
731
+
732
+ The **CreateRareCategoryColumn** function creates a new column in a Pandas dataframe that indicates whether a categorical variable value is rare. A rare category is a category that occurs less than a specified percentage of the time.
733
+
734
+ ```python
735
+ # Import necessary packages
736
+ from analysistoolbox.data_processing import CreateRareCategoryColumn
737
+ import pandas as pd
738
+
739
+ # Create a sample DataFrame
740
+ data = {
741
+ 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Alice', 'Bob', 'Alice'],
742
+ 'Age': [25, 31, 35, 19, 45, 23, 30, 24],
743
+ 'Score': [85, 95, 78, 81, 92, 88, 90, 86]
744
+ }
745
+ df = pd.DataFrame(data)
746
+
747
+ # Use the function
748
+ updated_df = CreateRareCategoryColumn(
749
+ dataframe=df,
750
+ categorical_column_name='Name',
751
+ rare_category_label='Rare',
752
+ rare_category_threshold=0.05,
753
+ new_column_suffix='(rare category)'
754
+ )
755
+ ```
756
+
757
+ #### CreateStratifiedRandomSampleGroups
758
+
759
+ The **CreateStratifiedRandomSampleGroups** unction performs stratified random sampling on a pandas DataFrame. Stratified random sampling is a method of sampling that involves the division of a population into smaller groups known as strata. In stratified random sampling, the strata are formed based on members' shared attributes or characteristics.
760
+
761
+ ```python
762
+ # Import necessary packages
763
+ from analysistoolbox.data_processing import CreateStratifiedRandomSampleGroups
764
+ import numpy as np
765
+ import pandas as pd
766
+
767
+ # Create a sample DataFrame
768
+ data = {
769
+ 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Alice', 'Bob', 'Alice'],
770
+ 'Age': [25, 31, 35, 19, 45, 23, 30, 24],
771
+ 'Score': [85, 95, 78, 81, 92, 88, 90, 86]
772
+ }
773
+ df = pd.DataFrame(data)
774
+
775
+ # Use the function
776
+ stratified_df = CreateStratifiedRandomSampleGroups(
777
+ dataframe=df,
778
+ number_of_groups=2,
779
+ list_categorical_column_names=['Name'],
780
+ random_seed=42
781
+ )
782
+ ```
783
+
784
+ #### ImputeMissingValuesUsingNearestNeighbors
785
+
786
+ The **ImputeMissingValuesUsingNearestNeighbors** function imputes missing values in a dataframe using the nearest neighbors method. For each sample with missing values, it finds the n_neighbors nearest neighbors in the training set and imputes the missing values using the mean value of these neighbors.
787
+
788
+ ```python
789
+ # Import necessary packages
790
+ from analysistoolbox.data_processing import ImputeMissingValuesUsingNearestNeighbors
791
+ import pandas as pd
792
+ import numpy as np
793
+
794
+ # Create a sample DataFrame with missing values
795
+ data = {
796
+ 'A': [1, 2, np.nan, 4, 5],
797
+ 'B': [np.nan, 2, 3, 4, 5],
798
+ 'C': [1, 2, 3, np.nan, 5],
799
+ 'D': [1, 2, 3, 4, np.nan]
800
+ }
801
+ df = pd.DataFrame(data)
802
+
803
+ # Use the function
804
+ imputed_df = ImputeMissingValuesUsingNearestNeighbors(
805
+ dataframe=df,
806
+ list_of_numeric_columns_to_impute=['A', 'B', 'C', 'D'],
807
+ number_of_neighbors=2,
808
+ averaging_method='uniform'
809
+ )
810
+ ```
811
+
812
+ #### VerifyGranularity
813
+
814
+ The **VerifyGranularity** function checks the granularity of a given dataframe based on a list of key columns. Granularity in this context refers to the level of detail or summarization in a set of data.
815
+
816
+ ```python
817
+ # Import necessary packages
818
+ from analysistoolbox.data_processing import VerifyGranularity
819
+ import pandas as pd
820
+
821
+ # Create a sample DataFrame
822
+ data = {
823
+ 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Alice', 'Bob', 'Alice'],
824
+ 'Age': [25, 31, 35, 19, 45, 23, 30, 24],
825
+ 'Score': [85, 95, 78, 81, 92, 88, 90, 86]
826
+ }
827
+ df = pd.DataFrame(data)
828
+
829
+ # Use the function
830
+ VerifyGranularity(
831
+ dataframe=df,
832
+ list_of_key_columns=['Name', 'Age'],
833
+ set_key_as_index=True,
834
+ print_as_markdown=False
835
+ )
836
+ ```
837
+
838
+ ### Descriptive Analytics
839
+
840
+ #### ConductManifoldLearning
841
+
842
+ The **ConductManifoldLearning** function performs manifold learning on a given dataframe and returns a new dataframe with the original columns and the new manifold learning components. Manifold learning is a type of unsupervised learning that is used to reduce the dimensionality of the data.
843
+
844
+ ```python
845
+ # Import necessary packages
846
+ from analysistoolbox.descriptive_analytics import ConductManifoldLearning
847
+ import pandas as pd
848
+ from sklearn.datasets import load_iris
849
+
850
+ # Load the iris dataset
851
+ iris = load_iris()
852
+ iris_df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
853
+
854
+ # Use the function
855
+ new_df = ConductManifoldLearning(
856
+ dataframe=iris_df,
857
+ list_of_numeric_columns=['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'],
858
+ number_of_components=2,
859
+ random_seed=42,
860
+ show_component_summary_plots=True,
861
+ sns_color_palette='Set2',
862
+ summary_plot_size=(10, 10)
863
+ )
864
+ ```
865
+
866
+ #### ConductPrincipalComponentAnalysis
867
+
868
+ The **ConductPrincipalComponentAnalysis** function performs Principal Component Analysis (PCA) on a given dataframe. PCA is a technique used in machine learning to reduce the dimensionality of data while retaining as much information as possible.
869
+
870
+ ```python
871
+ # Import necessary packages
872
+ from analysistoolbox.descriptive_analytics import ConductManifoldLearning
873
+ import pandas as pd
874
+ from sklearn.datasets import load_iris
875
+
876
+ # Load the iris dataset
877
+ iris = load_iris()
878
+ iris_df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
879
+
880
+ # Call the function
881
+ result = ConductPrincipalComponentAnalysis(
882
+ dataframe=iris_df,
883
+ list_of_numeric_columns=['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'],
884
+ number_of_components=2
885
+ )
886
+ ```
887
+
888
+ #### ConductPropensityScoreMatching
889
+
890
+ Conducts propensity score matching to create balanced treatment and control groups for causal inference analysis.
891
+
892
+ ```python
893
+ from analysistoolbox.descriptive_analytics import ConductPropensityScoreMatching
894
+ import pandas as pd
895
+
896
+ # Create matched groups based on age, education, and experience
897
+ matched_df = ConductPropensityScoreMatching(
898
+ dataframe=df,
899
+ subject_id_column_name='employee_id',
900
+ list_of_column_names_to_base_matching=['age', 'education', 'years_experience'],
901
+ grouping_column_name='received_training',
902
+ control_group_name='No',
903
+ max_matches_per_subject=1,
904
+ balance_groups=True,
905
+ propensity_score_column_name="PS_Score",
906
+ matched_id_column_name="Matched_Employee_ID",
907
+ random_seed=412
908
+ )
909
+ ```
910
+
911
+ #### CreateAssociationRules
912
+
913
+ The **CreateAssociationRules** function creates association rules from a given dataframe. Association rules are widely used in market basket analysis, where the goal is to find associations and/or correlations among a set of items.
914
+
915
+ ```python
916
+ # Import necessary packages
917
+ from analysistoolbox.descriptive_analytics import CreateAssociationRules
918
+ import pandas as pd
919
+
920
+ # Assuming you have a dataframe 'df' with 'TransactionID' and 'Item' columns
921
+ result = CreateAssociationRules(
922
+ dataframe=df,
923
+ transaction_id_column='TransactionID',
924
+ items_column='Item',
925
+ support_threshold=0.01,
926
+ confidence_threshold=0.2,
927
+ plot_lift=True,
928
+ plot_title='Association Rules',
929
+ plot_size=(10, 7)
930
+ )
931
+ ```
932
+
933
+ #### CreateGaussianMixtureClusters
934
+
935
+ The **CreateGaussianMixtureClusters** function creates Gaussian mixture clusters from a given dataframe. Gaussian mixture models are a type of unsupervised learning that is used to find clusters in data. It adds the resulting clusters as a new column in the dataframe, and also calculates the probability of each data point belonging to each cluster.
936
+
937
+ ```python
938
+ # Import necessary packages
939
+ from analysistoolbox.descriptive_analytics import CreateGaussianMixtureClusters
940
+ import pandas as pd
941
+ from sklearn import datasets
942
+
943
+ # Load the iris dataset
944
+ iris = datasets.load_iris()
945
+
946
+ # Convert the iris dataset to a pandas dataframe
947
+ df = pd.DataFrame(data= np.c_[iris['data'], iris['target']],
948
+ columns= iris['feature_names'] + ['target'])
949
+
950
+ # Call the CreateGaussianMixtureClusters function
951
+ df_clustered = CreateGaussianMixtureClusters(
952
+ dataframe=df,
953
+ list_of_numeric_columns_for_clustering=['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'],
954
+ number_of_clusters=3,
955
+ column_name_for_clusters='Gaussian Mixture Cluster',
956
+ scale_predictor_variables=True,
957
+ show_cluster_summary_plots=True,
958
+ sns_color_palette='Set2',
959
+ summary_plot_size=(15, 15),
960
+ random_seed=123,
961
+ maximum_iterations=200
962
+ )
963
+ ```
964
+
965
+ #### CreateHierarchicalClusters
966
+
967
+ The **CreateHierarchicalClusters** function creates hierarchical clusters from a given dataframe. Hierarchical clustering is a type of unsupervised learning that is used to find clusters in data. It adds the resulting clusters as a new column in the dataframe.
968
+
969
+ ```python
970
+ # Import necessary packages
971
+ from analysistoolbox.descriptive_analytics import CreateHierarchicalClusters
972
+ import pandas as pd
973
+ from sklearn import datasets
974
+
975
+ # Load the iris dataset
976
+ iris = datasets.load_iris()
977
+ df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
978
+
979
+ # Call the CreateHierarchicalClusters function
980
+ df_clustered = CreateHierarchicalClusters(
981
+ dataframe=df,
982
+ list_of_value_columns_for_clustering=['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'],
983
+ number_of_clusters=3,
984
+ column_name_for_clusters='Hierarchical Cluster',
985
+ scale_predictor_variables=True,
986
+ show_cluster_summary_plots=True,
987
+ color_palette='Set2',
988
+ summary_plot_size=(6, 4),
989
+ random_seed=412,
990
+ maximum_iterations=300
991
+ )
992
+ ```
993
+
994
+ #### CreateKMeansClusters
995
+
996
+ The **CreateKMeansClusters** function performs K-Means clustering on a given dataset and returns the dataset with an additional column indicating the cluster each record belongs to.
997
+
998
+ ```python
999
+ # Import necessary packages
1000
+ from analysistoolbox.descriptive_analytics import CreateKMeansClusters
1001
+ import pandas as pd
1002
+ from sklearn import datasets
1003
+
1004
+ # Load the iris dataset
1005
+ iris = datasets.load_iris()
1006
+ df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
1007
+
1008
+ # Call the CreateKMeansClusters function
1009
+ df_clustered = CreateKMeansClusters(
1010
+ dataframe=df,
1011
+ list_of_value_columns_for_clustering=['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'],
1012
+ number_of_clusters=3,
1013
+ column_name_for_clusters='K-Means Cluster',
1014
+ scale_predictor_variables=True,
1015
+ show_cluster_summary_plots=True,
1016
+ color_palette='Set2',
1017
+ summary_plot_size=(6, 4),
1018
+ random_seed=412,
1019
+ maximum_iterations=300
1020
+ )
1021
+ ```
1022
+
1023
+ #### GenerateEDAWithLIDA
1024
+
1025
+ The **GenerateEDAWithLIDA** function uses the LIDA package from Microsoft to generate exploratory data analysis (EDA) goals.
1026
+
1027
+ ```python
1028
+ # Import necessary packages
1029
+ from analysistoolbox.descriptive_analytics import GenerateEDAWithLIDA
1030
+ import pandas as pd
1031
+ from sklearn import datasets
1032
+
1033
+ # Load the iris dataset
1034
+ iris = datasets.load_iris()
1035
+ df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
1036
+
1037
+ # Call the GenerateEDAWithLIDA function
1038
+ df_summary = GenerateEDAWithLIDA(
1039
+ dataframe=df,
1040
+ llm_api_key="your_llm_api_key_here",
1041
+ llm_provider="openai",
1042
+ llm_model="gpt-3.5-turbo",
1043
+ visualization_library="seaborn",
1044
+ goal_temperature=0.50,
1045
+ code_generation_temperature=0.05,
1046
+ data_summary_method="llm",
1047
+ number_of_samples_to_show_in_summary=5,
1048
+ return_data_fields_summary=True,
1049
+ number_of_goals_to_generate=5,
1050
+ plot_recommended_visualization=True,
1051
+ show_code_for_recommended_visualization=True
1052
+ )
1053
+ ```
1054
+
1055
+ ### File Management
1056
+
1057
+ #### ImportDataFromFolder
1058
+
1059
+ The **ImportDataFromFolder** function imports all CSV and Excel files from a specified folder and combines them into a single DataFrame. It ensures that column names match across all files if specified.
1060
+
1061
+ ```python
1062
+ # Import necessary packages
1063
+ from analysistoolbox.file_management import ImportDataFromFolder
1064
+
1065
+ # Specify the folder path
1066
+ folder_path = "path/to/your/folder"
1067
+
1068
+ # Call the ImportDataFromFolder function
1069
+ combined_df = ImportDataFromFolder(
1070
+ folder_path=folder_path,
1071
+ force_column_names_to_match=True
1072
+ )
1073
+ ```
1074
+
1075
+ #### CreateFileTree
1076
+
1077
+ The **CreateFileTree** function recursively walks a directory tree and prints a diagram of all the subdirectories and files.
1078
+
1079
+ ```python
1080
+ # Import necessary packages
1081
+ from analysistoolbox.file_management import CreateFileTree
1082
+
1083
+ # Specify the directory path
1084
+ directory_path = "path/to/your/directory"
1085
+
1086
+ # Call the CreateFileTree function
1087
+ CreateFileTree(
1088
+ path=directory_path,
1089
+ indent_spaces=2
1090
+ )
1091
+ ```
1092
+
1093
+ #### CreateCopyOfPDF
1094
+
1095
+ The **CreateCopyOfPDF** function creates a copy of a PDF file, with options to specify the start and end pages.
1096
+
1097
+ ```python
1098
+ # Import necessary packages
1099
+ from analysistoolbox.file_management import CreateCopyOfPDF
1100
+
1101
+ # Specify the input and output file paths
1102
+ input_pdf = "path/to/input.pdf"
1103
+ output_pdf = "path/to/output.pdf"
1104
+
1105
+ # Call the CreateCopyOfPDF function
1106
+ CreateCopyOfPDF(
1107
+ input_file=input_pdf,
1108
+ output_file=output_pdf,
1109
+ start_page=1,
1110
+ end_page=5
1111
+ )
1112
+ ```
1113
+
1114
+ #### ConvertWordDocsToPDF
1115
+
1116
+ The **ConvertWordDocsToPDF** function converts all Word documents in a specified folder to PDF format.
1117
+
1118
+ ```python
1119
+ # Import necessary packages
1120
+ from analysistoolbox.file_management import ConvertWordDocsToPDF
1121
+
1122
+ # Specify the folder paths
1123
+ word_folder = "path/to/word/documents"
1124
+ pdf_folder = "path/to/save/pdf/documents"
1125
+
1126
+ # Call the ConvertWordDocsToPDF function
1127
+ ConvertWordDocsToPDF(
1128
+ word_folder_path=word_folder,
1129
+ pdf_folder_path=pdf_folder,
1130
+ open_each_doc=False
1131
+ )
1132
+ ```
1133
+
1134
+ ### Hypothesis Testing
1135
+
1136
+ #### ChiSquareTestOfIndependence
1137
+
1138
+ The **ChiSquareTestOfIndependence** function performs a chi-square test of independence to determine if there is a significant relationship between two categorical variables.
1139
+
1140
+ ```python
1141
+ from analysistoolbox.hypothesis_testing import ChiSquareTestOfIndependence
1142
+
1143
+ # Create sample data
1144
+ data = {
1145
+ 'Education': ['High School', 'College', 'High School', 'Graduate', 'College'],
1146
+ 'Employment': ['Employed', 'Unemployed', 'Employed', 'Employed', 'Unemployed']
1147
+ }
1148
+ df = pd.DataFrame(data)
1149
+
1150
+ # Conduct chi-square test
1151
+ ChiSquareTestOfIndependence(
1152
+ dataframe=df,
1153
+ first_categorical_column='Education',
1154
+ second_categorical_column='Employment',
1155
+ plot_contingency_table=True
1156
+ )
1157
+ ```
1158
+
1159
+ #### ChiSquareTestOfIndependenceFromTable
1160
+
1161
+ The **ChiSquareTestOfIndependenceFromTable** function performs a chi-square test using a pre-computed contingency table.
1162
+
1163
+ ```python
1164
+ from analysistoolbox.hypothesis_testing import ChiSquareTestOfIndependenceFromTable
1165
+
1166
+ # Create contingency table
1167
+ contingency_table = pd.DataFrame({
1168
+ 'Online': [100, 150],
1169
+ 'In-Store': [200, 175]
1170
+ }, index=['Male', 'Female'])
1171
+
1172
+ # Conduct chi-square test
1173
+ ChiSquareTestOfIndependenceFromTable(
1174
+ contingency_table=contingency_table,
1175
+ plot_contingency_table=True
1176
+ )
1177
+ ```
1178
+
1179
+ #### ConductCoxProportionalHazardRegression
1180
+
1181
+ The **ConductCoxProportionalHazardRegression** function performs survival analysis using Cox Proportional Hazard regression.
1182
+
1183
+ ```python
1184
+ from analysistoolbox.hypothesis_testing import ConductCoxProportionalHazardRegression
1185
+
1186
+ # Conduct Cox regression
1187
+ model = ConductCoxProportionalHazardRegression(
1188
+ dataframe=df,
1189
+ outcome_column='event',
1190
+ duration_column='time',
1191
+ list_of_predictor_columns=['age', 'sex', 'treatment'],
1192
+ plot_survival_curve=True
1193
+ )
1194
+ ```
1195
+
1196
+ #### ConductLinearRegressionAnalysis
1197
+
1198
+ The **ConductLinearRegressionAnalysis** function performs linear regression analysis with optional plotting.
1199
+
1200
+ ```python
1201
+ from analysistoolbox.hypothesis_testing import ConductLinearRegressionAnalysis
1202
+
1203
+ # Conduct linear regression
1204
+ results = ConductLinearRegressionAnalysis(
1205
+ dataframe=df,
1206
+ outcome_column='sales',
1207
+ list_of_predictor_columns=['advertising', 'price'],
1208
+ plot_regression_diagnostic=True
1209
+ )
1210
+ ```
1211
+
1212
+ #### ConductLogisticRegressionAnalysis
1213
+
1214
+ The **ConductLogisticRegressionAnalysis** function performs logistic regression for binary outcomes.
1215
+
1216
+ ```python
1217
+ from analysistoolbox.hypothesis_testing import ConductLogisticRegressionAnalysis
1218
+
1219
+ # Conduct logistic regression
1220
+ results = ConductLogisticRegressionAnalysis(
1221
+ dataframe=df,
1222
+ outcome_column='purchased',
1223
+ list_of_predictor_columns=['age', 'income'],
1224
+ plot_regression_diagnostic=True
1225
+ )
1226
+ ```
1227
+
1228
+ #### OneSampleTTest
1229
+
1230
+ The **OneSampleTTest** function performs a one-sample t-test to compare a sample mean to a hypothesized population mean.
1231
+
1232
+ ```python
1233
+ from analysistoolbox.hypothesis_testing import OneSampleTTest
1234
+
1235
+ # Conduct one-sample t-test
1236
+ OneSampleTTest(
1237
+ dataframe=df,
1238
+ outcome_column='score',
1239
+ hypothesized_mean=70,
1240
+ alternative_hypothesis='two-sided',
1241
+ confidence_interval=0.95
1242
+ )
1243
+ ```
1244
+
1245
+ #### OneWayANOVA
1246
+
1247
+ The **OneWayANOVA** function performs a one-way analysis of variance to compare means across multiple groups.
1248
+
1249
+ ```python
1250
+ from analysistoolbox.hypothesis_testing import OneWayANOVA
1251
+
1252
+ # Conduct one-way ANOVA
1253
+ OneWayANOVA(
1254
+ dataframe=df,
1255
+ outcome_column='performance',
1256
+ grouping_column='treatment_group',
1257
+ plot_sample_distributions=True
1258
+ )
1259
+ ```
1260
+
1261
+ #### TTestOfMeanFromStats
1262
+
1263
+ The **TTestOfMeanFromStats** function performs a t-test using summary statistics rather than raw data.
1264
+
1265
+ ```python
1266
+ from analysistoolbox.hypothesis_testing import TTestOfMeanFromStats
1267
+
1268
+ # Conduct t-test from statistics
1269
+ TTestOfMeanFromStats(
1270
+ sample_mean=75,
1271
+ sample_size=30,
1272
+ sample_standard_deviation=10,
1273
+ hypothesized_mean=70,
1274
+ alternative_hypothesis='greater'
1275
+ )
1276
+ ```
1277
+
1278
+ #### TTestOfProportionFromStats
1279
+
1280
+ The **TTestOfProportionFromStats** function tests a sample proportion against a hypothesized value.
1281
+
1282
+ ```python
1283
+ from analysistoolbox.hypothesis_testing import TTestOfProportionFromStats
1284
+
1285
+ # Test proportion from statistics
1286
+ TTestOfProportionFromStats(
1287
+ sample_proportion=0.65, # 65% proportion
1288
+ sample_size=200, # 200 survey responses
1289
+ hypothesized_proportion=0.50,
1290
+ alternative_hypothesis='two-sided'
1291
+ )
1292
+ ```
1293
+
1294
+ #### TTestOfTwoMeansFromStats
1295
+
1296
+ The **TTestOfTwoMeansFromStats** function compares two means using summary statistics.
1297
+
1298
+ ```python
1299
+ from analysistoolbox.hypothesis_testing import TTestOfTwoMeansFromStats
1300
+
1301
+ # Compare two means from statistics
1302
+ TTestOfTwoMeansFromStats(
1303
+ first_sample_mean=75,
1304
+ first_sample_size=30,
1305
+ first_sample_standard_deviation=10,
1306
+ second_sample_mean=70,
1307
+ second_sample_size=30,
1308
+ second_sample_standard_deviation=12
1309
+ )
1310
+ ```
1311
+
1312
+ #### TwoSampleTTestOfIndependence
1313
+
1314
+ The **TwoSampleTTestOfIndependence** function performs an independent samples t-test to compare means between two groups.
1315
+
1316
+ ```python
1317
+ from analysistoolbox.hypothesis_testing import TwoSampleTTestOfIndependence
1318
+
1319
+ # Conduct independent samples t-test
1320
+ TwoSampleTTestOfIndependence(
1321
+ dataframe=df,
1322
+ outcome_column='score',
1323
+ grouping_column='group',
1324
+ alternative_hypothesis='two-sided',
1325
+ homogeneity_of_variance=True
1326
+ )
1327
+ ```
1328
+
1329
+ #### TwoSampleTTestPaired
1330
+
1331
+ The **TwoSampleTTestPaired** function performs a paired samples t-test for before-after comparisons.
1332
+
1333
+ ```python
1334
+ from analysistoolbox.hypothesis_testing import TwoSampleTTestPaired
1335
+
1336
+ # Conduct paired samples t-test
1337
+ TwoSampleTTestPaired(
1338
+ dataframe=df,
1339
+ first_outcome_column='pre_score',
1340
+ second_outcome_column='post_score',
1341
+ alternative_hypothesis='greater'
1342
+ )
1343
+ ```
1344
+
1345
+ ### Linear Algebra
1346
+
1347
+ #### CalculateEigenvalues
1348
+
1349
+ The **CalculateEigenvalues** function calculates and visualizes the eigenvalues and eigenvectors of a matrix.
1350
+
1351
+ ```python
1352
+ from analysistoolbox.linear_algebra import CalculateEigenvalues
1353
+ import numpy as np
1354
+
1355
+ # Create a 2x2 matrix
1356
+ matrix = np.array([
1357
+ [4, -2],
1358
+ [1, 1]
1359
+ ])
1360
+
1361
+ # Calculate eigenvalues and eigenvectors
1362
+ CalculateEigenvalues(
1363
+ matrix=matrix,
1364
+ plot_eigenvectors=True,
1365
+ plot_transformation=True
1366
+ )
1367
+ ```
1368
+
1369
+ #### ConvertMatrixToRowEchelonForm
1370
+
1371
+ The **ConvertMatrixToRowEchelonForm** function converts a matrix to row echelon form using Gaussian elimination.
1372
+
1373
+ ```python
1374
+ from analysistoolbox.linear_algebra import ConvertMatrixToRowEchelonForm
1375
+ import numpy as np
1376
+
1377
+ # Create a matrix
1378
+ matrix = np.array([
1379
+ [1, 2, 3],
1380
+ [4, 5, 6],
1381
+ [7, 8, 9]
1382
+ ])
1383
+
1384
+ # Convert to row echelon form
1385
+ row_echelon = ConvertMatrixToRowEchelonForm(
1386
+ matrix=matrix,
1387
+ show_pivot_columns=True
1388
+ )
1389
+ ```
1390
+
1391
+ #### ConvertSystemOfEquationsToMatrix
1392
+
1393
+ The **ConvertSystemOfEquationsToMatrix** function converts a system of linear equations to matrix form.
1394
+
1395
+ ```python
1396
+ from analysistoolbox.linear_algebra import ConvertSystemOfEquationsToMatrix
1397
+ import numpy as np
1398
+
1399
+ # Define system of equations:
1400
+ # 2x + 3y = 8
1401
+ # 4x - y = 1
1402
+ coefficients = np.array([
1403
+ [2, 3],
1404
+ [4, -1]
1405
+ ])
1406
+ constants = np.array([8, 1])
1407
+
1408
+ # Convert to matrix form
1409
+ matrix = ConvertSystemOfEquationsToMatrix(
1410
+ coefficients=coefficients,
1411
+ constants=constants,
1412
+ show_determinant=True
1413
+ )
1414
+ ```
1415
+
1416
+ #### PlotVectors
1417
+
1418
+ The **PlotVectors** function visualizes vectors in 2D or 3D space.
1419
+
1420
+ ```python
1421
+ from analysistoolbox.linear_algebra import PlotVectors
1422
+ import numpy as np
1423
+
1424
+ # Define vectors
1425
+ vectors = [
1426
+ [3, 2], # First vector
1427
+ [-1, 4], # Second vector
1428
+ [2, -3] # Third vector
1429
+ ]
1430
+
1431
+ # Plot vectors
1432
+ PlotVectors(
1433
+ list_of_vectors=vectors,
1434
+ origin=[0, 0],
1435
+ plot_sum=True,
1436
+ grid=True
1437
+ )
1438
+ ```
1439
+
1440
+ #### SolveSystemOfEquations
1441
+
1442
+ The **SolveSystemOfEquations** function solves a system of linear equations and optionally visualizes the solution.
1443
+
1444
+ ```python
1445
+ from analysistoolbox.linear_algebra import SolveSystemOfEquations
1446
+ import numpy as np
1447
+
1448
+ # Define system of equations:
1449
+ # 2x + y = 5
1450
+ # x - 3y = -1
1451
+ coefficients = np.array([
1452
+ [2, 1],
1453
+ [1, -3]
1454
+ ])
1455
+ constants = np.array([5, -1])
1456
+
1457
+ # Solve the system
1458
+ solution = SolveSystemOfEquations(
1459
+ coefficients=coefficients,
1460
+ constants=constants,
1461
+ show_plot=True,
1462
+ plot_boundary=10
1463
+ )
1464
+ ```
1465
+
1466
+ #### VisualizeMatrixAsLinearTransformation
1467
+
1468
+ The **VisualizeMatrixAsLinearTransformation** function visualizes how a matrix transforms space as a linear transformation.
1469
+
1470
+ ```python
1471
+ from analysistoolbox.linear_algebra import VisualizeMatrixAsLinearTransformation
1472
+ import numpy as np
1473
+
1474
+ # Define transformation matrix
1475
+ transformation_matrix = np.array([
1476
+ [2, -1],
1477
+ [1, 1]
1478
+ ])
1479
+
1480
+ # Visualize the transformation
1481
+ VisualizeMatrixAsLinearTransformation(
1482
+ transformation_matrix=transformation_matrix,
1483
+ plot_grid=True,
1484
+ plot_unit_vectors=True,
1485
+ animation_frames=30
1486
+ )
1487
+ ```
1488
+
1489
+ ### LLM
1490
+
1491
+ #### SendPromptToAnthropic
1492
+
1493
+ The **SendPromptToAnthropic** function sends a prompt to Anthropic's Claude API using LangChain. It supports template-based prompting and requires an Anthropic API key.
1494
+
1495
+ ```python
1496
+ from analysistoolbox.llm import SendPromptToAnthropic
1497
+
1498
+ # Define your prompt template with variables in curly braces
1499
+ prompt_template = "Given the text: {text}\nSummarize the main points in bullet form."
1500
+
1501
+ # Create a dictionary with your input variables
1502
+ user_input = {
1503
+ "text": "Your text to analyze goes here..."
1504
+ }
1505
+
1506
+ # Send the prompt to Claude
1507
+ response = SendPromptToAnthropic(
1508
+ prompt_template=prompt_template,
1509
+ user_input=user_input,
1510
+ system_message="You are a helpful assistant.",
1511
+ anthropic_api_key="your-api-key-here",
1512
+ temperature=0.0,
1513
+ chat_model_name="claude-3-opus-20240229",
1514
+ maximum_tokens=1000
1515
+ )
1516
+
1517
+ print(response)
1518
+ ```
1519
+
1520
+ #### SendPromptToChatGPT
1521
+
1522
+ The **SendPromptToChatGPT** function sends a prompt to OpenAI's ChatGPT API using LangChain. It supports template-based prompting and requires an OpenAI API key.
1523
+
1524
+ ```python
1525
+ from analysistoolbox.llm import SendPromptToChatGPT
1526
+
1527
+ # Define your prompt template with variables in curly braces
1528
+ prompt_template = "Analyze the following data: {data}\nProvide key insights."
1529
+
1530
+ # Create a dictionary with your input variables
1531
+ user_input = {
1532
+ "data": "Your data to analyze goes here..."
1533
+ }
1534
+
1535
+ # Send the prompt to ChatGPT
1536
+ response = SendPromptToChatGPT(
1537
+ prompt_template=prompt_template,
1538
+ user_input=user_input,
1539
+ system_message="You are a helpful assistant.",
1540
+ openai_api_key="your-api-key-here",
1541
+ temperature=0.0,
1542
+ chat_model_name="gpt-4o-mini",
1543
+ maximum_tokens=1000
1544
+ )
1545
+
1546
+ print(response)
1547
+ ```
1548
+
1549
+ ### Predictive Analytics
1550
+
1551
+ #### CreateARIMAModel
1552
+
1553
+ Builds an ARIMA (Autoregressive Integrated Moving Average) model for time series forecasting.
1554
+
1555
+ ```python
1556
+ from analysistoolbox.predictive_analytics import CreateARIMAModel
1557
+ import pandas as pd
1558
+
1559
+ # Create time series forecast
1560
+ forecast = CreateARIMAModel(
1561
+ dataframe=df,
1562
+ time_column='date',
1563
+ value_column='sales',
1564
+ forecast_periods=12
1565
+ )
1566
+ ```
1567
+
1568
+ #### CreateBoostedTreeModel
1569
+
1570
+ Creates a gradient boosted tree model for classification or regression tasks, offering high performance and feature importance analysis.
1571
+
1572
+ ```python
1573
+ from analysistoolbox.predictive_analytics import CreateBoostedTreeModel
1574
+
1575
+ # Train a boosted tree classifier
1576
+ model = CreateBoostedTreeModel(
1577
+ dataframe=df,
1578
+ outcome_variable='churn',
1579
+ list_of_predictor_variables=['usage', 'tenure', 'satisfaction'],
1580
+ is_outcome_categorical=True,
1581
+ plot_model_test_performance=True
1582
+ )
1583
+ ```
1584
+
1585
+ #### CreateDecisionTreeModel
1586
+
1587
+ Builds an interpretable decision tree for classification or regression, with visualization options.
1588
+
1589
+ ```python
1590
+ from analysistoolbox.predictive_analytics import CreateDecisionTreeModel
1591
+
1592
+ # Create a decision tree for predicting house prices
1593
+ model = CreateDecisionTreeModel(
1594
+ dataframe=df,
1595
+ outcome_variable='price',
1596
+ list_of_predictor_variables=['sqft', 'bedrooms', 'location'],
1597
+ is_outcome_categorical=False,
1598
+ maximum_depth=5
1599
+ )
1600
+ ```
1601
+
1602
+ #### CreateLinearRegressionModel
1603
+
1604
+ Fits a linear regression model with optional scaling and comprehensive performance visualization.
1605
+
1606
+ ```python
1607
+ from analysistoolbox.predictive_analytics import CreateLinearRegressionModel
1608
+
1609
+ # Predict sales based on advertising spend
1610
+ model = CreateLinearRegressionModel(
1611
+ dataframe=df,
1612
+ outcome_variable='sales',
1613
+ list_of_predictor_variables=['tv_ads', 'radio_ads', 'newspaper_ads'],
1614
+ scale_variables=True,
1615
+ plot_model_test_performance=True
1616
+ )
1617
+ ```
1618
+
1619
+ #### CreateLogisticRegressionModel
1620
+
1621
+ Implements logistic regression for binary classification tasks with regularization options.
1622
+
1623
+ ```python
1624
+ from analysistoolbox.predictive_analytics import CreateLogisticRegressionModel
1625
+
1626
+ # Predict customer churn probability
1627
+ model = CreateLogisticRegressionModel(
1628
+ dataframe=df,
1629
+ outcome_variable='churn',
1630
+ list_of_predictor_variables=['usage', 'complaints', 'satisfaction'],
1631
+ scale_predictor_variables=True,
1632
+ show_classification_plot=True
1633
+ )
1634
+ ```
1635
+
1636
+ #### CreateNeuralNetwork_SingleOutcome
1637
+
1638
+ Builds and trains a neural network for single-outcome prediction tasks, with customizable architecture.
1639
+
1640
+ ```python
1641
+ from analysistoolbox.predictive_analytics import CreateNeuralNetwork_SingleOutcome
1642
+
1643
+ # Create a neural network for image classification
1644
+ model = CreateNeuralNetwork_SingleOutcome(
1645
+ dataframe=df,
1646
+ outcome_variable='label',
1647
+ list_of_predictor_variables=feature_columns,
1648
+ number_of_hidden_layers=3,
1649
+ is_outcome_categorical=True,
1650
+ plot_loss=True
1651
+ )
1652
+ ```
1653
+
1654
+ ### Prescriptive Analytics
1655
+
1656
+ The prescriptive analytics module provides tools for making data-driven recommendations and decisions:
1657
+
1658
+ #### CreateContentBasedRecommender
1659
+
1660
+ Builds a content-based recommendation system using neural networks to learn user and item embeddings.
1661
+
1662
+ ```python
1663
+ from analysistoolbox.prescriptive_analytics import CreateContentBasedRecommender
1664
+ import pandas as pd
1665
+
1666
+ # Create a movie recommendation system
1667
+ recommender = CreateContentBasedRecommender(
1668
+ dataframe=movie_ratings_df,
1669
+ outcome_variable='rating',
1670
+ user_list_of_predictor_variables=['age', 'gender', 'occupation'],
1671
+ item_list_of_predictor_variables=['genre', 'year', 'director', 'budget'],
1672
+ user_number_of_hidden_layers=2,
1673
+ item_number_of_hidden_layers=2,
1674
+ number_of_recommendations=5,
1675
+ scale_variables=True,
1676
+ plot_loss=True
1677
+ )
1678
+ ```
1679
+
1680
+ ### Probability
1681
+
1682
+ The probability module provides tools for working with probability distributions and statistical models:
1683
+
1684
+ #### ProbabilityOfAtLeastOne
1685
+
1686
+ Calculates and visualizes the probability of at least one event occurring in a series of independent trials.
1687
+
1688
+ ```python
1689
+ from analysistoolbox.probability import ProbabilityOfAtLeastOne
1690
+
1691
+ # Calculate probability of at least one defect in 10 products
1692
+ # given a 5% defect rate per product
1693
+ prob = ProbabilityOfAtLeastOne(
1694
+ probability_of_event=0.05,
1695
+ number_of_events=10,
1696
+ format_as_percent=True,
1697
+ show_plot=True,
1698
+ risk_tolerance=0.20 # Highlight 20% risk threshold
1699
+ )
1700
+
1701
+ # Calculate probability of at least one successful sale
1702
+ # given 30 customer interactions with 15% success rate
1703
+ prob = ProbabilityOfAtLeastOne(
1704
+ probability_of_event=0.15,
1705
+ number_of_events=30,
1706
+ format_as_percent=True,
1707
+ show_plot=True,
1708
+ title_for_plot="Sales Success Probability",
1709
+ subtitle_for_plot="Probability of at least one sale in 30 customer interactions"
1710
+ )
1711
+ ```
1712
+
1713
+ ### Simulations
1714
+
1715
+ The simulations module provides a comprehensive set of tools for statistical simulations and probability distributions:
1716
+
1717
+ #### CreateMetalogDistribution
1718
+
1719
+ Creates a flexible metalog distribution from data, useful for modeling complex probability distributions.
1720
+
1721
+ ```python
1722
+ from analysistoolbox.simulations import CreateMetalogDistribution
1723
+
1724
+ # Create a metalog distribution from historical data
1725
+ distribution = CreateMetalogDistribution(
1726
+ dataframe=df,
1727
+ variable='sales',
1728
+ lower_bound=0,
1729
+ number_of_samples=10000,
1730
+ plot_metalog_distribution=True
1731
+ )
1732
+ ```
1733
+
1734
+ #### CreateMetalogDistributionFromPercentiles
1735
+
1736
+ Builds a metalog distribution from known percentile values.
1737
+
1738
+ ```python
1739
+ from analysistoolbox.simulations import CreateMetalogDistributionFromPercentiles
1740
+
1741
+ # Create distribution from percentiles
1742
+ distribution = CreateMetalogDistributionFromPercentiles(
1743
+ list_of_values=[10, 20, 30, 50],
1744
+ list_of_percentiles=[0.1, 0.25, 0.75, 0.9],
1745
+ lower_bound=0,
1746
+ show_distribution_plot=True
1747
+ )
1748
+ ```
1749
+
1750
+ #### CreateSIPDataframe
1751
+
1752
+ Generates Stochastically Indexed Percentiles (SIP) for uncertainty analysis.
1753
+
1754
+ ```python
1755
+ from analysistoolbox.simulations import CreateSIPDataframe
1756
+
1757
+ # Create SIP dataframe for risk analysis
1758
+ sip_df = CreateSIPDataframe(
1759
+ number_of_percentiles=10,
1760
+ number_of_trials=1000
1761
+ )
1762
+ ```
1763
+
1764
+ #### CreateSLURPDistribution
1765
+ Creates a SIP with relationships preserved (SLURP) based on a linear regression model's prediction interval.
1766
+
1767
+ ```python
1768
+ from analysistoolbox.simulations import CreateSLURPDistribution
1769
+
1770
+ # Create a SLURP distribution from a linear regression model
1771
+ slurp_dist = CreateSLURPDistribution(
1772
+ linear_regression_model=model, # statsmodels regression model
1773
+ list_of_prediction_values=[x1, x2, ...], # values for predictors
1774
+ number_of_trials=10000, # number of samples to generate
1775
+ prediction_interval=0.95, # confidence level for prediction interval
1776
+ lower_bound=None, # optional lower bound constraint
1777
+ upper_bound=None # optional upper bound constraint
1778
+ )
1779
+ ```
1780
+
1781
+ #### SimulateCountOfSuccesses
1782
+
1783
+ Simulates binomial outcomes (number of successes in fixed trials).
1784
+
1785
+ ```python
1786
+ from analysistoolbox.simulations import SimulateCountOfSuccesses
1787
+
1788
+ # Simulate customer conversion rates
1789
+ results = SimulateCountOfSuccesses(
1790
+ probability_of_success=0.15,
1791
+ sample_size_per_trial=100,
1792
+ number_of_trials=10000,
1793
+ plot_simulation_results=True
1794
+ )
1795
+ ```
1796
+
1797
+ #### SimulateCountOutcome
1798
+
1799
+ Simulates Poisson-distributed count data.
1800
+
1801
+ ```python
1802
+ from analysistoolbox.simulations import SimulateCountOutcome
1803
+
1804
+ # Simulate daily customer arrivals
1805
+ arrivals = SimulateCountOutcome(
1806
+ expected_count=25,
1807
+ number_of_trials=10000,
1808
+ plot_simulation_results=True
1809
+ )
1810
+ ```
1811
+
1812
+ #### SimulateCountUntilFirstSuccess
1813
+
1814
+ Simulates geometric distributions (trials until first success).
1815
+
1816
+ ```python
1817
+ from analysistoolbox.simulations import SimulateCountUntilFirstSuccess
1818
+
1819
+ # Simulate number of attempts until success
1820
+ attempts = SimulateCountUntilFirstSuccess(
1821
+ probability_of_success=0.2,
1822
+ number_of_trials=10000,
1823
+ plot_simulation_results=True
1824
+ )
1825
+ ```
1826
+
1827
+ #### SimulateNormallyDistributedOutcome
1828
+ Generates normally distributed random variables.
1829
+
1830
+ ```python
1831
+ from analysistoolbox.simulations import SimulateNormallyDistributedOutcome
1832
+
1833
+ # Simulate product weights
1834
+ weights = SimulateNormallyDistributedOutcome(
1835
+ mean=100,
1836
+ standard_deviation=5,
1837
+ number_of_trials=10000,
1838
+ plot_simulation_results=True
1839
+ )
1840
+ ```
1841
+
1842
+ #### SimulateTDistributedOutcome
1843
+ Generates Student's t-distributed random variables.
1844
+
1845
+ ```python
1846
+ from analysistoolbox.simulations import SimulateTDistributedOutcome
1847
+
1848
+ # Simulate with heavy-tailed distribution
1849
+ values = SimulateTDistributedOutcome(
1850
+ degrees_of_freedom=5,
1851
+ number_of_trials=10000,
1852
+ plot_simulation_results=True
1853
+ )
1854
+ ```
1855
+
1856
+ #### SimulateTimeBetweenEvents
1857
+
1858
+ Simulates exponentially distributed inter-arrival times.
1859
+
1860
+ ```python
1861
+ from analysistoolbox.simulations import SimulateTimeBetweenEvents
1862
+
1863
+ # Simulate time between customer arrivals
1864
+ times = SimulateTimeBetweenEvents(
1865
+ average_time_between_events=30,
1866
+ number_of_trials=10000,
1867
+ plot_simulation_results=True
1868
+ )
1869
+ ```
1870
+
1871
+ #### SimulateTimeUntilNEvents
1872
+ Simulates Erlang-distributed waiting times.
1873
+
1874
+ ```python
1875
+ from analysistoolbox.simulations import SimulateTimeUntilNEvents
1876
+
1877
+ # Simulate time until 5 events occur
1878
+ wait_time = SimulateTimeUntilNEvents(
1879
+ average_time_between_events=10,
1880
+ number_of_events=5,
1881
+ number_of_trials=10000,
1882
+ plot_simulation_results=True
1883
+ )
1884
+ ```
1885
+
1886
+ ### Statistics
1887
+
1888
+ The statistics module provides essential tools for statistical inference and estimation:
1889
+
1890
+ #### CalculateConfidenceIntervalOfMean
1891
+
1892
+ Calculates confidence intervals for population means, automatically handling both large (z-distribution) and small (t-distribution) sample sizes.
1893
+
1894
+ ```python
1895
+ from analysistoolbox.statistics import CalculateConfidenceIntervalOfMean
1896
+
1897
+ # Calculate 95% confidence interval for average customer spending
1898
+ ci_results = CalculateConfidenceIntervalOfMean(
1899
+ sample_mean=45.2,
1900
+ sample_standard_deviation=12.5,
1901
+ sample_size=100,
1902
+ confidence_interval=0.95,
1903
+ plot_sample_distribution=True,
1904
+ value_name="Average Spending ($)"
1905
+ )
1906
+ ```
1907
+
1908
+ #### CalculateConfidenceIntervalOfProportion
1909
+
1910
+ Calculates confidence intervals for population proportions, with automatic selection of the appropriate distribution based on sample size.
1911
+
1912
+ ```python
1913
+ from analysistoolbox.statistics import CalculateConfidenceIntervalOfProportion
1914
+
1915
+ # Calculate 95% confidence interval for customer satisfaction rate
1916
+ ci_results = CalculateConfidenceIntervalOfProportion(
1917
+ sample_proportion=0.78, # 78% satisfaction rate
1918
+ sample_size=200, # 200 survey responses
1919
+ confidence_interval=0.95,
1920
+ plot_sample_distribution=True,
1921
+ value_name="Satisfaction Rate"
1922
+ )
1923
+ ```
1924
+
1925
+ ### Visualizations
1926
+
1927
+ The visualizations module provides a comprehensive set of tools for creating publication-quality statistical plots and charts:
1928
+
1929
+ #### Plot100PercentStackedBarChart
1930
+ Creates a 100% stacked bar chart for comparing proportional compositions across categories.
1931
+
1932
+ ```python
1933
+ from analysistoolbox.visualizations import Plot100PercentStackedBarChart
1934
+
1935
+ # Create a stacked bar chart showing customer segments by region
1936
+ chart = Plot100PercentStackedBarChart(
1937
+ dataframe=df,
1938
+ categorical_column_name='Region',
1939
+ value_column_name='Customers',
1940
+ grouping_column_name='Segment'
1941
+ )
1942
+ ```
1943
+
1944
+ #### PlotBarChart
1945
+
1946
+ Creates a customizable bar chart with options for highlighting specific categories.
1947
+
1948
+ ```python
1949
+ from analysistoolbox.visualizations import PlotBarChart
1950
+
1951
+ # Create a bar chart of sales by product
1952
+ chart = PlotBarChart(
1953
+ dataframe=df,
1954
+ categorical_column_name='Product',
1955
+ value_column_name='Sales',
1956
+ top_n_to_highlight=3,
1957
+ highlight_color="#b0170c"
1958
+ )
1959
+ ```
1960
+
1961
+ #### PlotBoxWhiskerByGroup
1962
+
1963
+ Creates box-and-whisker plots for comparing distributions across groups.
1964
+
1965
+ ```python
1966
+ from analysistoolbox.visualizations import PlotBoxWhiskerByGroup
1967
+
1968
+ # Compare salary distributions across departments
1969
+ plot = PlotBoxWhiskerByGroup(
1970
+ dataframe=df,
1971
+ value_column_name='Salary',
1972
+ grouping_column_name='Department'
1973
+ )
1974
+ ```
1975
+
1976
+ #### PlotBulletChart
1977
+
1978
+ Creates bullet charts for comparing actual values against targets with optional range bands.
1979
+
1980
+ ```python
1981
+ from analysistoolbox.visualizations import PlotBulletChart
1982
+
1983
+ # Create bullet chart comparing actual vs target sales
1984
+ chart = PlotBulletChart(
1985
+ dataframe=df,
1986
+ value_column_name='Actual_Sales',
1987
+ grouping_column_name='Region',
1988
+ target_value_column_name='Target_Sales',
1989
+ list_of_limit_columns=['Min_Sales', 'Max_Sales']
1990
+ )
1991
+ ```
1992
+
1993
+ #### PlotCard
1994
+
1995
+ Creates a simple card-style visualization with a value and an optional value label.
1996
+
1997
+ ```python
1998
+ from analysistoolbox.visualizations import PlotCard
1999
+
2000
+ # Create a simple KPI card
2001
+ card = PlotCard(
2002
+ value=125000, # main value to display
2003
+ value_label="Monthly Revenue", # optional label
2004
+ value_font_size=30, # size of the main value
2005
+ value_label_font_size=14, # size of the label
2006
+ figure_size=(3, 2) # dimensions of the card
2007
+ )
2008
+ ```
2009
+
2010
+ #### PlotClusteredBarChart
2011
+
2012
+ Creates grouped bar charts for comparing multiple categories across groups.
2013
+
2014
+ ```python
2015
+ from analysistoolbox.visualizations import PlotClusteredBarChart
2016
+
2017
+ # Create clustered bar chart of sales by product and region
2018
+ chart = PlotClusteredBarChart(
2019
+ dataframe=df,
2020
+ categorical_column_name='Product',
2021
+ value_column_name='Sales',
2022
+ grouping_column_name='Region'
2023
+ )
2024
+ ```
2025
+
2026
+ #### PlotContingencyHeatmap
2027
+
2028
+ Creates a heatmap visualization of contingency tables.
2029
+
2030
+ ```python
2031
+ from analysistoolbox.visualizations import PlotContingencyHeatmap
2032
+
2033
+ # Create heatmap of customer segments vs purchase categories
2034
+ heatmap = PlotContingencyHeatmap(
2035
+ dataframe=df,
2036
+ categorical_column_name_1='Customer_Segment',
2037
+ categorical_column_name_2='Purchase_Category',
2038
+ normalize_by="columns"
2039
+ )
2040
+ ```
2041
+
2042
+ #### PlotCorrelationMatrix
2043
+
2044
+ Creates correlation matrix visualizations with optional scatter plots.
2045
+
2046
+ ```python
2047
+ from analysistoolbox.visualizations import PlotCorrelationMatrix
2048
+
2049
+ # Create correlation matrix of numeric variables
2050
+ matrix = PlotCorrelationMatrix(
2051
+ dataframe=df,
2052
+ list_of_value_column_names=['Age', 'Income', 'Spending'],
2053
+ show_as_pairplot=True
2054
+ )
2055
+ ```
2056
+
2057
+ #### PlotDensityByGroup
2058
+
2059
+ Creates density plots for comparing distributions across groups.
2060
+
2061
+ ```python
2062
+ from analysistoolbox.visualizations import PlotDensityByGroup
2063
+
2064
+ # Compare age distributions across customer segments
2065
+ plot = PlotDensityByGroup(
2066
+ dataframe=df,
2067
+ value_column_name='Age',
2068
+ grouping_column_name='Customer_Segment'
2069
+ )
2070
+ ```
2071
+
2072
+ #### PlotDotPlot
2073
+
2074
+ Creates dot plots with optional connecting lines between groups.
2075
+
2076
+ ```python
2077
+ from analysistoolbox.visualizations import PlotDotPlot
2078
+
2079
+ # Compare before/after measurements
2080
+ plot = PlotDotPlot(
2081
+ dataframe=df,
2082
+ categorical_column_name='Metric',
2083
+ value_column_name='Value',
2084
+ group_column_name='Time_Period',
2085
+ connect_dots=True
2086
+ )
2087
+ ```
2088
+
2089
+ #### PlotHeatmap
2090
+
2091
+ Creates customizable heatmaps for visualizing two-dimensional data.
2092
+
2093
+ ```python
2094
+ from analysistoolbox.visualizations import PlotHeatmap
2095
+
2096
+ # Create heatmap of customer activity by hour and day
2097
+ heatmap = PlotHeatmap(
2098
+ dataframe=df,
2099
+ x_axis_column_name='Hour',
2100
+ y_axis_column_name='Day',
2101
+ value_column_name='Activity',
2102
+ color_palette="RdYlGn"
2103
+ )
2104
+ ```
2105
+
2106
+ #### PlotOverlappingAreaChart
2107
+
2108
+ Creates stacked or overlapping area charts for time series data.
2109
+
2110
+ ```python
2111
+ from analysistoolbox.visualizations import PlotOverlappingAreaChart
2112
+
2113
+ # Show product sales trends over time
2114
+ chart = PlotOverlappingAreaChart(
2115
+ dataframe=df,
2116
+ time_column_name='Date',
2117
+ value_column_name='Sales',
2118
+ variable_column_name='Product'
2119
+ )
2120
+ ```
2121
+
2122
+ #### PlotRiskTolerance
2123
+
2124
+ Creates specialized plots for risk analysis and tolerance visualization.
2125
+
2126
+ ```python
2127
+ from analysistoolbox.visualizations import PlotRiskTolerance
2128
+
2129
+ # Visualize risk tolerance levels
2130
+ plot = PlotRiskTolerance(
2131
+ dataframe=df,
2132
+ value_column_name='Risk_Score',
2133
+ tolerance_level_column_name='Tolerance'
2134
+ )
2135
+ ```
2136
+
2137
+ #### PlotScatterplot
2138
+
2139
+ Creates scatter plots with optional trend lines and grouping.
2140
+
2141
+ ```python
2142
+ from analysistoolbox.visualizations import PlotScatterplot
2143
+
2144
+ # Create scatter plot of age vs income
2145
+ plot = PlotScatterplot(
2146
+ dataframe=df,
2147
+ x_axis_column_name='Age',
2148
+ y_axis_column_name='Income',
2149
+ color_by_column_name='Education'
2150
+ )
2151
+ ```
2152
+
2153
+ #### PlotSingleVariableCountPlot
2154
+
2155
+ Creates count plots for categorical variables.
2156
+
2157
+ ```python
2158
+ from analysistoolbox.visualizations import PlotSingleVariableCountPlot
2159
+
2160
+ # Show distribution of customer types
2161
+ plot = PlotSingleVariableCountPlot(
2162
+ dataframe=df,
2163
+ categorical_column_name='Customer_Type',
2164
+ top_n_to_highlight=2
2165
+ )
2166
+ ```
2167
+
2168
+ #### PlotSingleVariableHistogram
2169
+
2170
+ Creates histograms for continuous variables.
2171
+
2172
+ ```python
2173
+ from analysistoolbox.visualizations import PlotSingleVariableHistogram
2174
+
2175
+ # Create histogram of transaction amounts
2176
+ plot = PlotSingleVariableHistogram(
2177
+ dataframe=df,
2178
+ value_column_name='Transaction_Amount',
2179
+ show_mean=True,
2180
+ show_median=True
2181
+ )
2182
+ ```
2183
+
2184
+ #### PlotTimeSeries
2185
+
2186
+ Creates time series plots with optional grouping and marker sizes.
2187
+
2188
+ ```python
2189
+ from analysistoolbox.visualizations import PlotTimeSeries
2190
+
2191
+ # Plot monthly sales with grouping
2192
+ plot = PlotTimeSeries(
2193
+ dataframe=df,
2194
+ time_column_name='Date',
2195
+ value_column_name='Sales',
2196
+ grouping_column_name='Region', # optional grouping
2197
+ marker_size_column_name='Volume', # optional markers
2198
+ line_color='#3269a8',
2199
+ figure_size=(8, 5)
2200
+ )
2201
+ ```
2202
+
2203
+ #### RenderTableOne
2204
+
2205
+ Creates publication-ready summary statistics tables comparing variables across groups.
2206
+
2207
+ ```python
2208
+ from analysistoolbox.visualizations import RenderTableOne
2209
+
2210
+ # Create summary statistics table comparing age, education by department
2211
+ table = RenderTableOne(
2212
+ dataframe=df,
2213
+ value_column_name='Age', # outcome variable
2214
+ grouping_column_name='Department', # grouping variable
2215
+ list_of_row_variables=['Education', 'Experience'], # variables to compare
2216
+ table_format='html', # output format
2217
+ show_p_value=True # include statistical tests
2218
+ )
2219
+ ```
2220
+
2221
+ ## Contributions
2222
+
2223
+ Contributions to the analysistoolbox package are welcome! Please submit a pull request with your changes.
2224
+
2225
+ ## License
2226
+
2227
+ The analysistoolbox package is licensed under the GNU License. Read more about the GNU License at [https://www.gnu.org/licenses/gpl-3.0.html](https://www.gnu.org/licenses/gpl-3.0.html).