"""
Machine Learning utilities module
All functions have dual names: full descriptive name + abbreviated alias
"""

from .metrics import (
    accuracy_score,
    precision_score,
    recall_score,
    f1_score,
    confusion_matrix,
    classification_report,
    mean_squared_error,
    mean_absolute_error,
    root_mean_squared_error,
    r2_score,
    roc_auc_score,
    # Aliases
    mae,
    mse,
    rmse,
)

from .cross_validation import (
    # Full names
    k_fold_cross_validation,
    stratified_k_fold,
    time_series_split,
    leave_one_out_cv,
    shuffle_split_cv,
    cross_validate_score,
    holdout_validation_split,
    train_val_test_split,
    # Abbreviated aliases
    kfold,
    skfold,
    tssplit,
    loocv,
    shuffle_cv,
    cv_score,
    holdout,
    tvt_split,
)

from .tuning import (
    # Full names
    grid_search_cv,
    random_search_cv,
    generate_param_grid,
    extract_best_params,
    format_cv_results,
    learning_curve_data,
    validation_curve_data,
    early_stopping_monitor,
    compare_models_cv,
    bayesian_search_simple,
    # Abbreviated aliases
    gridsearch,
    randomsearch,
    param_grid,
    best_params,
    cv_results,
    learning_curve,
    val_curve,
    early_stop,
    compare_models,
    bayesopt,
)

from .ensemble import (
    # Full names
    voting_classifier,
    voting_regressor,
    bagging_predictions,
    boosting_sequential,
    stacking_ensemble,
    weighted_average_ensemble,
    majority_vote,
    soft_vote,
    bootstrap_sample,
    out_of_bag_score,
    ensemble_diversity,
    blend_predictions,
    # Abbreviated aliases
    vote_clf,
    vote_reg,
    bagging,
    boosting,
    stacking,
    weighted_avg,
    hard_vote,
    soft_vote_alias,
    bootstrap,
    oob_score,
    diversity,
    blend,
)

from .feature_selection import (
    # Full names
    correlation_filter,
    variance_threshold_filter,
    chi_square_filter,
    mutual_information_filter,
    recursive_feature_elimination,
    forward_feature_selection,
    backward_feature_elimination,
    feature_importance_ranking,
    l1_feature_selection,
    univariate_feature_selection,
    select_k_best_features,
    remove_correlated_features,
    # Abbreviated aliases
    corr_filter,
    var_filter,
    chi2_filter,
    mi_filter,
    rfe,
    forward_select,
    backward_select,
    feat_importance,
    l1_select,
    univariate_select,
    select_k_best,
    remove_corr,
)

from .interpretation import (
    # Full names
    feature_importance_scores,
    permutation_importance,
    partial_dependence,
    shap_values_approximation,
    lime_explanation,
    decision_path_explanation,
    model_coefficients_interpretation,
    prediction_breakdown,
    feature_contribution_analysis,
    global_feature_importance,
    local_feature_importance,
    model_summary_statistics,
    # Abbreviated aliases
    feat_importance_scores,
    perm_importance,
    pdp,
    shap_approx,
    lime_explain,
    decision_path,
    coef_interpret,
    pred_breakdown,
    feat_contrib,
    global_importance,
    local_importance,
    model_summary,
)

from .pipeline import (
    # Full names
    create_pipeline,
    add_pipeline_step,
    execute_pipeline,
    validate_pipeline,
    serialize_pipeline,
    deserialize_pipeline,
    pipeline_transform,
    pipeline_fit_transform,
    get_pipeline_params,
    set_pipeline_params,
    clone_pipeline,
    pipeline_summary,
    # Abbreviated aliases
    create_pipe,
    add_step,
    execute_pipe,
    validate_pipe,
    serialize_pipe,
    deserialize_pipe,
    pipe_transform,
    pipe_fit_transform,
    get_params,
    set_params,
    clone_pipe,
    pipe_summary,
)

from .imbalanced import (
    # Full names
    random_oversampling,
    random_undersampling,
    smote_oversampling,
    tomek_links_undersampling,
    class_weight_calculator,
    stratified_sampling,
    compute_class_distribution,
    balance_dataset,
    minority_class_identifier,
    imbalance_ratio,
    synthetic_sample_generator,
    near_miss_undersampling,
    # Abbreviated aliases
    random_oversample,
    random_undersample,
    smote,
    tomek_links,
    class_weights,
    stratified_sample,
    class_dist,
    balance_data,
    minority_class,
    imbalance_ratio_alias,
    synthetic_sample,
    near_miss,
)

