与利润相关的ELO评级和预测。

melo的Python项目详细描述


利润相关的ELO评级和预测模型

https://travis-ci.org/morelandjs/melo.svg?branch=master

快速启动

要求:python 2.7或3.3+与numpyscipy

使用pip

安装最新版本
pip install melo

示例用法:

import pkgutil
import numpy as np
from melo import Melo

# the package comes pre-bundled with an example dataset
pkgdata = pkgutil.get_data('melo', 'nfl.dat').splitlines()
dates, teams_home, scores_home, teams_away, scores_away = zip(
    *[l.split() for l in pkgdata[1:]])

# define a binary comparison statistic
spreads = [int(h) - int(a) for h, a
    in zip(scores_home, scores_away)]

# hyperparameters and options
k = 0.245
bias = 0.166
lines = np.arange(-50.5, 51.5)
regress = lambda months: .413 if months > 3 else 0
regress_unit = 'month'
commutes = False

# initialize the estimator
nfl_spreads = Melo(k, lines=lines, commutes=commutes,
                   regress=regress, regress_unit=regress_unit)

# fit the estimator to the training data
nfl_spreads.fit(dates, teams_home, teams_away, spreads,
                bias=bias)

# specify a comparison time
time = nfl_spreads.last_update

# predict the mean outcome at that time
mean = nfl_spreads.mean(time, 'CLE', 'KC', bias=bias)
print('CLE VS KC: {}'.format(mean))

# rank nfl teams at end of 2018 regular season
rankings = nfl_spreads.rank(time, statistic='mean')
for team, rank in rankings:
    print('{}: {}'.format(team, rank))

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何向xsi:nil元素添加另一个属性?   Java抽象泛型方法,使用具体类型实现通配符   java使用pcap4j截断pcap文件   当我放置字母a、b和c时,java中的异常预期会下降   java设置活动对话框不可取消   接口类型变量上的Java克隆   使用Java或BouncyCastle对CSR(证书签名请求)进行安全解码/读取   java调用SavingsAccount对象上的函数并打印结果   java如何在Android应用程序上显示地图上的兴趣点(POI)并与之交互?   如果在JavaFX中的ResultSet中未找到任何内容,则显示java警报   java我将springboot和@component与@scheduled一起使用,它每12小时锁定一次   ApachePOI如何使用java删除包含字符串的word表的行   java如果对象(x,y)靠近其他对象(x,y)   从未对JMSException调用java JMS CachingConnectionFactory OneException方法   javascript使用java将HTML页面转换为MS word