from sklearn.linear_model import LogisticRegression
from fightchurn.listings.chap8.listing_8_2_logistic_regression import prepare_data, save_regression_model
from fightchurn.listings.chap8.listing_8_2_logistic_regression import save_regression_summary, save_dataset_predictions

def regression_cparam(data_set_path, C_param):
    X,y = prepare_data(data_set_path)
    retain_reg = LogisticRegression( C=C_param, penalty='l1', solver='liblinear', fit_intercept=True)
    retain_reg.fit(X, y)
    c_ext = '_c{:.3f}'.format(C_param)
    save_regression_summary(data_set_path,retain_reg,ext=c_ext)
    save_regression_model(data_set_path,retain_reg,ext=c_ext)
    save_dataset_predictions(data_set_path,retain_reg,X,ext=c_ext)


[((336, 363), 'fightchurn.listings.chap8.listing_8_2_logistic_regression.prepare_data', 'prepare_data', (['data_set_path'], {}), '(data_set_path)\n', (348, 363), False, 'from fightchurn.listings.chap8.listing_8_2_logistic_regression import prepare_data, save_regression_model\n'), ((381, 468), 'sklearn.linear_model.LogisticRegression', 'LogisticRegression', ([], {'C': 'C_param', 'penalty': '"""l1"""', 'solver': '"""liblinear"""', 'fit_intercept': '(True)'}), "(C=C_param, penalty='l1', solver='liblinear',\n    fit_intercept=True)\n", (399, 468), False, 'from sklearn.linear_model import LogisticRegression\n'), ((534, 595), 'fightchurn.listings.chap8.listing_8_2_logistic_regression.save_regression_summary', 'save_regression_summary', (['data_set_path', 'retain_reg'], {'ext': 'c_ext'}), '(data_set_path, retain_reg, ext=c_ext)\n', (557, 595), False, 'from fightchurn.listings.chap8.listing_8_2_logistic_regression import save_regression_summary, save_dataset_predictions\n'), ((598, 657), 'fightchurn.listings.chap8.listing_8_2_logistic_regression.save_regression_model', 'save_regression_model', (['data_set_path', 'retain_reg'], {'ext': 'c_ext'}), '(data_set_path, retain_reg, ext=c_ext)\n', (619, 657), False, 'from fightchurn.listings.chap8.listing_8_2_logistic_regression import prepare_data, save_regression_model\n'), ((660, 725), 'fightchurn.listings.chap8.listing_8_2_logistic_regression.save_dataset_predictions', 'save_dataset_predictions', (['data_set_path', 'retain_reg', 'X'], {'ext': 'c_ext'}), '(data_set_path, retain_reg, X, ext=c_ext)\n', (684, 725), False, 'from fightchurn.listings.chap8.listing_8_2_logistic_regression import save_regression_summary, save_dataset_predictions\n')]