数据科学篇| statsmodels库的使用(六) - 腾讯云 import statsmodels api as sm from statsmodels formula api import ols moore = sm datasets get_rdataset("Moore", "car", cache=True) # load data data = moore data data = data rename(columns={"partner status": "partner_status"}) # make name pythonic moore_lm = ols('conformity ~ C(fcategory, Sum)*C(partner_status, Sum)', data=data) fit() table = sm
使用 Statsmodels 的逻辑回归 | 码农参考 - VeryToolz在线工具 Statsmodels 提供了一个 Logit() 函数来执行逻辑回归。 Logit() 函数接受 y 和 X 作为参数并返回 Logit 对象。然后将模型拟合到数据中。 Python3 # importing libraries import statsmodels api as sm import pandas as pd # loading the training dataset df = pd read_csv('logit_train1 csv', index_col = 0)