From d0be693bbb55feabaa571cf2f0454d9ee400affb Mon Sep 17 00:00:00 2001 From: Avinash Barnwal Date: Tue, 24 Sep 2019 21:46:32 -0400 Subject: [PATCH] remove build --- .DS_Store | Bin 8196 -> 6148 bytes build/lib/stepwisereg/__init__.py | 5 -- build/lib/stepwisereg/stepwisereg.py | 72 ------------------------ stepwisereg/__init__.py | 2 +- stepwisereg/test/lusc_lung_cancer.ipynb | 1 - stepwisereg/test/lusc_lung_cancer.py | 3 +- 6 files changed, 2 insertions(+), 81 deletions(-) delete mode 100644 build/lib/stepwisereg/__init__.py delete mode 100644 build/lib/stepwisereg/stepwisereg.py diff --git a/.DS_Store b/.DS_Store index b556f4c0a5f8710bc3f501f3b6cf78b6cbdb8e47..47698bd368c867a32f79bb03ae1b1f8fa786c597 100644 GIT binary patch delta 325 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjdEU6q~50D9i%lfW=ZgbMljua`KZV7Ot!Z z39~XJF_bc7GUPD8rJ%a4fwabdFaWX`7&sY%7+e_~8C)2AfwUe&E{2YkXgW9;iWyQF zN`U4U0M!>TRKhF=ssp;uiBTL)12<4Z2~bM`Lpjh%Ak9TUoQ|rEu@#|fW1%(MVs;J= wL1v&B5D0Js30IKMHx_xmjD0& literal 8196 zcmeHLPfQ$D82>(?Ff)ZRP)fHI%BBmEDy=LHhQWx{yTWE(VlGe;6bDDpeId~#MX=P;KitiUTQQke($|mf^11oq$Zu0y!XBN z{=9kb_kQzUz5xJ?XZ0vR2mmCiOsZR{xlLhqRtrjzuVF@{cz`rmU?g&GI$;%f2Z{iJ z0D%C30D%C30D=Dl0(57yB5iQ*3v18@2m}b+lL)Z$AxxFYm@k)w-6Y*2xWd znwNFsT4s_znYxki`@@c7t@gFVsA=S;)S6z$_B7KrGHcvVj+wUZIaGPp1~nE}mO@{*qW1`ey@Fu3P8p zg^RRiqC-h1m0shy4hGAe>rGe;hN4U!hU=>^C|g5M)F?;C&7@-wnP-hDwbCU_`sr~n zW6aTt$C8efP1)|0T9wqSWY*F=qsOwCvpen?^B(J+aGi|T%N?gwHR~Er8{}us8GYnU zq19}pfwX5jwmWKMT#}JktC+NWrF_TkhDh`NwnJS#D;3)+Ri#>~8Jja*GhrDcIaBv$ zCp0%{*t%)YoS^-&J@XmU$jDX2%kr?TrHmDITV+M<&QNGPn=qftn%;sMkt8uzU1*Q2 zek`5TX(q=Voki;05~>UBm840g@68z03boP{x?ff`Y1pN8i6I_PT4dFghtJR^i_nLZ zsHE!hh@~YAOQ_nF4oQ7d9-9-(6Us-FPN@o8La0;q<$@(X74_xx!yq9 zu<7+|74f=IXoBf`bluP;Ns7dpeVkNwx$J_y&<xqwzca@Jf${7i(s<+qd*b`}PiFS0xR`+k+mi>oSYpKN9Bj~|tlc$BC zD^YdV?)#Mb5h9c^znZ@gpI?@XBZV1=ctBf<^v9YOMQITjZbL+k)vKINa{RhZa zObiybwu4H&x`oIpA`cx_6t#rdEUaDKWGyA$3TscCtiZl2c@6P4q}}^)6}}+K{Rlt7 zFGRPSa0>xTu^el04~8*X4tbFw|f$u@zLcnVJw z=7?~Mcn+8FMSKZg=G420m+%dI6W_wO@jXGZRni?5&-oTF7m_aJ^!4dkF9~qtgMV&v z&vmp+Ir<$u(zACuYUhSBw&mC}G=Bbr$WJPen}3KR%(oe^^F6`T4zFZcPhf)j=B`Grb UP5%)P-2Vc2fZ+aTM7&4Kzb^a*aR2}S diff --git a/build/lib/stepwisereg/__init__.py b/build/lib/stepwisereg/__init__.py deleted file mode 100644 index 360930e..0000000 --- a/build/lib/stepwisereg/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ - -# -*- coding: utf-8 -*- - -from .stepwisereg import * - diff --git a/build/lib/stepwisereg/stepwisereg.py b/build/lib/stepwisereg/stepwisereg.py deleted file mode 100644 index c60be0b..0000000 --- a/build/lib/stepwisereg/stepwisereg.py +++ /dev/null @@ -1,72 +0,0 @@ -import numpy as np -import warnings -import os -import statsmodels.formula.api as smf -import pandas as pd -import functools -import re -warnings.filterwarnings('ignore') - - -class stepwise: - - def __init__(self,step,fit_intercept): - self.step = step - self.fit_intercept = fit_intercept - - def reduce_concat(self,x, sep=""): - return functools.reduce(lambda x, y: str(x) + sep + str(y), x) - - def fit(self,data,null_formula,full_formula,response): - - """Linear model designed by forward selection. - Parameters: - ----------- - data : pandas DataFrame with all possible predictors and response - response: string, name of response column in data - Returns: - -------- - model: an "optimal" fitted statsmodels linear model - with an intercept - selected by forward selection - evaluated by aic - """ - - null_temp = re.split('~',null_formula) - null_predic_com = null_temp[1].split('+') - null_predic = null_predic_com[1:len(null_predic_com)] - full_temp = re.split('~',full_formula) - full_predic_com = full_temp[1].split('+') - full_predic = full_predic_com[1:len(full_predic_com)] - indices = [i for i,id in enumerate(full_predic) if id not in null_predic] - domain = [full_predic[i] for i in indices] - start = set(null_predic) - remaining = set(domain) - selected = null_predic - current_score, best_new_score = float('inf'), float('inf') - score_selected = [] - variable_added = [] - - while (remaining and current_score == best_new_score and self.step >0): - scores_with_candidates = [] - for candidate in remaining: - formula = "{} ~ {}".format(response,' + '.join(selected + [candidate])) - if self.fit_intercept == 0: - formula = formula + "-1" - score = smf.ols(formula, data).fit().aic - scores_with_candidates.append((score, candidate)) - scores_with_candidates.sort() - best_new_score, best_candidate = scores_with_candidates.pop(0) - if current_score > best_new_score: - remaining.remove(best_candidate) - selected.append(best_candidate) - score_selected.append(best_new_score) - variable_added.append(best_candidate) - current_score = best_new_score - self.step=self.step-1 - formula = "{} ~ {}".format(response,' + '.join(selected)) - if self.fit_intercept == 0: - formula = formula + "-1" - model = smf.ols(formula, data).fit() - return model - diff --git a/stepwisereg/__init__.py b/stepwisereg/__init__.py index 360930e..09b50cb 100644 --- a/stepwisereg/__init__.py +++ b/stepwisereg/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from .stepwisereg import * +from stepwisereg.stepwisereg import stepwise diff --git a/stepwisereg/test/lusc_lung_cancer.ipynb b/stepwisereg/test/lusc_lung_cancer.ipynb index 0a00434..9f6eaac 100644 --- a/stepwisereg/test/lusc_lung_cancer.ipynb +++ b/stepwisereg/test/lusc_lung_cancer.ipynb @@ -98,7 +98,6 @@ "model_fit = model.fit(train,null,full,'OS_MONTHS')\n", "model_param = model_fit.params\n", "test_predict = model_fit.predict(test)\n", - "print(model_fit.summary())" ] } ], diff --git a/stepwisereg/test/lusc_lung_cancer.py b/stepwisereg/test/lusc_lung_cancer.py index 8ac165f..ff6e573 100644 --- a/stepwisereg/test/lusc_lung_cancer.py +++ b/stepwisereg/test/lusc_lung_cancer.py @@ -40,5 +40,4 @@ model = stepwisereg.stepwise(5,1) model_fit = model.fit(train,null,full,'OS_MONTHS') model_param = model_fit.params -test_predict = model_fit.predict(test) -print(model_fit.summary()) \ No newline at end of file +test_predict = model_fit.predict(test) \ No newline at end of file