from .dimensionality import (
    # Full names
    pca_transform,
    explained_variance_ratio,
    scree_plot_data,
    cumulative_variance,
    pca_inverse_transform,
    truncated_svd,
    kernel_pca_transform,
    incremental_pca_transform,
    feature_projection,
    dimensionality_reduction_ratio,
    reconstruction_error,
    optimal_components,
    whitening_transform,
    component_loadings,
    biplot_data,
    # Abbreviated aliases
    pca,
    exp_var,
    scree_plot,
    cum_var,
    pca_inverse,
    svd,
    kpca,
    ipca,
    project,
    dim_ratio,
    recon_error,
    opt_components,
    whiten,
    loadings,
    biplot,
)

from .timeseries import (
    # Full names
    moving_average,
    exponential_moving_average,
    weighted_moving_average,
    seasonal_decompose,
    difference_series,
    autocorrelation,
    partial_autocorrelation,
    detect_trend,
    detect_seasonality,
    remove_trend,
    remove_seasonality,
    rolling_statistics,
    lag_features,
    time_series_split_cv,
    forecast_accuracy,
    # Abbreviated aliases
    ma,
    ema,
    wma,
    decompose,
    diff,
    acf,
    pacf,
    trend,
    seasonality,
    detrend,
    deseasonalize,
    rolling_stats,
    lag,
    ts_cv,
    forecast_acc,
)

from .clustering import (
    # Full names
    kmeans_clustering,
    hierarchical_clustering,
    dbscan_clustering,
    elbow_method,
    silhouette_score,
    euclidean_distance,
    manhattan_distance,
    cosine_similarity_distance,
    initialize_centroids,
    assign_clusters,
    update_centroids,
    calculate_inertia,
    dendrogram_data,
    cluster_purity,
    davies_bouldin_index,
    # Abbreviated aliases
    kmeans,
    hierarchical,
    dbscan,
    elbow,
    silhouette,
    euclidean,
    manhattan,
    cosine_dist,
    init_centroids,
    assign,
    update,
    inertia,
    dendrogram,
    purity,
    davies_bouldin,
)

from .anomaly_detection import (
    # Full names
    detect_zscore,
    detect_iqr,
    detect_isolation_forest,
    detect_local_outlier_factor,
    detect_dbscan,
    detect_statistical,
    remove_outliers,
    get_outlier_scores,
    visualize_anomalies,
)

from .neural_network import (
    # Activation Functions
    sigmoid,
    relu,
    leaky_relu,
    tanh,
    softmax,
    elu,
    swish,
    # Activation Derivatives
    sigmoid_derivative,
    relu_derivative,
    tanh_derivative,
    # Loss Functions
    mse_loss,
    binary_crossentropy,
    categorical_crossentropy,
    huber_loss as nn_huber_loss,
    # Weight Initialization
    xavier_init,
    he_init,
    random_init,
    zeros_init,
    ones_init,
    # Layer Operations
    dense_forward,
    dense_backward,
    dropout_forward,
    batch_norm_forward,
    # Optimization
    sgd_update,
    momentum_update,
    adam_update,
    rmsprop_update,
    # Utilities
    one_hot_encode,
    shuffle_data,
    mini_batch_generator,
    calculate_accuracy,
    confusion_matrix_nn,
)

from .gradient_descent import (
    # Basic Gradient Descent
    gradient_descent,
    batch_gradient_descent,
    stochastic_gradient_descent,
    mini_batch_gradient_descent,
    # Advanced Optimizers
    momentum_optimizer,
    nesterov_momentum,
    adagrad_optimizer,
    rmsprop_optimizer,
    adam_optimizer,
    adamw_optimizer,
    nadam_optimizer,
    adadelta_optimizer,
    # Learning Rate Schedules
    step_decay_schedule,
    exponential_decay_schedule,
    cosine_annealing_schedule,
    linear_warmup_schedule,
    polynomial_decay_schedule,
    # Utilities
    compute_gradient,
    gradient_clipping,
    check_convergence,
    line_search,
    compute_learning_rate,
)

