Skip to main content

Librería para obtener valores estadísticos para pruebas de distribución de signos, determinación de outliers y pruebas Durbin-Watson

Project description

StadisticsML

StadisticsML is a Python library designed to facilitate the use of machine learning models, specifically neural networks and Support Vector Regression (SVR), with a focus on data prediction and analysis. This library allows users to create customizable models, adjust hyperparameters, and obtain predictions and performance evaluations.

Features

  • Customizable Neural Network: Allows the creation of neural networks with multiple layers and activations, specifying the number of epochs and optimization function.
  • SVR: Implementation of Support Vector Regression, with easy adjustment of parameters like C, gamma, and epsilon.
  • Model Evaluation: Generates performance metrics such as MSE and RMSE to assess the accuracy of trained models.
  • User-Friendly Interface: Easy-to-use functions to train models and make predictions on new data.

Installation

To install the library, use the following pip command:

pip install StadisticsML

Requirements

  • numpy
  • scipy
  • scikit-learn
  • tensorflow

These packages will be installed automatically as dependencies when you install StadisticsML.

Functions

1. Customizable Neural Network (train_neural_network)

This function allows the user to create and train a neural network for regression. The adjustable parameters include:

  • X: Training input data.
  • y: Labels or expected outcomes.
  • hidden_layers_config: Configuration of the hidden layers with the number of neurons and activation functions.
  • output_neurons: Number of neurons in the output layer.
  • output_activation: Activation function for the output layer.
  • optimizer: Optimizer to use (e.g., adam, sgd).
  • loss: Loss function to use (e.g., mean_squared_error).
  • metrics: Additional metrics for model evaluation (e.g., mae, mse).
  • epochs: Number of training epochs.
  • test_size: Percentage of data allocated for testing.
  • random_state: Seed for randomization.

Example:

from StadisticsML import train_neural_network

# Example data
X = [[1], [2], [3], [4], [5]]
y = [1.1, 2.0, 2.9, 4.0, 5.1]

# Hidden layers configuration: [(neurons, activation function)]
hidden_layers_config = [(12, 'relu'), (8, 'relu')]

# Train the neural network
model, history, test_loss, predictions = train_neural_network(
    X=X, y=y, 
    hidden_layers_config=hidden_layers_config,
    epochs=100,
    test_size=0.2,
    random_state=42
)

print("Predictions:", predictions)
print("Test Loss:", test_loss)

2. Support Vector Regression (SVR) (train_svr)

This function trains a support vector regression model using customizable parameters.

  • X: Training input data.
  • y: Labels or expected outcomes.
  • C: Penalty parameter.
  • gamma: Kernel function coefficient.
  • epsilon: Tolerance margin.
  • test_size: Percentage of data allocated for testing.

Example:

from StadisticsML import train_svr

# Example data
X = [[1], [2], [3], [4], [5]]
y = [1.1, 2.0, 2.9, 4.0, 5.1]

# Train the SVR model
mse, rmse, predictions = train_svr(X=X, y=y, C=100, gamma=0.001, epsilon=0.001, test_size=0.2)

print("SVR Predictions:", predictions)
print("RMSE:", rmse)

3. Cross-Validation for Model Optimization (cross_validate_model)

This function allows the user to perform cross-validation for optimizing the hyperparameters of a neural network or SVR model.

  • model_type: Choose between 'nn' (neural network) or 'svr' (Support Vector Regression).
  • X: Input data for training.
  • y: Expected outcomes.
  • hyperparameters: A dictionary of hyperparameters to tune, such as C, gamma, epochs, etc.
  • cv_folds: Number of cross-validation folds.
  • random_state: Seed for reproducibility.

Example:

from StadisticsML import cross_validate_model

# Example data
X = [[1], [2], [3], [4], [5]]
y = [1.1, 2.0, 2.9, 4.0, 5.1]

# Hyperparameters to tune
hyperparameters = {'C': [0.1, 1, 10], 'gamma': [0.001, 0.01, 0.1]}

# Perform cross-validation for SVR
best_params, mean_score = cross_validate_model(
    model_type='svr', X=X, y=y, hyperparameters=hyperparameters, cv_folds=5, random_state=42
)

print("Best parameters:", best_params)
print("Mean score from cross-validation:", mean_score)

Contribution

If you want to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/new-feature).
  3. Make your changes and commit them (git commit -am 'Add new feature').
  4. Push the branch (git push origin feature/new-feature).
  5. Open a pull request.

Expected Contribution: Implementation of additional machine learning models.

License

This project is licensed under the MIT License. For more details, please refer to the LICENSE file.

Contact

Project details


Download files

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

Source Distribution

StadisticsML-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

StadisticsML-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file StadisticsML-1.0.0.tar.gz.

File metadata

  • Download URL: StadisticsML-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for StadisticsML-1.0.0.tar.gz
Algorithm Hash digest
SHA256 34643a6247aa5f30fd511f68fc44ed72d4d9b78c9f8ed3078303d7a6b4c05d85
MD5 63f3eaada2852b28f0b7a78bc07694d9
BLAKE2b-256 5acfe9c0c7411fe8dca81741f358d87ec815665ca78172863a78dc90aef3b447

See more details on using hashes here.

File details

Details for the file StadisticsML-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: StadisticsML-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for StadisticsML-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2de6553d48030d0baad4663888c9932932e47d6ea8ba7cfdc784e49127739104
MD5 e1623df6db9463e2638a79b6757779ad
BLAKE2b-256 427a4a672a1a50f09d9fdaab2a7df4c5cdb88516080b92f8f4fbc0abc19aaf68

See more details on using hashes here.

Supported by

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