一致性评价算法
安装
pip install thinkenergy-2.1.0-py3-none-any.whl
#执行激活脚本
使用方法
1.导入引擎工厂类
from thinkenergy.thinkengine import ThinkEngineFactory
2.使用 app_key 和 app_secret 初始化引擎工厂
Tip:用户需要申请app_key 和 app_secret,否则算法无法使用
tef = ThinkEngineFactory(app_key, app_secret)
3.根据算法编码获取具体的算法引擎
Tip:每一个算法都有对应的算法编号码,针对不同的算法请传入正确的算法编号,本例中A100151代表一致性评价算法
alg_code = 'A100151'
te1 = tef.get_engine(alg_code)
4.给算法引擎设置参数(可选)
Tip:算法参数可以通过两种方式实现:
通过算法配置文件
通过set_params方法实现
不配置参数会使用默认的参数
te1.set_params(params=params) # 设置参数
5.调用算法
Tip:run()函数接收的数据为DataFarme,用户可以将自己的数据构建成符合算法的DataFarme,本例采用的是读取.csv格式文件中的数据转为DataFarme.
data = pd.read_csv(r'/tmp/sample_data_A100151.csv')
te1.run(data)
算法的使用参数说明如下:
参数 | 类型 | 示例 | 说明 |
---|---|---|---|
app_key | str | 123456 | 用户申请的app_key |
app_secret | str | 'I2NEWMBQFW7IMSD7XFZNHFARCVJAK7IZDK23BGABSWNU5QLBBCWLRFTL6QDAHDM32ZDA5ITFR6JPPJT3JHCBHZC77ZXNYSE4NUPHAEA=' | 用户申请的app_secret |
alg_code | str | A100151 | 算法编码 |
data | DataFrame | pandas二维数组 | |
params | dict | 算法配置 |
算法输入数据样例
算法传入数据DataFarme字段
#一致性
['vin', 'timestamp', 'current', 'soc', 'single_volt_list', 'single_temp_list'](最少两条数据)
输入数据样例
sample_data_A100151.csv文件内容
timestamp | current | soc | single_volt_list | single_temp_list | |
---|---|---|---|---|---|
0 | 1591489309 | -2.8 | 77 | 4.049,4.05,4.047,4.046,4.067,3.969,3.968,3.964,4.068,4.067,4.065,4.07,4.062,4.062,4.062,4.072,4.022,4.021,4.052,4.065,4.069,4.073,4.069,4.074,4.092,4.091,4.092,4.093,4.091,4.091,4.089,4.094,4.091,4.089,4.056,4.06,4.06,4.061,4.014,4.069,4.013,4.019,4.088,4.08,4.08,4.085,4.078,4.069,4.077,4.078,4.069,4.081,4.072,4.081,4.078,4.08,4.078,4.077,4.087,4.088,4.09,4.094,4.093,4.087,4.085,4.087,4.093,4.092,4.092,4.089,4.088,4.087,4.083,4.08,4.078,4.078,4.089,4.092,4.088,4.088,4.005,4.028,4.004,4.049,4.039,4.038,4.038,4.075,4.042,4.035,4.032,4.032 | 25,25,24,26,25,24,26,25,25,25,25,24,25,24,25,24 |
1 | 1591489319 | -6.5 | 77 | 4.058,4.059,4.057,4.056,4.077,3.98,3.977,3.973,4.077,4.076,4.075,4.08,4.072,4.072,4.072,4.081,4.031,4.031,4.063,4.076,4.078,4.082,4.078,4.083,4.101,4.1,4.101,4.102,4.1,4.1,4.098,4.102,4.1,4.098,4.065,4.069,4.068,4.07,4.023,4.077,4.022,4.028,4.096,4.089,4.089,4.094,4.087,4.078,4.085,4.088,4.078,4.088,4.08,4.088,4.085,4.088,4.087,4.085,4.096,4.097,4.098,4.102,4.101,4.095,4.095,4.096,4.101,4.1,4.1,4.098,4.096,4.096,4.091,4.088,4.087,4.087,4.097,4.1,4.096,4.095,4.016,4.038,4.014,4.059,4.048,4.047,4.047,4.084,4.052,4.044,4.043,4.042 | 25,25,24,26,25,24,26,25,25,25,25,24,25,24,25,24 |
2 | 1591489329 | -6.6 | 77 | 4.059,4.06,4.058,4.057,4.078,3.981,3.978,3.974,4.078,4.077,4.076,4.081,4.073,4.072,4.072,4.082,4.032,4.032,4.064,4.078,4.08,4.083,4.078,4.084,4.102,4.101,4.102,4.102,4.101,4.101,4.098,4.103,4.1,4.098,4.065,4.07,4.069,4.07,4.024,4.078,4.023,4.03,4.097,4.09,4.09,4.095,4.088,4.078,4.085,4.089,4.078,4.089,4.082,4.089,4.087,4.089,4.088,4.085,4.097,4.098,4.098,4.103,4.102,4.097,4.096,4.097,4.102,4.101,4.102,4.098,4.097,4.097,4.093,4.09,4.088,4.088,4.098,4.101,4.098,4.097,4.016,4.039,4.015,4.06,4.05,4.049,4.048,4.085,4.052,4.045,4.044,4.043 | 25,25,24,26,25,24,26,25,25,25,25,24,25,24,25,24 |
3 | 1591489340 | -6.6 | 77 | 4.06,4.061,4.058,4.057,4.078,3.981,3.978,3.975,4.078,4.078,4.077,4.081,4.074,4.073,4.073,4.083,4.032,4.032,4.065,4.078,4.081,4.084,4.08,4.085,4.102,4.101,4.103,4.103,4.102,4.102,4.098,4.104,4.101,4.1,4.067,4.071,4.07,4.072,4.025,4.078,4.024,4.03,4.098,4.092,4.091,4.096,4.09,4.081,4.088,4.091,4.081,4.091,4.083,4.091,4.089,4.091,4.09,4.088,4.098,4.098,4.101,4.104,4.104,4.098,4.097,4.098,4.103,4.103,4.103,4.1,4.098,4.098,4.094,4.091,4.09,4.089,4.1,4.103,4.098,4.098,4.018,4.039,4.017,4.062,4.051,4.05,4.05,4.087,4.055,4.047,4.046,4.045 | 25,25,24,26,25,24,26,25,25,25,25,24,25,24,25,24 |
4 | 1591489350 | -6.6 | 77 | 4.061,4.062,4.06,4.059,4.08,3.982,3.98,3.976,4.08,4.08,4.078,4.083,4.075,4.074,4.074,4.084,4.035,4.034,4.065,4.08,4.082,4.085,4.082,4.085,4.104,4.102,4.104,4.104,4.103,4.103,4.1,4.104,4.102,4.101,4.068,4.072,4.071,4.073,4.026,4.08,4.025,4.031,4.098,4.093,4.092,4.097,4.09,4.081,4.088,4.091,4.081,4.091,4.083,4.091,4.089,4.091,4.09,4.088,4.098,4.1,4.102,4.105,4.104,4.098,4.098,4.098,4.104,4.104,4.104,4.101,4.098,4.098,4.094,4.091,4.09,4.09,4.1,4.103,4.098,4.098,4.019,4.041,4.017,4.062,4.051,4.051,4.051,4.087,4.055,4.047,4.046,4.045 | 25,25,24,26,25,24,26,25,25,25,25,24,25,24,25,24 |
算法参数配置
#在配置文件中的配置
CO_PARAMS = {
'alg_config': {
'Vincon_0': 0.025, #电压一致性0分阈值
'Vincon_100': 0, #电压一致性100分阈值
'Tincon_0': 10, #温度一致性0分阈值
'Tincon_100': 0, #温度一致性100分阈值
'Rincon_0': 0.5, #内阻一致性0分阈值
'Rincon_100': 0, #内阻一致性100分阈值
'Qincon_0': 0.05, #容量一致性0分阈值
'Qincon_100': 0, #容量一致性100分阈值
'Eincon_0': 0.05, #电量一致性0分阈值
'Eincon_100': 0, #电量一致性100分阈值
}
}
详细实例demo
import pandas as pd
from thinkenergy.thinkengine import ThinkEngineFactory
app_key = '123456' # 用户申请的 app_key
app_secret = 'I2NEWMBQFW7IMSD7XFZNHFARCVJAK7IZD' \
'K23BGABSWNU5QLBBCWLRFTL6QDAHDM32Z' \
'DA5ITFR6JPPJT3JHCBHZC77ZXNYSE4NUP' \
'HAEA=' # 用户申请的 app_secret
tef = ThinkEngineFactory(app_key, app_secret) # 初始化引擎工厂
# 实例化
alg_code = 'A100151' # 算法编号.本例为一致性算法编号
data = pd.read_csv(r'/tmp/charge_trip.csv', encoding = 'gbk') # 读取 CSV
params = {
'alg_config': {
'Vincon_0': 0.025, #电压一致性0分阈值
'Vincon_100': 0, #电压一致性100分阈值
'Tincon_0': 10, #温度一致性0分阈值
'Tincon_100': 0, #温度一致性100分阈值
'Rincon_0': 0.5, #内阻一致性0分阈值
'Rincon_100': 0, #内阻一致性100分阈值
'Qincon_0': 0.05, #容量一致性0分阈值
'Qincon_100': 0, #容量一致性100分阈值
'Eincon_0': 0.05, #电量一致性0分阈值
'Eincon_100': 0, #电量一致性100分阈值
}
} #可传入符合厂商的配置参数
te1 = tef.get_engine(alg_code) # 获取一致性算法引擎
te1.set_params(params=params) # 设置参数.可选,非必须
print(te1.run(data)) # 调用一致性算法
算法结果
{
'score_V': 94.88, //电压一致性得分
'score_T': 91.31, //温度一致性得分
'score_R': 72.72, //内阻一致性得分
'score_E': 98.88, //电量一致性得分
'score_Q': 99.2, //容量一致性得分
'all_Score': 73.38 //总得分
}