# from pynalytics.preprocessor import Preprocessing # from pynalytics.regression.lin_regression_visual import LinRegressionVis from pynalytics.preprocessor import Preprocessing from pynalytics.regression.linear_regression.lin_regression_num import LinRegressionRes from pynalytics.regression.linear_regression.lin_regression_visual import LinRegressionVis from pynalytics.regression.polynomial_regression.poly_regression_num import PolyRegressionRes from pynalytics.regression.polynomial_regression.poly_regression_visual import PolyRegressionVis import os import pandas as pd import statsmodels.api as sm import statsmodels.formula.api as smf csv_file = os.path.dirname(__file__) + "/regrex1.csv" # csv_file = os.path.dirname(__file__) + "/Position_Salaries.csv" # csv_file = os.path.dirname(__file__) + "/Data Analytics.csv" lin_res = LinRegressionRes() lin_vis = LinRegressionVis() poly_res = PolyRegressionRes() poly_vis = PolyRegressionVis() df = pd.read_csv(csv_file) #FOR LINRES # print(lin_res.get_slope(df[["y"]], df[["x"]])) # print(lin_res.get_intercept(df[["y"]], df[["x"]])) # print(lin_res.get_rsquare(df["y"] ,df[["x", "z"]])) # how to input for MULTIPLE INDEPENDENTS # print(lin_res.get_adj_rsquare(df["y"] ,df[["x", "z"]])) # print(lin_res.get_pearsonr(df["y"] ,df[["x", "z"]])) # print(lin_res.get_pvalue(df["y"] ,df[["x"]])) # print(lin_res.line_eq(df[["y"]], df[["x"]])) #FOR LINVIS
def simp_lin_num_rslope(dv, idv): lin_res = LinRegressionRes() x = df[[idv]] y = df[[dv]] return str(lin_res.line_eq(y, x))
def lin_rtable_multi(dv, idv): lin_res = LinRegressionRes() X = df[idv] y = df[[dv]] return ('' + lin_res.lin_regression_table(y, X).to_html() + '')
def lin_rtable(dv, idv): lin_res = LinRegressionRes() x = df[[idv]] y = df[[dv]] return ('' + lin_res.lin_regression_table(y, x).to_html() + '')
def lin_pearson(dv, idv): lin_res = LinRegressionRes() x = df[[idv]] y = df[[dv]] return str(lin_res.get_pearsonr(y, x))
def lin_adj_rsquare(dv, idv): lin_res = LinRegressionRes() x = df[[idv]] y = df[[dv]] return str(lin_res.get_adj_rsquare(y, x))