<jupyter_start><jupyter_text>Get Training and Testing Data<jupyter_code>EcommerceDataset = EcommerceDataset("EcommerceCustomers.csv")<jupyter_output><empty_output><jupyter_text>Make LinearRegression model<jupyter_code>model = LinearRegression()<jupyter_output><empty_output><jupyter_text>Train Model<jupyter_code>model.fit(EcommerceDataset.return_data()[0], EcommerceDataset.return_data()[1])<jupyter_output><empty_output><jupyter_text>Get Model Coefficient1.Avg. Session Length2.Time on App3.Length of Membershipvs AnnualAmountSpent<jupyter_code>model.coef_<jupyter_output><empty_output><jupyter_text>Get Model Accuracy using testing dataself.ChangeState() will return the test dataset<jupyter_code>EcommerceDataset.ChangeState()
getattr(EcommerceDataset, 'state')
test_data = EcommerceDataset.return_data()
pred = model.predict(test_data[0])
f"Model Accuracy: {r2_score(pred, test_data[1]) * 100:.2f}%"<jupyter_output><empty_output><jupyter_text>Save model<jupyter_code>from joblib import dump
dump(model, 'ecommerce_model_sklearn.joblib');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11194029850746269, 'fraction_numerical': 0.011194029850746268, 'mean_word_length': 15.014925373134329, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '263382', 'license': 'MIT', 'n_tokens_mistral': 385, 'n_tokens_neox': 379, 'n_words': 47, 'path': 'EcommerceRegressor.ipynb', 'repo_name': 'dae-cmyk/KaggleEcommerceAnalysisAndML', 'size': '1072'}