-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel-cycles-logit.py
More file actions
39 lines (30 loc) · 1.28 KB
/
model-cycles-logit.py
File metadata and controls
39 lines (30 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pandas as pd
import statsmodels.api as sm
# === Настройки ===
path = "data-251019.xlsx"
# Загружаем таблицу
df = pd.read_excel(path)
# Исключаем анкеты с ошибками
exclude_ids = [2105212553, 2105364012, 2105434991, 2117312175, 2117477460]
df = df[~df["ID"].isin(exclude_ids)]
# Целевая переменная — поддерживаемость
df["supportive"] = df["На момент начала вашей работы, описываемый далее проект был на ваш взгляд поддерживаемым"].map({
"да": 1,
"нет": 0
})
# === Признак: циклы в зависимостях ===
col_cycles = "Встречались ли циклы (двунаправленные связи) в модели"
order = ["никогда", "редко", "иногда", "часто", "всегда", "не знаю/не помню"]
mapping = {v: i for i, v in enumerate(order)}
df["Cycles"] = (
df[col_cycles]
.str.lower()
.map(lambda x: x if x in order else "не знаю/не помню")
.map(mapping)
)
# === Логистическая регрессия ===
X = sm.add_constant(df["Cycles"])
y = df["supportive"]
model = sm.Logit(y, X)
result = model.fit()
print(result.summary())