<jupyter_start><jupyter_text>Data Science Internship at Widhya  Mission: Instagram Post Reach Predicition  Importing required liberaries<jupyter_code>import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error 
from sklearn.preprocessing import StandardScaler<jupyter_output><empty_output><jupyter_text>Reading and Previewing dataset<jupyter_code>df=pd.read_excel('insta.xlsx')
df.head()<jupyter_output><empty_output><jupyter_text>Removing unwanted features<jupyter_code>df = df.drop(['S.No','USERNAME','Caption','Hashtags'],axis=1)
df<jupyter_output><empty_output><jupyter_text>Data preprocessing<jupyter_code>df['Time']=df['Time since posted'].str.split(" ",n=1,expand=True)[0].astype(int)
df.head()
df.drop(['Time since posted'],axis=1)
df = df[['Followers','Time','Likes']]
df.head()<jupyter_output><empty_output><jupyter_text>Dividing and Spliting data into traing and testing set<jupyter_code>df1 = df.values
X, y = df1[:,:-1], df1[:,-1]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42)<jupyter_output><empty_output><jupyter_text>Feature scaling<jupyter_code>scaled_features = StandardScaler().fit_transform(X_train, X_test)<jupyter_output><empty_output><jupyter_text>Model Building<jupyter_code>l_reg=LinearRegression()
l_reg.fit(X_train,y_train)
print("Training completed")<jupyter_output>Training completed<jupyter_text>Training and Testing Score achived by model<jupyter_code>print('Training Score: ', round(l_reg.score(X_train,y_train)*100,2),'%')
print('Testing Score: ', round(l_reg.score(X_test,y_test)*100,2))<jupyter_output>Training Score:  35.83 %
Testing Score:  61.84<jupyter_text>Prediction on test set<jupyter_code>y_predict=l_reg.predict(X_test)<jupyter_output><empty_output><jupyter_text>Accuracy acchieved by Model<jupyter_code>from sklearn import metrics
acc=metrics.r2_score(y_test,y_predict)
print("Accuracy Score of Model: ",round(acc*100,2),'%')<jupyter_output>Accuracy Score of Model:  61.84 %<jupyter_text>Model Evaluation<jupyter_code>from sklearn import metrics
print('Mean Absolute Error:',round(metrics.mean_absolute_error(y_test,y_predict),2))
print('Mean Squared Error:',round(metrics.mean_squared_error(y_test,y_predict),2))
print('Root Mean Squared Error:',round(np.sqrt(metrics.mean_squared_error(y_test,y_predict)),2))
print('Explained Variance Score:',round(metrics.explained_variance_score(y_test,y_predict),2))<jupyter_output>Mean Absolute Error: 18.5
Mean Squared Error: 541.01
Root Mean Squared Error: 23.26
Explained Variance Score: 0.68<jupyter_text>Sample Predicition >Prediction for the post's reach for someone who has 300 followers and after 10 hours<jupyter_code>print(l_reg.predict([[300,10]]))<jupyter_output>[108.75693473]<jupyter_text>>Prediction for the post's reach for someone who has 400 followers and after 5 hours<jupyter_code>print(l_reg.predict([[400,5]]))<jupyter_output>[60.2841626]
{'fraction_non_alphanumeric': 0.12682119205298012, 'fraction_numerical': 0.031788079470198675, 'mean_word_length': 11.640167364016737, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, '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': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '496761', 'license': 'Apache-2.0', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1091, 'n_words': 183, 'path': 'Instagram Post Reach Predicition/Instagram_Post_Reach_Prediction.ipynb', 'repo_name': 'hrishikeshmalkar/Widhya-Winternship', 'size': '3020'}