from .regularization import (
    # L1/L2 Regularization
    l1_regularization,
    l2_regularization,
    elastic_net_regularization,
    l1_penalty,
    l2_penalty,
    elastic_net_penalty,
    # Dropout
    dropout,
    dropout_mask,
    inverted_dropout,
    # Early Stopping
    early_stopping_monitor as reg_early_stopping_monitor,
    should_stop_early,
    # Weight Constraints
    max_norm_constraint,
    unit_norm_constraint,
    non_negative_constraint,
    # Regularization Utilities
    compute_regularization_loss,
    apply_weight_decay,
)

from .loss_functions import (
    # Regression Losses
    mean_squared_error_loss,
    mean_absolute_error_loss,
    root_mean_squared_error_loss,
    huber_loss,
    log_cosh_loss,
    quantile_loss,
    mean_squared_logarithmic_error,
    # Classification Losses
    binary_crossentropy_loss,
    categorical_crossentropy_loss,
    sparse_categorical_crossentropy_loss,
    hinge_loss,
    squared_hinge_loss,
    categorical_hinge_loss,
    focal_loss,
    kullback_leibler_divergence,
    # Segmentation Losses
    dice_loss,
    dice_coefficient,
    iou_loss,
    tversky_loss,
    focal_tversky_loss,
    # Utilities
    combined_loss,
    weighted_loss,
)

from .activations import (
    # Basic Activations
    sigmoid_activation,
    tanh_activation,
    relu_activation,
    leaky_relu_activation,
    elu_activation,
    selu_activation,
    gelu_activation,
    swish_activation,
    mish_activation,
    softplus_activation,
    softsign_activation,
    hard_sigmoid_activation,
    hard_tanh_activation,
    softmax_activation,
    log_softmax_activation,
    # Derivatives
    sigmoid_derivative as sigmoid_deriv,
    tanh_derivative as tanh_deriv,
    relu_derivative as relu_deriv,
    leaky_relu_derivative,
    elu_derivative,
    swish_derivative,
    softplus_derivative,
    # Utilities
    apply_activation,
    get_activation_function,
)

