You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于7输入1输出数据拟合近似公式及方法咨询

Hey there! Let's break down how to tackle your problem of finding an approximate formula mapping columns A-G to column H (like the example y = A*G/B), plus explore more robust approaches for this task.

1. Crafting Simple Rational Approximations

If you want to stick to straightforward multiplicative/divisive forms (similar to your example), here's a practical workflow:

  • Start with correlation analysis: First, calculate the correlation between each variable (A-G) and H to identify which variables have the strongest linear relationships. For example, if A and G have strong positive correlations with H, while B has a negative correlation, a combination like A*G/B makes intuitive sense.
  • Fit coefficients to refine the formula: Don't limit yourself to fixed exponents of 1—use curve fitting to optimize constants and exponents. For instance, test a generalized form like:
    import numpy as np
    from scipy.optimize import curve_fit
    
    # Generalized rational model with adjustable exponents and scaling factor
    def rational_model(x, k, a, b, c):
        A, G, B = x
        return k * (A**a * G**b) / (B**c)
    
    # Assume A, G, B, H are numpy arrays from your dataset
    x_data = np.array([A, G, B])
    fitted_params, _ = curve_fit(rational_model, x_data, H)
    k, a, b, c = fitted_params
    print(f"Refined formula: H = {k:.2f} * (A^{a:.2f} * G^{b:.2f}) / B^{c:.2f}")
    
    This gives you a data-driven tweak to your initial intuitive formula.
2. Better Methods for Formula Discovery

If you're open to more powerful approaches that can uncover non-obvious relationships, these are worth exploring:

  • Symbolic Regression: This technique uses genetic algorithms to automatically search a space of mathematical expressions (including addition, multiplication, exponents, logs, and trigonometric functions) to find the best fit for your data. Tools like gplearn in Python make this accessible:
    from gplearn.genetic import SymbolicRegressor
    import pandas as pd
    
    # Load your dataset into a DataFrame
    df = pd.read_csv('your_data.csv')
    X = df[['A','B','C','D','E','F','G']]
    y = df['H']
    
    # Initialize the symbolic regressor
    reg = SymbolicRegressor(population_size=5000,
                            generations=20,
                            stopping_criteria=0.01,
                            verbose=1)
    reg.fit(X, y)
    
    # Print the best discovered formula
    print("Optimal symbolic formula:", reg._program)
    
    It will return a human-readable formula that balances fit quality and simplicity.
  • Feature Engineering + Regression Models: If you don't need an explicit "pretty" formula but want high prediction accuracy, create derived features (like A/B, log(C), E^2, or interactions like A*D) and use models like linear regression, random forests, or XGBoost. These models capture complex variable interactions without requiring a hand-written formula.
  • Domain-Informed Guessing: If your data comes from a specific field (e.g., engineering, physics, finance), leverage domain knowledge to narrow down potential formula forms. For example, if you're working with fluid dynamics, you might start with forms similar to the Reynolds number (density * velocity * length / viscosity) instead of guessing randomly.
3. Practical Steps to Validate
  • Evaluate fit quality: Use metrics like R² score, mean absolute error (MAE), or root mean squared error (RMSE) to compare how well different formulas/models perform on your data.
  • Test on unseen data: If possible, split your data into training and test sets to ensure your formula generalizes well, not just fits the existing data.

内容的提问来源于stack exchange,提问作者Maarten -Monica for president

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:46:17