Skip to content

Commit 927ac3f

Browse files
committed
Initial Commit
0 parents  commit 927ac3f

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.pyc
2+
__pycache__/
3+
.env
4+
models/
5+
outputs/
6+
*.zip
7+
8+
# Metadata OS files
9+
.DS_Store

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# GLM Learning Project
2+
3+
This is a learning project to understand **Generalised Linear Models** (GLM) using Python.

data/sample.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
age,income,balance,default
2+
25,50000,2000,0
3+
45,80000,5000,1
4+
35,62000,3000,0

notebooks/GLM_Model_Exploration.ipynb

Whitespace-only changes.

requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pandas
2+
numpy
3+
statsmodels
4+
matplotlib
5+
seaborn
6+
scikit-learn
7+
jupyter

src/glm_pipeline.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pandas as pd
2+
import statsmodels.api as sm
3+
import matplotlib.pyplot as plt
4+
5+
def load_data(filepath):
6+
df = pd.read_csv(filepath)
7+
return df
8+
9+
def preprocess_data(df, target_col, feature_cols):
10+
X = df[feature_cols]
11+
X = sm.add_constant(X)
12+
y = df[target_col]
13+
return X, y
14+
15+
def fit_glm(X, y, family=sm.families.Binomial()):
16+
model = sm.GLM(y, X, family=family)
17+
results = model.fit()
18+
return results
19+
20+
def main():
21+
df = load_data("data/sample.csv")
22+
X, y = preprocess_data(df, "default", ["age", "income", "balance"])
23+
results = fit_glm(X, y)
24+
print(results.summary())
25+
results.save("models/glm_model.pickle")
26+
27+
if __name__ == "__main__":
28+
main()

0 commit comments

Comments
 (0)