Skip to main content

Install

# only for python3
# need: sqlite3

pip install autoleastsq

Usage

# -*- coding: utf-8 -*-  

import autoleastsq

### 从文件获取数据到 list   其他数据源只要符合数据类型和对齐就行了

filename="./test.xlsx"
lists=autoleastsq.excel_col2list(filename,["a","b","result"])


################# 多元多项式回归样例

# 挑选所需要的因子  注意append 因子次序决定了拟合的公式,和后续使用时的入口次序, append 几个因子多项式就有几元,可灵活使用

factor=[]  # factor自由多个因子的二维list
factor.append(lists[0])
factor.append(lists[1])
y = lists[2]

##################### 拟合得到多项式模型

# 返回:多项式的参数列表、 幂次,并可根据新输入的因子list 进行预测

"""
支持的参数:
pows_start=1	# pows_start 起始拟合的幂次(默认为1)
loss_min=0.01		# loss 起始误差率要求(默认0.01, 达到即拟合结束), 过程中会自动判断最可能的误差率
leastsq_mult(factor,y,pows_start,loss_min)
"""

model=autoleastsq.leastsq_mult(factor,y)

print(model.args,model.pows)  ## 最终的多项式参数 按高次向低次逐个因子排列 ; 最终的多项式参数最高幂次
print(model.func)  ##  模型公式

################# 根据拟合后结果多项式,按顺序输入得到结果

factor=[29,101]

result=model.leastsq_result(factor)

print(result)


Release files for autoleastsq 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autoleastsq 1.0.1
File Size Uploaded
autoleastsq-1.0.1.tar.gz 7.1 kB Details

Release files / autoleastsq-1.0.1.tar.gz

Download URL autoleastsq-1.0.1.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2c99b34001506d10e6bf43a86e8057cf2e2f709159250b9d5da1e8f33ca6a663
BLAKE2b-256 checksum
How to use checksums
c76dd9659a4fad8604e36b04d6a690fb7556c02af3b1e0f43085767136c53b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page