-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstaAnalysis.py
More file actions
21 lines (17 loc) · 838 Bytes
/
Copy pathInstaAnalysis.py
File metadata and controls
21 lines (17 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import PassiveAggressiveRegressor
data = pd.read_csv("/Users/aniketindulkar/Documents/GitHub/MLProjects/InstagramAnalysis/Instagram.csv", encoding = 'latin1')
data = data.dropna()
x = np.array(data[['Likes', 'Saves', 'Comments', 'Shares',
'Profile Visits', 'Follows']])
y = np.array(data["Impressions"])
xtrain, xtest, ytrain, ytest = train_test_split(x, y,
test_size=0.2, random_state=42)
model = PassiveAggressiveRegressor()
model.fit(xtrain, ytrain)
model.score(xtest, ytest)
# Features = [['Likes','Saves', 'Comments', 'Shares', 'Profile Visits', 'Follows']]
features = np.array([[282.0, 233.0, 4.0, 9.0, 165.0, 54.0]])
model.predict(features)