validmind 2.5.8__py3-none-any.whl → 2.5.18__py3-none-any.whl
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.
- validmind/__version__.py +1 -1
- validmind/ai/test_descriptions.py +80 -119
- validmind/ai/test_result_description/config.yaml +29 -0
- validmind/ai/test_result_description/context.py +73 -0
- validmind/ai/test_result_description/image_processing.py +124 -0
- validmind/ai/test_result_description/system.jinja +39 -0
- validmind/ai/test_result_description/user.jinja +25 -0
- validmind/api_client.py +89 -43
- validmind/client.py +2 -2
- validmind/client_config.py +11 -14
- validmind/datasets/credit_risk/__init__.py +1 -0
- validmind/datasets/credit_risk/datasets/lending_club_biased.csv.gz +0 -0
- validmind/datasets/credit_risk/lending_club_bias.py +142 -0
- validmind/datasets/regression/fred_timeseries.py +67 -138
- validmind/template.py +1 -0
- validmind/test_suites/__init__.py +0 -2
- validmind/test_suites/statsmodels_timeseries.py +1 -1
- validmind/test_suites/summarization.py +0 -1
- validmind/test_suites/time_series.py +0 -43
- validmind/tests/__types__.py +14 -15
- validmind/tests/data_validation/ACFandPACFPlot.py +15 -13
- validmind/tests/data_validation/ADF.py +31 -24
- validmind/tests/data_validation/AutoAR.py +9 -9
- validmind/tests/data_validation/AutoMA.py +23 -16
- validmind/tests/data_validation/AutoSeasonality.py +18 -16
- validmind/tests/data_validation/AutoStationarity.py +21 -16
- validmind/tests/data_validation/BivariateScatterPlots.py +67 -96
- validmind/tests/{model_validation/statsmodels → data_validation}/BoxPierce.py +34 -34
- validmind/tests/data_validation/ChiSquaredFeaturesTable.py +85 -124
- validmind/tests/data_validation/ClassImbalance.py +15 -12
- validmind/tests/data_validation/DFGLSArch.py +19 -13
- validmind/tests/data_validation/DatasetDescription.py +17 -11
- validmind/tests/data_validation/DatasetSplit.py +7 -5
- validmind/tests/data_validation/DescriptiveStatistics.py +28 -21
- validmind/tests/data_validation/Duplicates.py +33 -25
- validmind/tests/data_validation/EngleGrangerCoint.py +35 -33
- validmind/tests/data_validation/FeatureTargetCorrelationPlot.py +59 -71
- validmind/tests/data_validation/HighCardinality.py +19 -12
- validmind/tests/data_validation/HighPearsonCorrelation.py +27 -22
- validmind/tests/data_validation/IQROutliersBarPlot.py +13 -10
- validmind/tests/data_validation/IQROutliersTable.py +40 -36
- validmind/tests/data_validation/IsolationForestOutliers.py +21 -14
- validmind/tests/data_validation/JarqueBera.py +70 -0
- validmind/tests/data_validation/KPSS.py +34 -29
- validmind/tests/data_validation/LJungBox.py +66 -0
- validmind/tests/data_validation/LaggedCorrelationHeatmap.py +22 -15
- validmind/tests/data_validation/MissingValues.py +32 -27
- validmind/tests/data_validation/MissingValuesBarPlot.py +25 -21
- validmind/tests/data_validation/PearsonCorrelationMatrix.py +71 -84
- validmind/tests/data_validation/PhillipsPerronArch.py +37 -30
- validmind/tests/data_validation/ProtectedClassesCombination.py +197 -0
- validmind/tests/data_validation/ProtectedClassesDescription.py +130 -0
- validmind/tests/data_validation/ProtectedClassesDisparity.py +133 -0
- validmind/tests/data_validation/ProtectedClassesThresholdOptimizer.py +172 -0
- validmind/tests/data_validation/RollingStatsPlot.py +31 -23
- validmind/tests/data_validation/RunsTest.py +72 -0
- validmind/tests/data_validation/ScatterPlot.py +63 -78
- validmind/tests/data_validation/SeasonalDecompose.py +38 -34
- validmind/tests/{model_validation/statsmodels → data_validation}/ShapiroWilk.py +35 -30
- validmind/tests/data_validation/Skewness.py +35 -37
- validmind/tests/data_validation/SpreadPlot.py +35 -35
- validmind/tests/data_validation/TabularCategoricalBarPlots.py +23 -17
- validmind/tests/data_validation/TabularDateTimeHistograms.py +21 -13
- validmind/tests/data_validation/TabularDescriptionTables.py +51 -16
- validmind/tests/data_validation/TabularNumericalHistograms.py +25 -22
- validmind/tests/data_validation/TargetRateBarPlots.py +21 -14
- validmind/tests/data_validation/TimeSeriesDescription.py +25 -18
- validmind/tests/data_validation/TimeSeriesDescriptiveStatistics.py +23 -17
- validmind/tests/data_validation/TimeSeriesFrequency.py +24 -17
- validmind/tests/data_validation/TimeSeriesHistogram.py +33 -32
- validmind/tests/data_validation/TimeSeriesLinePlot.py +17 -10
- validmind/tests/data_validation/TimeSeriesMissingValues.py +15 -10
- validmind/tests/data_validation/TimeSeriesOutliers.py +37 -33
- validmind/tests/data_validation/TooManyZeroValues.py +16 -11
- validmind/tests/data_validation/UniqueRows.py +11 -6
- validmind/tests/data_validation/WOEBinPlots.py +23 -16
- validmind/tests/data_validation/WOEBinTable.py +35 -30
- validmind/tests/data_validation/ZivotAndrewsArch.py +34 -28
- validmind/tests/data_validation/nlp/CommonWords.py +21 -14
- validmind/tests/data_validation/nlp/Hashtags.py +42 -40
- validmind/tests/data_validation/nlp/LanguageDetection.py +33 -14
- validmind/tests/data_validation/nlp/Mentions.py +21 -15
- validmind/tests/data_validation/nlp/PolarityAndSubjectivity.py +32 -9
- validmind/tests/data_validation/nlp/Punctuations.py +24 -20
- validmind/tests/data_validation/nlp/Sentiment.py +27 -8
- validmind/tests/data_validation/nlp/StopWords.py +26 -19
- validmind/tests/data_validation/nlp/TextDescription.py +39 -36
- validmind/tests/data_validation/nlp/Toxicity.py +32 -9
- validmind/tests/decorator.py +81 -42
- validmind/tests/model_validation/BertScore.py +36 -27
- validmind/tests/model_validation/BleuScore.py +25 -19
- validmind/tests/model_validation/ClusterSizeDistribution.py +38 -34
- validmind/tests/model_validation/ContextualRecall.py +38 -13
- validmind/tests/model_validation/FeaturesAUC.py +32 -13
- validmind/tests/model_validation/MeteorScore.py +46 -33
- validmind/tests/model_validation/ModelMetadata.py +32 -64
- validmind/tests/model_validation/ModelPredictionResiduals.py +75 -73
- validmind/tests/model_validation/RegardScore.py +30 -14
- validmind/tests/model_validation/RegressionResidualsPlot.py +10 -5
- validmind/tests/model_validation/RougeScore.py +36 -30
- validmind/tests/model_validation/TimeSeriesPredictionWithCI.py +30 -14
- validmind/tests/model_validation/TimeSeriesPredictionsPlot.py +27 -30
- validmind/tests/model_validation/TimeSeriesR2SquareBySegments.py +68 -63
- validmind/tests/model_validation/TokenDisparity.py +31 -23
- validmind/tests/model_validation/ToxicityScore.py +26 -17
- validmind/tests/model_validation/embeddings/ClusterDistribution.py +24 -20
- validmind/tests/model_validation/embeddings/CosineSimilarityComparison.py +30 -27
- validmind/tests/model_validation/embeddings/CosineSimilarityDistribution.py +7 -5
- validmind/tests/model_validation/embeddings/CosineSimilarityHeatmap.py +32 -23
- validmind/tests/model_validation/embeddings/DescriptiveAnalytics.py +7 -5
- validmind/tests/model_validation/embeddings/EmbeddingsVisualization2D.py +15 -11
- validmind/tests/model_validation/embeddings/EuclideanDistanceComparison.py +29 -29
- validmind/tests/model_validation/embeddings/EuclideanDistanceHeatmap.py +34 -25
- validmind/tests/model_validation/embeddings/PCAComponentsPairwisePlots.py +38 -26
- validmind/tests/model_validation/embeddings/StabilityAnalysis.py +40 -1
- validmind/tests/model_validation/embeddings/StabilityAnalysisKeyword.py +18 -17
- validmind/tests/model_validation/embeddings/StabilityAnalysisRandomNoise.py +40 -45
- validmind/tests/model_validation/embeddings/StabilityAnalysisSynonyms.py +17 -19
- validmind/tests/model_validation/embeddings/StabilityAnalysisTranslation.py +29 -25
- validmind/tests/model_validation/embeddings/TSNEComponentsPairwisePlots.py +38 -28
- validmind/tests/model_validation/ragas/AnswerCorrectness.py +5 -4
- validmind/tests/model_validation/ragas/AnswerRelevance.py +5 -4
- validmind/tests/model_validation/ragas/AnswerSimilarity.py +5 -4
- validmind/tests/model_validation/ragas/AspectCritique.py +12 -6
- validmind/tests/model_validation/ragas/ContextEntityRecall.py +9 -8
- validmind/tests/model_validation/ragas/ContextPrecision.py +5 -4
- validmind/tests/model_validation/ragas/ContextRecall.py +5 -4
- validmind/tests/model_validation/ragas/ContextUtilization.py +155 -0
- validmind/tests/model_validation/ragas/Faithfulness.py +5 -4
- validmind/tests/model_validation/ragas/NoiseSensitivity.py +152 -0
- validmind/tests/model_validation/ragas/utils.py +6 -0
- validmind/tests/model_validation/sklearn/AdjustedMutualInformation.py +19 -12
- validmind/tests/model_validation/sklearn/AdjustedRandIndex.py +22 -17
- validmind/tests/model_validation/sklearn/ClassifierPerformance.py +27 -25
- validmind/tests/model_validation/sklearn/ClusterCosineSimilarity.py +7 -5
- validmind/tests/model_validation/sklearn/ClusterPerformance.py +40 -78
- validmind/tests/model_validation/sklearn/ClusterPerformanceMetrics.py +15 -17
- validmind/tests/model_validation/sklearn/CompletenessScore.py +17 -11
- validmind/tests/model_validation/sklearn/ConfusionMatrix.py +22 -15
- validmind/tests/model_validation/sklearn/FeatureImportance.py +95 -0
- validmind/tests/model_validation/sklearn/FowlkesMallowsScore.py +7 -7
- validmind/tests/model_validation/sklearn/HomogeneityScore.py +19 -12
- validmind/tests/model_validation/sklearn/HyperParametersTuning.py +35 -30
- validmind/tests/model_validation/sklearn/KMeansClustersOptimization.py +10 -5
- validmind/tests/model_validation/sklearn/MinimumAccuracy.py +32 -32
- validmind/tests/model_validation/sklearn/MinimumF1Score.py +23 -23
- validmind/tests/model_validation/sklearn/MinimumROCAUCScore.py +15 -10
- validmind/tests/model_validation/sklearn/ModelsPerformanceComparison.py +26 -19
- validmind/tests/model_validation/sklearn/OverfitDiagnosis.py +38 -18
- validmind/tests/model_validation/sklearn/PermutationFeatureImportance.py +32 -26
- validmind/tests/model_validation/sklearn/PopulationStabilityIndex.py +8 -6
- validmind/tests/model_validation/sklearn/PrecisionRecallCurve.py +24 -17
- validmind/tests/model_validation/sklearn/ROCCurve.py +12 -7
- validmind/tests/model_validation/sklearn/RegressionErrors.py +74 -130
- validmind/tests/model_validation/sklearn/RegressionErrorsComparison.py +27 -12
- validmind/tests/model_validation/sklearn/{RegressionModelsPerformanceComparison.py → RegressionPerformance.py} +18 -20
- validmind/tests/model_validation/sklearn/RegressionR2Square.py +55 -94
- validmind/tests/model_validation/sklearn/RegressionR2SquareComparison.py +32 -13
- validmind/tests/model_validation/sklearn/RobustnessDiagnosis.py +36 -32
- validmind/tests/model_validation/sklearn/SHAPGlobalImportance.py +66 -5
- validmind/tests/model_validation/sklearn/SilhouettePlot.py +27 -19
- validmind/tests/model_validation/sklearn/TrainingTestDegradation.py +25 -18
- validmind/tests/model_validation/sklearn/VMeasure.py +14 -13
- validmind/tests/model_validation/sklearn/WeakspotsDiagnosis.py +7 -5
- validmind/tests/model_validation/statsmodels/AutoARIMA.py +24 -18
- validmind/tests/model_validation/statsmodels/CumulativePredictionProbabilities.py +73 -104
- validmind/tests/model_validation/statsmodels/DurbinWatsonTest.py +59 -32
- validmind/tests/model_validation/statsmodels/GINITable.py +44 -77
- validmind/tests/model_validation/statsmodels/KolmogorovSmirnov.py +33 -34
- validmind/tests/model_validation/statsmodels/Lilliefors.py +27 -24
- validmind/tests/model_validation/statsmodels/PredictionProbabilitiesHistogram.py +86 -119
- validmind/tests/model_validation/statsmodels/RegressionCoeffs.py +100 -0
- validmind/tests/model_validation/statsmodels/RegressionFeatureSignificance.py +14 -9
- validmind/tests/model_validation/statsmodels/RegressionModelForecastPlot.py +17 -13
- validmind/tests/model_validation/statsmodels/RegressionModelForecastPlotLevels.py +46 -43
- validmind/tests/model_validation/statsmodels/RegressionModelSensitivityPlot.py +38 -36
- validmind/tests/model_validation/statsmodels/RegressionModelSummary.py +30 -28
- validmind/tests/model_validation/statsmodels/RegressionPermutationFeatureImportance.py +18 -11
- validmind/tests/model_validation/statsmodels/ScorecardHistogram.py +75 -107
- validmind/tests/ongoing_monitoring/FeatureDrift.py +10 -6
- validmind/tests/ongoing_monitoring/PredictionAcrossEachFeature.py +31 -25
- validmind/tests/ongoing_monitoring/PredictionCorrelation.py +29 -21
- validmind/tests/ongoing_monitoring/TargetPredictionDistributionPlot.py +31 -23
- validmind/tests/prompt_validation/Bias.py +14 -11
- validmind/tests/prompt_validation/Clarity.py +16 -14
- validmind/tests/prompt_validation/Conciseness.py +7 -5
- validmind/tests/prompt_validation/Delimitation.py +23 -22
- validmind/tests/prompt_validation/NegativeInstruction.py +7 -5
- validmind/tests/prompt_validation/Robustness.py +12 -10
- validmind/tests/prompt_validation/Specificity.py +13 -11
- validmind/tests/prompt_validation/ai_powered_test.py +6 -0
- validmind/tests/run.py +68 -23
- validmind/unit_metrics/__init__.py +81 -144
- validmind/unit_metrics/classification/{sklearn/Accuracy.py → Accuracy.py} +1 -1
- validmind/unit_metrics/classification/{sklearn/F1.py → F1.py} +1 -1
- validmind/unit_metrics/classification/{sklearn/Precision.py → Precision.py} +1 -1
- validmind/unit_metrics/classification/{sklearn/ROC_AUC.py → ROC_AUC.py} +1 -2
- validmind/unit_metrics/classification/{sklearn/Recall.py → Recall.py} +1 -1
- validmind/unit_metrics/regression/{sklearn/AdjustedRSquaredScore.py → AdjustedRSquaredScore.py} +1 -1
- validmind/unit_metrics/regression/GiniCoefficient.py +1 -1
- validmind/unit_metrics/regression/HuberLoss.py +1 -1
- validmind/unit_metrics/regression/KolmogorovSmirnovStatistic.py +1 -1
- validmind/unit_metrics/regression/{sklearn/MeanAbsoluteError.py → MeanAbsoluteError.py} +1 -1
- validmind/unit_metrics/regression/MeanAbsolutePercentageError.py +1 -1
- validmind/unit_metrics/regression/MeanBiasDeviation.py +1 -1
- validmind/unit_metrics/regression/{sklearn/MeanSquaredError.py → MeanSquaredError.py} +1 -1
- validmind/unit_metrics/regression/QuantileLoss.py +1 -1
- validmind/unit_metrics/regression/{sklearn/RSquaredScore.py → RSquaredScore.py} +1 -1
- validmind/unit_metrics/regression/{sklearn/RootMeanSquaredError.py → RootMeanSquaredError.py} +1 -1
- validmind/utils.py +4 -0
- validmind/vm_models/dataset/dataset.py +2 -0
- validmind/vm_models/figure.py +5 -0
- validmind/vm_models/test/metric.py +1 -0
- validmind/vm_models/test/result_wrapper.py +143 -158
- validmind/vm_models/test/threshold_test.py +1 -0
- {validmind-2.5.8.dist-info → validmind-2.5.18.dist-info}/METADATA +4 -3
- validmind-2.5.18.dist-info/RECORD +324 -0
- validmind/tests/data_validation/ANOVAOneWayTable.py +0 -138
- validmind/tests/data_validation/BivariateFeaturesBarPlots.py +0 -142
- validmind/tests/data_validation/BivariateHistograms.py +0 -117
- validmind/tests/data_validation/HeatmapFeatureCorrelations.py +0 -124
- validmind/tests/data_validation/MissingValuesRisk.py +0 -88
- validmind/tests/model_validation/ModelMetadataComparison.py +0 -59
- validmind/tests/model_validation/sklearn/FeatureImportanceComparison.py +0 -83
- validmind/tests/model_validation/statsmodels/JarqueBera.py +0 -73
- validmind/tests/model_validation/statsmodels/LJungBox.py +0 -66
- validmind/tests/model_validation/statsmodels/RegressionCoeffsPlot.py +0 -135
- validmind/tests/model_validation/statsmodels/RegressionModelsCoeffs.py +0 -103
- validmind/tests/model_validation/statsmodels/RunsTest.py +0 -71
- validmind-2.5.8.dist-info/RECORD +0 -318
- {validmind-2.5.8.dist-info → validmind-2.5.18.dist-info}/LICENSE +0 -0
- {validmind-2.5.8.dist-info → validmind-2.5.18.dist-info}/WHEEL +0 -0
- {validmind-2.5.8.dist-info → validmind-2.5.18.dist-info}/entry_points.txt +0 -0
@@ -11,31 +11,38 @@ from validmind import tags, tasks
|
|
11
11
|
@tasks("regression")
|
12
12
|
def TimeSeriesDescription(dataset):
|
13
13
|
"""
|
14
|
-
Generates a detailed analysis for the provided time series dataset
|
14
|
+
Generates a detailed analysis for the provided time series dataset, summarizing key statistics to identify trends,
|
15
|
+
patterns, and data quality issues.
|
15
16
|
|
16
|
-
|
17
|
-
by providing a summary of key statistics. This helps in understanding trends, patterns, and data quality issues
|
18
|
-
within the time series.
|
17
|
+
### Purpose
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
The TimeSeriesDescription function aims to analyze an individual time series by providing a summary of key
|
20
|
+
statistics. This helps in understanding trends, patterns, and data quality issues within the time series.
|
21
|
+
|
22
|
+
### Test Mechanism
|
23
|
+
|
24
|
+
The function extracts the time series data and provides a summary of key statistics. The dataset is expected to
|
25
|
+
have a datetime index. The function checks this and raises an error if the index is not in datetime format. For
|
26
|
+
each variable (column) in the dataset, appropriate statistics including start date, end date, frequency, number of
|
27
|
+
missing values, count, min, and max values are calculated.
|
28
|
+
|
29
|
+
### Signs of High Risk
|
24
30
|
|
25
|
-
**Signs of High Risk**:
|
26
31
|
- If the index of the dataset is not in datetime format, it could lead to errors in time-series analysis.
|
27
32
|
- Inconsistent or missing data within the dataset might affect the analysis of trends and patterns.
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
### Strengths
|
35
|
+
|
36
|
+
- Provides a comprehensive summary of key statistics for each variable, helping to identify data quality issues
|
37
|
+
such as missing values.
|
38
|
+
- Helps in understanding the distribution and range of the data by including min and max values.
|
39
|
+
|
40
|
+
### Limitations
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
-
|
38
|
-
- The function does not handle large datasets efficiently, and performance may degrade with very large datasets.
|
42
|
+
- Assumes that the dataset is provided as a DataFrameDataset object with a .df attribute to access the pandas
|
43
|
+
DataFrame.
|
44
|
+
- Only analyzes datasets with a datetime index and will raise an error for other types of indices.
|
45
|
+
- Does not handle large datasets efficiently; performance may degrade with very large datasets.
|
39
46
|
"""
|
40
47
|
|
41
48
|
summary = []
|
@@ -12,30 +12,36 @@ from validmind import tags, tasks
|
|
12
12
|
@tasks("regression")
|
13
13
|
def TimeSeriesDescriptiveStatistics(dataset):
|
14
14
|
"""
|
15
|
-
|
15
|
+
Evaluates the descriptive statistics of a time series dataset to identify trends, patterns, and data quality issues.
|
16
16
|
|
17
|
-
|
18
|
-
by providing a summary of key descriptive statistics. This helps in understanding trends, patterns, and data quality issues
|
19
|
-
within the time series.
|
17
|
+
### Purpose
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
The purpose of the TimeSeriesDescriptiveStatistics function is to analyze an individual time series by providing a
|
20
|
+
summary of key descriptive statistics. This analysis helps in understanding trends, patterns, and data quality
|
21
|
+
issues within the time series dataset.
|
22
|
+
|
23
|
+
### Test Mechanism
|
24
|
+
|
25
|
+
The function extracts the time series data and provides a summary of key descriptive statistics. The dataset is
|
26
|
+
expected to have a datetime index, and the function will check this and raise an error if the index is not in a
|
27
|
+
datetime format. For each variable (column) in the dataset, appropriate statistics, including start date, end date,
|
28
|
+
min, mean, max, skewness, kurtosis, and count, are calculated.
|
29
|
+
|
30
|
+
### Signs of High Risk
|
25
31
|
|
26
|
-
**Signs of High Risk**:
|
27
32
|
- If the index of the dataset is not in datetime format, it could lead to errors in time-series analysis.
|
28
33
|
- Inconsistent or missing data within the dataset might affect the analysis of trends and patterns.
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
### Strengths
|
36
|
+
|
37
|
+
- Provides a comprehensive summary of key descriptive statistics for each variable.
|
38
|
+
- Helps identify data quality issues and understand the distribution of the data.
|
39
|
+
|
40
|
+
### Limitations
|
33
41
|
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
- It only analyzes datasets with a datetime index and will raise an error for other types of indices.
|
38
|
-
- The function does not handle large datasets efficiently, and performance may degrade with very large datasets.
|
42
|
+
- Assumes the dataset is provided as a DataFrameDataset object with a .df attribute to access the pandas DataFrame.
|
43
|
+
- Only analyzes datasets with a datetime index and will raise an error for other types of indices.
|
44
|
+
- Does not handle large datasets efficiently, and performance may degrade with very large datasets.
|
39
45
|
"""
|
40
46
|
|
41
47
|
summary = []
|
@@ -22,34 +22,41 @@ class TimeSeriesFrequency(ThresholdTest):
|
|
22
22
|
"""
|
23
23
|
Evaluates consistency of time series data frequency and generates a frequency plot.
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
time-series
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
25
|
+
### Purpose
|
26
|
+
|
27
|
+
The purpose of the TimeSeriesFrequency test is to evaluate the consistency in the frequency of data points in a
|
28
|
+
time-series dataset. This test inspects the intervals or duration between each data point to determine if a fixed
|
29
|
+
pattern (such as daily, weekly, or monthly) exists. The identification of such patterns is crucial to time-series
|
30
|
+
analysis as any irregularities could lead to erroneous results and hinder the model's capacity for identifying
|
31
|
+
trends and patterns.
|
32
|
+
|
33
|
+
### Test Mechanism
|
34
|
+
|
35
|
+
Initially, the test checks if the dataframe index is in datetime format. Subsequently, it utilizes pandas'
|
36
|
+
`infer_freq` method to identify the frequency of each data series within the dataframe. The `infer_freq` method
|
37
|
+
attempts to establish the frequency of a time series and returns both the frequency string and a dictionary
|
38
|
+
relating these strings to their respective labels. The test compares the frequencies of all datasets. If they share
|
39
|
+
a common frequency, the test passes, but it fails if they do not. Additionally, Plotly is used to create a
|
40
|
+
frequency plot, offering a visual depiction of the time differences between consecutive entries in the dataframe
|
41
|
+
index.
|
42
|
+
|
43
|
+
### Signs of High Risk
|
44
|
+
|
40
45
|
- The test fails, indicating multiple unique frequencies within the dataset. This failure could suggest irregular
|
41
46
|
intervals between observations, potentially interrupting pattern recognition or trend analysis.
|
42
47
|
- The presence of missing or null frequencies could be an indication of inconsistencies in data or gaps within the
|
43
48
|
data collection process.
|
44
49
|
|
45
|
-
|
50
|
+
### Strengths
|
51
|
+
|
46
52
|
- This test uses a systematic approach to checking the consistency of data frequency within a time-series dataset.
|
47
53
|
- It increases the model's reliability by asserting the consistency of observations over time, an essential factor
|
48
54
|
in time-series analysis.
|
49
55
|
- The test generates a visual plot, providing an intuitive representation of the dataset's frequency distribution,
|
50
56
|
which caters to visual learners and aids in interpretation and explanation.
|
51
57
|
|
52
|
-
|
58
|
+
### Limitations
|
59
|
+
|
53
60
|
- This test is only applicable to time-series datasets and hence not suitable for other types of datasets.
|
54
61
|
- The `infer_freq` method might not always correctly infer frequency when faced with missing or irregular data
|
55
62
|
points.
|
@@ -13,39 +13,40 @@ def TimeSeriesHistogram(dataset, nbins=30):
|
|
13
13
|
"""
|
14
14
|
Visualizes distribution of time-series data using histograms and Kernel Density Estimation (KDE) lines.
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
The
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
### Purpose
|
17
|
+
|
18
|
+
The TimeSeriesHistogram test aims to perform a histogram analysis on time-series data to assess the distribution of
|
19
|
+
values within a dataset over time. This test is useful for regression tasks and can be applied to various types of
|
20
|
+
data, such as internet traffic, stock prices, and weather data, providing insights into the probability
|
21
|
+
distribution, skewness, and kurtosis of the dataset.
|
22
|
+
|
23
|
+
### Test Mechanism
|
24
|
+
|
25
|
+
This test operates on a specific column within the dataset that must have a datetime type index. For each column in
|
26
|
+
the dataset, a histogram is created using Plotly's histplot function. If the dataset includes more than one
|
27
|
+
time-series, a distinct histogram is plotted for each series. Additionally, a Kernel Density Estimate (KDE) line is
|
28
|
+
drawn for each histogram, visualizing the data's underlying probability distribution. The x and y-axis labels are
|
29
|
+
hidden to focus solely on the data distribution.
|
30
|
+
|
31
|
+
### Signs of High Risk
|
32
|
+
|
30
33
|
- The dataset lacks a column with a datetime type index.
|
31
34
|
- The specified columns do not exist within the dataset.
|
32
|
-
-
|
33
|
-
the
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
-
|
38
|
-
|
39
|
-
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
-
|
44
|
-
|
45
|
-
-
|
46
|
-
|
47
|
-
- The histogram cannot handle non-numeric data columns.
|
48
|
-
- The histogram's shape may be sensitive to the number of bins used.
|
35
|
+
- High skewness or kurtosis in the data distribution, indicating potential bias.
|
36
|
+
- Presence of significant outliers in the data distribution.
|
37
|
+
|
38
|
+
### Strengths
|
39
|
+
|
40
|
+
- Serves as a visual diagnostic tool for understanding data behavior and distribution trends.
|
41
|
+
- Effective for analyzing both single and multiple time-series data.
|
42
|
+
- KDE line provides a smooth estimate of the overall trend in data distribution.
|
43
|
+
|
44
|
+
### Limitations
|
45
|
+
|
46
|
+
- Provides a high-level view without specific numeric measures such as skewness or kurtosis.
|
47
|
+
- The histogram loses some detail due to binning of data values.
|
48
|
+
- Cannot handle non-numeric data columns.
|
49
|
+
- Histogram shape may be sensitive to the number of bins used.
|
49
50
|
"""
|
50
51
|
|
51
52
|
df = dataset.df
|
@@ -62,7 +63,7 @@ def TimeSeriesHistogram(dataset, nbins=30):
|
|
62
63
|
)
|
63
64
|
fig.update_layout(
|
64
65
|
title={
|
65
|
-
"text": f"
|
66
|
+
"text": f"{col}",
|
66
67
|
"y": 0.9,
|
67
68
|
"x": 0.5,
|
68
69
|
"xanchor": "center",
|
@@ -12,22 +12,28 @@ class TimeSeriesLinePlot(Metric):
|
|
12
12
|
"""
|
13
13
|
Generates and analyses time-series data through line plots revealing trends, patterns, anomalies over time.
|
14
14
|
|
15
|
-
|
16
|
-
creation of line plots. This assists in the initial inspection of the data by providing a visual representation of
|
17
|
-
patterns, trends, seasonality, irregularity, and anomalies that may be present in the dataset over a period of time.
|
15
|
+
### Purpose
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
The TimeSeriesLinePlot metric is designed to generate and analyze time series data through the creation of line
|
18
|
+
plots. This assists in the initial inspection of the data by providing a visual representation of patterns, trends,
|
19
|
+
seasonality, irregularity, and anomalies that may be present in the dataset over a period of time.
|
20
|
+
|
21
|
+
### Test Mechanism
|
22
|
+
|
23
|
+
The mechanism for this Python class involves extracting the column names from the provided dataset and subsequently
|
24
|
+
generating line plots for each column using the Plotly Python library. For every column in the dataset, a
|
25
|
+
time-series line plot is created where the values are plotted against the dataset's datetime index. It is important
|
26
|
+
to note that indexes that are not of datetime type will result in a ValueError.
|
27
|
+
|
28
|
+
### Signs of High Risk
|
23
29
|
|
24
|
-
**Signs of High Risk**:
|
25
30
|
- Presence of time-series data that does not have datetime indices.
|
26
31
|
- Provided columns do not exist in the provided dataset.
|
27
32
|
- The detection of anomalous patterns or irregularities in the time-series plots, indicating potential high model
|
28
33
|
instability or probable predictive error.
|
29
34
|
|
30
|
-
|
35
|
+
### Strengths
|
36
|
+
|
31
37
|
- The visual representation of complex time series data, which simplifies understanding and helps in recognizing
|
32
38
|
temporal trends, patterns, and anomalies.
|
33
39
|
- The adaptability of the metric, which allows it to effectively work with multiple time series within the same
|
@@ -35,7 +41,8 @@ class TimeSeriesLinePlot(Metric):
|
|
35
41
|
- Enables the identification of anomalies and irregular patterns through visual inspection, assisting in spotting
|
36
42
|
potential data or model performance problems.
|
37
43
|
|
38
|
-
|
44
|
+
### Limitations
|
45
|
+
|
39
46
|
- The effectiveness of the metric is heavily reliant on the quality and patterns of the provided time series data.
|
40
47
|
- Exclusively a visual tool, it lacks the capability to provide quantitative measurements, making it less effective
|
41
48
|
for comparing and ranking multiple models or when specific numerical diagnostics are needed.
|
@@ -23,37 +23,42 @@ class TimeSeriesMissingValues(ThresholdTest):
|
|
23
23
|
"""
|
24
24
|
Validates time-series data quality by confirming the count of missing values is below a certain threshold.
|
25
25
|
|
26
|
-
|
26
|
+
### Purpose
|
27
|
+
|
27
28
|
This test is designed to validate the quality of a historical time-series dataset by verifying that the number of
|
28
29
|
missing values is below a specified threshold. As time-series models greatly depend on the continuity and
|
29
30
|
temporality of data points, missing values could compromise the model's performance. Consequently, this test aims
|
30
31
|
to ensure data quality and readiness for the machine learning model, safeguarding its predictive capacity.
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
### Test Mechanism
|
34
|
+
|
35
|
+
The test method commences by validating if the dataset has a datetime index; if not, an error is raised. It
|
34
36
|
establishes a lower limit threshold for missing values and performs a missing values check on each column of the
|
35
37
|
dataset. An object for the test result is created stating whether the number of missing values is within the
|
36
38
|
specified threshold. Additionally, the test calculates the percentage of missing values alongside the raw count.
|
37
39
|
|
38
|
-
To aid in data visualization, the test generates two plots - a bar plot and a heatmap
|
39
|
-
distribution and quantity of missing values per variable. The test results, a count of missing values,
|
40
|
-
percentage of missing values, and a pass/fail status are returned in a results table.
|
40
|
+
To aid in data visualization, the test generates two plots - a bar plot and a heatmap - to better illustrate the
|
41
|
+
distribution and quantity of missing values per variable. The test results, including a count of missing values,
|
42
|
+
the percentage of missing values, and a pass/fail status, are returned in a results table.
|
43
|
+
|
44
|
+
### Signs of High Risk
|
41
45
|
|
42
|
-
**Signs of High Risk**:
|
43
46
|
- The number of missing values in any column of the dataset surpasses the threshold, marking a failure and a
|
44
47
|
high-risk scenario. The reasons could range from incomplete data collection, faulty sensors to data preprocessing
|
45
48
|
errors.
|
46
49
|
- A continuous visual 'streak' in the heatmap may indicate a systematic error during data collection, pointing
|
47
50
|
towards another potential risk source.
|
48
51
|
|
49
|
-
|
50
|
-
|
52
|
+
### Strengths
|
53
|
+
|
54
|
+
- Effectively identifies missing values which could adversely affect the model’s performance.
|
51
55
|
- Applicable and customizable through the threshold parameter across different data sets.
|
52
56
|
- Goes beyond raw numbers by calculating the percentage of missing values, offering a more relative understanding
|
53
57
|
of data scarcity.
|
54
58
|
- Includes a robust visualization mechanism for easy and fast understanding of data quality.
|
55
59
|
|
56
|
-
|
60
|
+
### Limitations
|
61
|
+
|
57
62
|
- Although it identifies missing values, the test does not provide solutions to handle them.
|
58
63
|
- The test demands that the dataset should have a datetime index, hence limiting its use only to time series
|
59
64
|
analysis.
|
@@ -20,43 +20,47 @@ from validmind.vm_models import (
|
|
20
20
|
@dataclass
|
21
21
|
class TimeSeriesOutliers(ThresholdTest):
|
22
22
|
"""
|
23
|
-
Identifies and visualizes outliers in time-series data using z-score method.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
Identifies and visualizes outliers in time-series data using the z-score method.
|
24
|
+
|
25
|
+
### Purpose
|
26
|
+
|
27
|
+
This test is designed to identify outliers in time-series data using the z-score method. It's vital for ensuring
|
28
|
+
data quality before modeling, as outliers can skew predictive models and significantly impact their overall
|
29
|
+
performance.
|
30
|
+
|
31
|
+
### Test Mechanism
|
32
|
+
|
33
|
+
The test processes a given dataset which must have datetime indexing, checks if a 'zscore_threshold' parameter has
|
34
|
+
been supplied, and identifies columns with numeric data types. After finding numeric columns, the implementer then
|
35
|
+
applies the z-score method to each numeric column, identifying outliers based on the threshold provided. Each
|
36
|
+
outlier is listed together with their variable name, z-score, timestamp, and relative threshold in a dictionary and
|
37
|
+
converted to a DataFrame for convenient output. Additionally, it produces visual plots for each time series
|
38
|
+
illustrating outliers in the context of the broader dataset. The 'zscore_threshold' parameter sets the limit beyond
|
39
|
+
which a data point will be labeled as an outlier. The default threshold is set at 3, indicating that any data point
|
40
|
+
that falls 3 standard deviations away from the mean will be marked as an outlier.
|
41
|
+
|
42
|
+
### Signs of High Risk
|
43
|
+
|
44
|
+
- Many or substantial outliers are present within the dataset, indicating significant anomalies.
|
45
|
+
- Data points with z-scores higher than the set threshold.
|
46
|
+
- Potential impact on the performance of machine learning models if outliers are not properly addressed.
|
47
|
+
|
48
|
+
### Strengths
|
49
|
+
|
47
50
|
- The z-score method is a popular and robust method for identifying outliers in a dataset.
|
48
|
-
-
|
49
|
-
-
|
50
|
-
- Provides an elaborate report
|
51
|
-
- Offers visual inspection for detected outliers
|
51
|
+
- Simplifies time series maintenance by requiring a datetime index.
|
52
|
+
- Identifies outliers for each numeric feature individually.
|
53
|
+
- Provides an elaborate report showing variables, dates, z-scores, and pass/fail tests.
|
54
|
+
- Offers visual inspection for detected outliers through plots.
|
55
|
+
|
56
|
+
### Limitations
|
52
57
|
|
53
|
-
|
54
|
-
- This test only identifies outliers in numeric columns, and won't identify outliers in categorical variables.
|
58
|
+
- The test only identifies outliers in numeric columns, not in categorical variables.
|
55
59
|
- The utility and accuracy of z-scores can be limited if the data doesn't follow a normal distribution.
|
56
60
|
- The method relies on a subjective z-score threshold for deciding what constitutes an outlier, which might not
|
57
|
-
always be suitable depending on the dataset and
|
61
|
+
always be suitable depending on the dataset and use case.
|
58
62
|
- It does not address possible ways to handle identified outliers in the data.
|
59
|
-
- The
|
63
|
+
- The requirement for a datetime index could limit its application.
|
60
64
|
"""
|
61
65
|
|
62
66
|
name = "time_series_outliers"
|
@@ -215,7 +219,7 @@ class TimeSeriesOutliers(ThresholdTest):
|
|
215
219
|
)
|
216
220
|
|
217
221
|
fig.update_layout(
|
218
|
-
title=f"
|
222
|
+
title=f"Outliers for {col}",
|
219
223
|
xaxis_title="Date",
|
220
224
|
yaxis_title=col,
|
221
225
|
)
|
@@ -23,27 +23,31 @@ class TooManyZeroValues(ThresholdTest):
|
|
23
23
|
Identifies numerical columns in a dataset that contain an excessive number of zero values, defined by a threshold
|
24
24
|
percentage.
|
25
25
|
|
26
|
-
|
26
|
+
### Purpose
|
27
|
+
|
27
28
|
The 'TooManyZeroValues' test is utilized to identify numerical columns in the dataset that may present a quantity
|
28
29
|
of zero values considered excessive. The aim is to detect situations where these may implicate data sparsity or a
|
29
30
|
lack of variation, limiting their effectiveness within a machine learning model. The definition of 'too many' is
|
30
31
|
quantified as a percentage of total values, with a default set to 3%.
|
31
32
|
|
32
|
-
|
33
|
+
### Test Mechanism
|
34
|
+
|
33
35
|
This test is conducted by looping through each column in the dataset and categorizing those that pertain to
|
34
36
|
numerical data. On identifying a numerical column, the function computes the total quantity of zero values and
|
35
37
|
their ratio to the total row count. Should the proportion exceed a pre-set threshold parameter, set by default at
|
36
|
-
0.03 or 3%, the column is considered to have failed the test. The results for each column are
|
38
|
+
0.03 or 3%, the column is considered to have failed the test. The results for each column are summarized and
|
37
39
|
reported, indicating the count and percentage of zero values for each numerical column, alongside a status
|
38
40
|
indicating whether the column has passed or failed the test.
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
of zero values when compared to the total count of rows (exceeding
|
42
|
+
### Signs of High Risk
|
43
|
+
|
44
|
+
- Numerical columns showing a high ratio of zero values when compared to the total count of rows (exceeding the
|
45
|
+
predetermined threshold).
|
43
46
|
- Columns characterized by zero values across the board suggest a complete lack of data variation, signifying high
|
44
47
|
risk.
|
45
48
|
|
46
|
-
|
49
|
+
### Strengths
|
50
|
+
|
47
51
|
- Assists in highlighting columns featuring an excess of zero values that could otherwise go unnoticed within a
|
48
52
|
large dataset.
|
49
53
|
- Provides the flexibility to alter the threshold that determines when the quantity of zero values becomes 'too
|
@@ -53,12 +57,13 @@ class TooManyZeroValues(ThresholdTest):
|
|
53
57
|
- Targets specifically numerical data, thereby avoiding inappropriate application to non-numerical columns and
|
54
58
|
mitigating the risk of false test failures.
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
### Limitations
|
61
|
+
|
62
|
+
- Is exclusively designed to check for zero values and doesn’t assess the potential impact of other values that
|
63
|
+
could affect the dataset, such as extremely high or low figures, missing values, or outliers.
|
59
64
|
- Lacks the ability to detect a repetitive pattern of zeros, which could be significant in time-series or
|
60
65
|
longitudinal data.
|
61
|
-
- Zero values can actually be meaningful in some contexts
|
66
|
+
- Zero values can actually be meaningful in some contexts; therefore, tagging them as 'too many' could potentially
|
62
67
|
misinterpret the data to some extent.
|
63
68
|
- This test does not take into consideration the context of the dataset, and fails to recognize that within certain
|
64
69
|
columns, a high number of zero values could be quite normal and not necessarily an indicator of poor data quality.
|
@@ -19,31 +19,36 @@ class UniqueRows(ThresholdTest):
|
|
19
19
|
"""
|
20
20
|
Verifies the diversity of the dataset by ensuring that the count of unique rows exceeds a prescribed threshold.
|
21
21
|
|
22
|
-
|
22
|
+
### Purpose
|
23
|
+
|
23
24
|
The UniqueRows test is designed to gauge the quality of the data supplied to the machine learning model by
|
24
25
|
verifying that the count of distinct rows in the dataset exceeds a specific threshold, thereby ensuring a varied
|
25
26
|
collection of data. Diversity in data is essential for training an unbiased and robust model that excels when faced
|
26
27
|
with novel data.
|
27
28
|
|
28
|
-
|
29
|
+
### Test Mechanism
|
30
|
+
|
29
31
|
The testing process starts with calculating the total number of rows in the dataset. Subsequently, the count of
|
30
32
|
unique rows is determined for each column in the dataset. If the percentage of unique rows (calculated as the ratio
|
31
33
|
of unique rows to the overall row count) is less than the prescribed minimum percentage threshold given as a
|
32
|
-
function parameter, the test
|
34
|
+
function parameter, the test passes. The results are cached and a final pass or fail verdict is given based on
|
33
35
|
whether all columns have successfully passed the test.
|
34
36
|
|
35
|
-
|
37
|
+
### Signs of High Risk
|
38
|
+
|
36
39
|
- A lack of diversity in data columns, demonstrated by a count of unique rows that falls short of the preset
|
37
40
|
minimum percentage threshold, is indicative of high risk.
|
38
41
|
- This lack of variety in the data signals potential issues with data quality, possibly leading to overfitting in
|
39
42
|
the model and issues with generalization, thus posing a significant risk.
|
40
43
|
|
41
|
-
|
44
|
+
### Strengths
|
45
|
+
|
42
46
|
- The UniqueRows test is efficient in evaluating the data's diversity across each information column in the dataset.
|
43
47
|
- This test provides a quick, systematic method to assess data quality based on uniqueness, which can be pivotal in
|
44
48
|
developing effective and unbiased machine learning models.
|
45
49
|
|
46
|
-
|
50
|
+
### Limitations
|
51
|
+
|
47
52
|
- A limitation of the UniqueRows test is its assumption that the data's quality is directly proportionate to its
|
48
53
|
uniqueness, which may not always hold true. There might be contexts where certain non-unique rows are essential and
|
49
54
|
should not be overlooked.
|