-
Notifications
You must be signed in to change notification settings - Fork 0
Transform
Japip edited this page Oct 18, 2024
·
2 revisions
The Transform
module provides a variety of data transformation techniques for statistical analysis. It allows users to preprocess their dataset by applying different transformation methods to improve the quality and interpretability of statistical analysis.
Here is an example of how to use the Transform
class:
from Transform import Transform
# Sample dataset
dataset = [1, 2, 3, 4, 5]
# Create a Transform object
transformer = Transform(dataset)
# Apply transformations
transformer.logaritmic()
print("Logarithmic Transformation:", transformer.transformed_data)
transformer.sqrt_root()
print("Square Root Transformation:", transformer.transformed_data)
transformer.power_two()
print("Power Two Transformation:", transformer.transformed_data)
transformer.z_score()
print("Z-Score Transformation:", transformer.transformed_data)
transformer.min_max()
print("Min-Max Normalization:", transformer.transformed_data)
transformer.boxcox()
print("Box-Cox Transformation:", transformer.transformed_data, "Lambda:", transformer.lambda_value)
transformer.logit()
print("Logit Transformation:", transformer.transformed_data)
transformer.yeo_johnshon()
print("Yeo-Johnson Transformation:", transformer.transformed_data)
-
Input:
-
dataset
: A list or array of numerical data that will be transformed.
-
-
Output: Initializes the
Transform
object with sorted data and calculates basic statistics including mean, standard deviation, minimum value, maximum value, and length of the dataset. It also initializestransformed_data
to store the results of transformations.
- Function: Applies a logarithmic transformation (base 10) to each element of the dataset.
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Applies a square root transformation to each element of the dataset.
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Squares each element of the dataset.
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Computes the reciprocal (1/x) of each element in the dataset. An epsilon value is added to prevent division by zero.
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Computes the z-score for each element in the dataset, which standardizes the data by subtracting the mean and dividing by the standard deviation.
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Applies Min-Max normalization to scale each element of the dataset to a range of [0, 1].
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Applies the Box-Cox transformation, which is useful for stabilizing variance and making the data more normally distributed. It requires all input data to be positive.
-
Output: Stores the transformed data in the
transformed_data
attribute and computes the lambda value used for the transformation. Converts the transformed data to a list.
- Function: Applies the logit transformation, which is often used for probability data. It computes the natural logarithm of the odds for each value in the dataset, adding an epsilon to avoid log(0).
-
Output: Stores the transformed data in the
transformed_data
attribute.
- Function: Applies the Yeo-Johnson transformation, which is a modification of the Box-Cox transformation that can handle zero and negative values.
-
Output: Stores the transformed data in the
transformed_data
attribute and converts it to a list.