Skip to content

Commit d211137

Browse files
authored
Update LOOCV Reg.py
1 parent f1eb084 commit d211137

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

LOOCV Reg.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# in Python
44
#-------------------------------------------------------------
55

6+
#--------------------------------------------------
7+
# Example 1: Linear and Quadratic regression models
8+
#--------------------------------------------------
9+
610
# 1. generate artificial data
711
import numpy as np
812
np.random.seed(2023)
@@ -79,6 +83,24 @@
7983
# [16.169293289892607, 7.873829105930071]
8084
# The second model (Quadratic) has the lowest RMSE and thus is prefered.
8185

82-
#----
83-
# end
84-
#----
86+
#---------------------------------------
87+
# Example 2: binomial regressions models
88+
#---------------------------------------
89+
90+
# importing the data from .csv file
91+
92+
training = pd.read_csv("C:/Users/julia/OneDrive/Desktop/github/16. Crossvalidation/mtcars_training.csv")
93+
testing = pd.read_csv("C:/Users/julia/OneDrive/Desktop/github/16. Crossvalidation/mtcars_testing.csv")
94+
testing
95+
96+
# 2. Cross-Validation
97+
# fit the models on leave-one-out samples
98+
from sklearn.linear_model import LogisticRegression
99+
100+
# logistic model
101+
modl = LogisticRegression(random_state=0).fit_transform(training['mpg'])
102+
modl1 = LogisticRegression.fit(mod1, training['vs'])
103+
104+
#-----------
105+
# unfinished
106+
#-----------

0 commit comments

Comments
 (0)