Metadata-Version: 2.4
Name: mmq-high-precision
Version: 0.1.3
Summary: Regressão Polinomial de Alta Precisão via Mínimos Quadrados com mpmath
Author-email: Eduardo Segovia <eduardosegovia2309@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Eduardo
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/dudusegovia/least_squares_method
Project-URL: Bug Tracker, https://github.com/dudusegovia/least_squares_method/issues
Keywords: least-squares,polynomial-regression,numerical-analysis,mpmath,high-precision
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: mpmath
Dynamic: license-file

# MMQRegressor

Solução robusta para o Método dos Mínimos Quadrados em Python, projetada para ajustar polinômios de grau elevado (10+) sem divergência numérica.
Utiliza aritmética de precisão arbitrária, correção automática para falta de dados e estabilização de matrizes mal-condicionadas.

# 🎯 O Problema

Bibliotecas padrão como NumPy utilizam aritmética de ponto flutuante (float64).
Ao ajustar polinômios de grau alto (ex.: grau 10) ou trabalhar com valores muito grandes (ex.: 2000^10), ocorrem:

Overflow / Underflow

Perda catastrófica de precisão

Coeficientes sem sentido

RankWarning (matriz quase singular)

# 🚀 A Solução: MMQRegressor

O MMQRegressor resolve esses problemas substituindo floats por objetos de precisão arbitrária usando mpmath.
Isso permite cálculos com 50, 100, 200+ casas decimais, garantindo estabilidade mesmo em matrizes de Vandermonde extremamente mal-condicionadas.

# 🔥 Principais Diferenciais
⚡ Precisão Infinita

Não depende de float64.

Você escolhe a precisão (ex.: 200 casas decimais).

# 🛡️ Blindagem Numérica (Data Augmentation)

Detecta automaticamente falta de dados (sistema indeterminado).

Gera micro-variações sintéticas (jittering) para permitir o cálculo sem distorcer a curva.

# 🔧 Regularização Ridge Automática

Aplica Tikhonov somente quando necessário (matriz singular).

# 📊 Normalização Interna

Normaliza dados via Z-score automaticamente:

𝑧
=
𝑥
−
𝜇
𝜎
z=
σ
x−μ
	​


Melhora a estabilidade sem intervenção do usuário.

# 📦 Instalação
git clone https://github.com/dudusegovia/mmq-regressor.git
cd mmq-regressor
pip install -r requirements.txt

# 🛠️ Como Usar

A API segue o padrão Scikit-Learn (fit / predict).

Exemplo 1 — Teste de Estresse (Grau Alto)

### from mmq_regressor import MMQRegressor

# Dados que normalmente quebrariam o NumPy devido à magnitude (2015^10)
x = [2010, 2011, 2012, 2013, 2014, 2015]
y = [10, 12, 15, 18, 22, 28]

# 1. Inicializa com alta precisão (100 casas decimais)
# Grau 7 com apenas 6 pontos ativa automaticamente o Data Augmentation
modelo = MMQRegressor(grau=7, precision=100)

# 2. Treinamento
coeficientes = modelo.fit(x, y)

print("Ajuste concluído com sucesso!")
print(f"Coeficientes: {coeficientes}")

# 3. Previsão na escala original
previsao = modelo.predict(2016)

print(f"Previsão para 2016: {previsao:.4f}")

📋 Dependências

Python 3.8+

numpy — operações vetoriais

mpmath — núcleo de alta precisão

📄 Licença

Este projeto está licenciado sob a MIT License.
Consulte o arquivo LICENSE para mais detalhes.
