<jupyter_start><jupyter_text>Step 1: Load libraries<jupyter_code># Data manipulation libraries
import pandas as pd
import numpy as np

##### Scikit Learn modules needed for Logistic Regression
from sklearn.linear_model import SGDClassifier, SGDRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn.preprocessing import LabelEncoder,MinMaxScaler , StandardScaler

# Plotting libraries
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes = True)
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Step 2: Load the data<jupyter_code>import os
os.getcwd()
df = pd.read_csv("Assignment_regression.csv")
df.head()
df.shape<jupyter_output><empty_output><jupyter_text>Step 3: Transform data<jupyter_code>stdscalar = StandardScaler()
X_stdscalar = stdscalar.fit_transform(df.iloc[:,:8])
X_stdscalar.shape
X_stdscalar[0:5]<jupyter_output><empty_output><jupyter_text>Step 4: Train model  Step 5: Model score on Test Data<jupyter_code># Train & Test split
x_train, x_test, y_train, y_test = train_test_split(X_stdscalar,df["tenure"],test_size=0.15,
                                                    random_state=21)

print('Shape of Training Xs:{}'.format(x_train.shape))
print('Shape of Test Xs:{}'.format(x_test.shape))
print('Shape of Training y:{}'.format(y_train.shape))
print('Shape of Test y:{}'.format(y_test.shape))
model = SGDRegressor()
model.fit(x_train, y_train)
y_predicted = model.predict(x_test)
score=model.score(x_test,y_test);#testing the linear regression model
print(score)<jupyter_output>0.19581259930723816<jupyter_text>Step 6: Save data and model<jupyter_code>df_prediction = pd.DataFrame({"Tenure":y_test,"Predicted_tenure":y_predicted})
df_prediction.head(n=10)
import joblib
joblib.dump(model,filename= "reg_model.md")
import joblib
model = joblib.load("reg_model.md")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10967408173823073, 'fraction_numerical': 0.01758923952405587, 'mean_word_length': 7.126050420168068, 'pattern_counts': {'":': 2, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '130865', 'license': 'MIT', 'n_tokens_mistral': 696, 'n_tokens_neox': 670, 'n_words': 136, 'path': '1.Python/regression analysis/Assignment_Reg.ipynb', 'repo_name': 'kedar750/DSB7', 'size': '1933'}