__all__ = [
    # Metrics (full names)
    'accuracy_score',
    'precision_score',
    'recall_score',
    'f1_score',
    'confusion_matrix',
    'classification_report',
    'mean_squared_error',
    'mean_absolute_error',
    'root_mean_squared_error',
    'r2_score',
    'roc_auc_score',
    # Metrics (aliases)
    'mae',
    'mse',
    'rmse',
    # Cross-validation (full names)
    'k_fold_cross_validation',
    'stratified_k_fold',
    'time_series_split',
    'leave_one_out_cv',
    'shuffle_split_cv',
    'cross_validate_score',
    'holdout_validation_split',
    'train_val_test_split',
    # Cross-validation (aliases)
    'kfold',
    'skfold',
    'tssplit',
    'loocv',
    'shuffle_cv',
    'cv_score',
    'holdout',
    'tvt_split',
    # Tuning (full names)
    'grid_search_cv',
    'random_search_cv',
    'generate_param_grid',
    'extract_best_params',
    'format_cv_results',
    'learning_curve_data',
    'validation_curve_data',
    'early_stopping_monitor',
    'compare_models_cv',
    'bayesian_search_simple',
    # Tuning (aliases)
    'gridsearch',
    'randomsearch',
    'param_grid',
    'best_params',
    'cv_results',
    'learning_curve',
    'val_curve',
    'early_stop',
    'compare_models',
    'bayesopt',
    # Ensemble (full names)
    'voting_classifier',
    'voting_regressor',
    'bagging_predictions',
    'boosting_sequential',
    'stacking_ensemble',
    'weighted_average_ensemble',
    'majority_vote',
    'soft_vote',
    'bootstrap_sample',
    'out_of_bag_score',
    'ensemble_diversity',
    'blend_predictions',
    # Ensemble (aliases)
    'vote_clf',
    'vote_reg',
    'bagging',
    'boosting',
    'stacking',
    'weighted_avg',
    'hard_vote',
    'soft_vote_alias',
    'bootstrap',
    'oob_score',
    'diversity',
    'blend',
    # Feature Selection (full names)
    'correlation_filter',
    'variance_threshold_filter',
    'chi_square_filter',
    'mutual_information_filter',
    'recursive_feature_elimination',
    'forward_feature_selection',
    'backward_feature_elimination',
    'feature_importance_ranking',
    'l1_feature_selection',
    'univariate_feature_selection',
    'select_k_best_features',
    'remove_correlated_features',
    # Feature Selection (aliases)
    'corr_filter',
    'var_filter',
    'chi2_filter',
    'mi_filter',
    'rfe',
    'forward_select',
    'backward_select',
    'feat_importance',
    'l1_select',
    'univariate_select',
    'select_k_best',
    'remove_corr',
    # Interpretation (full names)
    'feature_importance_scores',
    'permutation_importance',
    'partial_dependence',
    'shap_values_approximation',
    'lime_explanation',
    'decision_path_explanation',
    'model_coefficients_interpretation',
    'prediction_breakdown',
    'feature_contribution_analysis',
    'global_feature_importance',
    'local_feature_importance',
    'model_summary_statistics',
    # Interpretation (aliases)
    'feat_importance_scores',
    'perm_importance',
    'pdp',
    'shap_approx',
    'lime_explain',
    'decision_path',
    'coef_interpret',
    'pred_breakdown',
    'feat_contrib',
    'global_importance',
    'local_importance',
    'model_summary',
    # Pipeline (full names)
    'create_pipeline',
    'add_pipeline_step',
    'execute_pipeline',
    'validate_pipeline',
    'serialize_pipeline',
    'deserialize_pipeline',
    'pipeline_transform',
    'pipeline_fit_transform',
    'get_pipeline_params',
    'set_pipeline_params',
    'clone_pipeline',
    'pipeline_summary',
    # Pipeline (aliases)
    'create_pipe',
    'add_step',
    'execute_pipe',
    'validate_pipe',
    'serialize_pipe',
    'deserialize_pipe',
    'pipe_transform',
    'pipe_fit_transform',
    'get_params',
    'set_params',
    'clone_pipe',
    'pipe_summary',
    # Imbalanced (full names)
    'random_oversampling',
    'random_undersampling',
    'smote_oversampling',
    'tomek_links_undersampling',
    'class_weight_calculator',
    'stratified_sampling',
    'compute_class_distribution',
    'balance_dataset',
    'minority_class_identifier',
    'imbalance_ratio',
    'synthetic_sample_generator',
    'near_miss_undersampling',
    # Imbalanced (aliases)
    'random_oversample',
    'random_undersample',
    'smote',
    'tomek_links',
    'class_weights',
    'stratified_sample',
    'class_dist',
    'balance_data',
    'minority_class',
    'imbalance_ratio_alias',
    'synthetic_sample',
    'near_miss',
    # Dimensionality (full names)
    'pca_transform',
    'explained_variance_ratio',
    'scree_plot_data',
    'cumulative_variance',
    'pca_inverse_transform',
    'truncated_svd',
    'kernel_pca_transform',
    'incremental_pca_transform',
    'feature_projection',
    'dimensionality_reduction_ratio',
    'reconstruction_error',
    'optimal_components',
    'whitening_transform',
    'component_loadings',
    'biplot_data',
    # Dimensionality (aliases)
    'pca',
    'exp_var',
    'scree_plot',
    'cum_var',
    'pca_inverse',
    'svd',
    'kpca',
    'ipca',
    'project',
    'dim_ratio',
    'recon_error',
    'opt_components',
    'whiten',
    'loadings',
    'biplot',
    # Time Series (full names)
    'moving_average',
    'exponential_moving_average',
    'weighted_moving_average',
    'seasonal_decompose',
    'difference_series',
    'autocorrelation',
    'partial_autocorrelation',
    'detect_trend',
    'detect_seasonality',
    'remove_trend',
    'remove_seasonality',
    'rolling_statistics',
    'lag_features',
    'time_series_split_cv',
    'forecast_accuracy',
    # Time Series (aliases)
    'ma',
    'ema',
    'wma',
    'decompose',
    'diff',
    'acf',
    'pacf',
    'trend',
    'seasonality',
    'detrend',
    'deseasonalize',
    'rolling_stats',
    'lag',
    'ts_cv',
    'forecast_acc',
    # Clustering (full names)
    'kmeans_clustering',
    'hierarchical_clustering',
    'dbscan_clustering',
    'elbow_method',
    'silhouette_score',
    'euclidean_distance',
    'manhattan_distance',
    'cosine_similarity_distance',
    'initialize_centroids',
    'assign_clusters',
    'update_centroids',
    'calculate_inertia',
    'dendrogram_data',
    'cluster_purity',
    'davies_bouldin_index',
    # Clustering (aliases)
    'kmeans',
    'hierarchical',
    'dbscan',
    'elbow',
    'silhouette',
    'euclidean',
    'manhattan',
    'cosine_dist',
    'init_centroids',
    'assign',
    'update',
    'inertia',
    'dendrogram',
    'purity',
    'davies_bouldin',
    # Anomaly Detection
    'detect_zscore',
    'detect_iqr',
    'detect_isolation_forest',
    'detect_local_outlier_factor',
    'detect_dbscan',
    'detect_statistical',
    'remove_outliers',
    'get_outlier_scores',
    'visualize_anomalies',
    # Neural Network - Activation Functions
    'sigmoid',
    'relu',
    'leaky_relu',
    'tanh',
    'softmax',
    'elu',
    'swish',
    # Neural Network - Activation Derivatives
    'sigmoid_derivative',
    'relu_derivative',
    'tanh_derivative',
    # Neural Network - Loss Functions
    'mse_loss',
    'binary_crossentropy',
    'categorical_crossentropy',
    'nn_huber_loss',
    # Neural Network - Weight Initialization
    'xavier_init',
    'he_init',
    'random_init',
    'zeros_init',
    'ones_init',
    # Neural Network - Layer Operations
    'dense_forward',
    'dense_backward',
    'dropout_forward',
    'batch_norm_forward',
    # Neural Network - Optimization
    'sgd_update',
    'momentum_update',
    'adam_update',
    'rmsprop_update',
    # Neural Network - Utilities
    'one_hot_encode',
    'shuffle_data',
    'mini_batch_generator',
    'calculate_accuracy',
    'confusion_matrix_nn',
    # Gradient Descent - Basic
    'gradient_descent',
    'batch_gradient_descent',
    'stochastic_gradient_descent',
    'mini_batch_gradient_descent',
    # Gradient Descent - Advanced Optimizers
    'momentum_optimizer',
    'nesterov_momentum',
    'adagrad_optimizer',
    'rmsprop_optimizer',
    'adam_optimizer',
    'adamw_optimizer',
    'nadam_optimizer',
    'adadelta_optimizer',
    # Gradient Descent - Learning Rate Schedules
    'step_decay_schedule',
    'exponential_decay_schedule',
    'cosine_annealing_schedule',
    'linear_warmup_schedule',
    'polynomial_decay_schedule',
    # Gradient Descent - Utilities
    'compute_gradient',
    'gradient_clipping',
    'check_convergence',
    'line_search',
    'compute_learning_rate',
    # Regularization - L1/L2
    'l1_regularization',
    'l2_regularization',
    'elastic_net_regularization',
    'l1_penalty',
    'l2_penalty',
    'elastic_net_penalty',
    # Regularization - Dropout
    'dropout',
    'dropout_mask',
    'inverted_dropout',
    # Regularization - Early Stopping
    'reg_early_stopping_monitor',
    'should_stop_early',
    # Regularization - Weight Constraints
    'max_norm_constraint',
    'unit_norm_constraint',
    'non_negative_constraint',
    # Regularization - Utilities
    'compute_regularization_loss',
    'apply_weight_decay',
    # Loss Functions - Regression
    'mean_squared_error_loss',
    'mean_absolute_error_loss',
    'root_mean_squared_error_loss',
    'huber_loss',
    'log_cosh_loss',
    'quantile_loss',
    'mean_squared_logarithmic_error',
    # Loss Functions - Classification
    'binary_crossentropy_loss',
    'categorical_crossentropy_loss',
    'sparse_categorical_crossentropy_loss',
    'hinge_loss',
    'squared_hinge_loss',
    'categorical_hinge_loss',
    'focal_loss',
    'kullback_leibler_divergence',
    # Loss Functions - Segmentation
    'dice_loss',
    'dice_coefficient',
    'iou_loss',
    'tversky_loss',
    'focal_tversky_loss',
    # Loss Functions - Utilities
    'combined_loss',
    'weighted_loss',
    # Activation Functions - Basic
    'sigmoid_activation',
    'tanh_activation',
    'relu_activation',
    'leaky_relu_activation',
    'elu_activation',
    'selu_activation',
    'gelu_activation',
    'swish_activation',
    'mish_activation',
    'softplus_activation',
    'softsign_activation',
    'hard_sigmoid_activation',
    'hard_tanh_activation',
    'softmax_activation',
    'log_softmax_activation',
    # Activation Functions - Derivatives
    'sigmoid_deriv',
    'tanh_deriv',
    'relu_deriv',
    'leaky_relu_derivative',
    'elu_derivative',
    'swish_derivative',
    'softplus_derivative',
    # Activation Functions - Utilities
    'apply_activation',
    'get_activation_function',
]
