<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
from matplotlib import pyplot as plt
%matplotlib inline
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error,r2_score,accuracy_score
df_dict={"Number_of_Claims":[108,19,13,124,40],
                "Total_Payment":[392.5,46.2,15.7,422.2,119.4]}
df1=pd.DataFrame(df_dict)
df1.head()
df1.dtypes
plt.scatter(df1["Number_of_Claims"],
            df1["Total_Payment"])
plt.xlabel('Number of Claims')
plt.ylabel('Total Payment')
df1.describe()
X=df1['Number_of_Claims']
Y=df1['Total_Payment']
standardized_X=preprocessing.scale(X)
standardized_Y=preprocessing.scale(Y)
X_train,X_test,y_train,y_test=train_test_split(standardized_X,standardized_Y,test_size=0.25,random_state=42)
import numpy as np
X_train=X_train.reshape(-1,1)
y_train=y_train.reshape(-1,1)
X_test=X_test.reshape(-1,1)
regression_model=LinearRegression()
regression_model.fit(X_train,y_train)
y_predicted=regression_model.predict(X_test)
rmse=mean_squared_error(y_test,y_predicted)
r2=r2_score(y_test,y_predicted)
print('Slope:',regression_model.coef_)
print('Intercept:',regression_model)
print('Root mean squared error:',rmse)
print('R2 score:',r2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12603150787696923, 'fraction_numerical': 0.04051012753188297, 'mean_word_length': 10.024793388429751, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '637570', 'license': 'Unlicense', 'n_tokens_mistral': 547, 'n_tokens_neox': 513, 'n_words': 66, 'path': 'simple_linear_case_study_1_.ipynb', 'repo_name': 'Chithra05/Supervised-Learning', 'size': '1333'}