Skip to content

Instantly share code, notes, and snippets.

View letthedataconfess's full-sized avatar
🎯
Focusing

Let The Data Confess letthedataconfess

🎯
Focusing
View GitHub Profile
@letthedataconfess
letthedataconfess / applying SVC model
Created January 27, 2021 07:06
sentiment analysis
from sklearn.svm import SVC
clf=SVC()
clf.fit(x_train_tfidf,y_train)
y_pred=clf.predict(x_test_tfidf)
print(y_pred, y_test)
@letthedataconfess
letthedataconfess / model evaluation
Created January 27, 2021 07:07
sentiment analysis
from sklearn.metrics import accuracy_score, classification_report,confusion_matrix
print("Accuracy score:",accuracy_score(y_pred,y_test))
print("Confusion matrix:",confusion_matrix(y_pred,y_test))
print("Classification report:",classification_report(y_pred,y_test))
@letthedataconfess
letthedataconfess / prediction
Created January 27, 2021 07:09
sentiment analysis
message=["Congratulations on building your first Sentiment Analysis model! You're going great!"]
message=tfidf.transform(message).toarray()
clf.predict(message)[0]
@letthedataconfess
letthedataconfess / stop words removal
Last active January 28, 2021 02:20
sentiment analysis
nltk.download('stopwords')
stopword_list=stopwords.words('english')
stopword_list.remove('no')
stopword_list.remove('not')
df.review=df.review.apply(lambda x : " ".join(x for x in x.split() if x not in stopword_list))
df['review'][5]
@letthedataconfess
letthedataconfess / scatter plot
Created February 1, 2021 16:13
Outlier detection
import matplotlib.pyplot as plt
x = [5,7,8,10,3,17,4,9,7,9,8,9,6]
y = [40,36,47,48,120,46,67,48,31,134,50,35,56]
plt.scatter(x, y)
plt.show()
@letthedataconfess
letthedataconfess / boxplot
Created February 1, 2021 16:20
outlier detection
import matplotlib.pyplot as plt
data =[20,25,27,75,40,67,62,75,78,71,32,82,127,140,78,67,132,82,87,66,56,52]
plt.boxplot(data,vert=False)
plt.show()
@letthedataconfess
letthedataconfess / Z score
Created February 1, 2021 16:24
outlier detection
import numpy as np
outliers=[]
dataset=[11,10,12,14,12,15,14,13,15,102,12,14,17,19,107,10,13,12,14,12,108,12,11,14,13,15,10,15,12,10,14,13,15,10]
def detect_outliers(data):
threshold=3
mean=np.mean(data)
std=np.std(data)
for i in dataset:
@letthedataconfess
letthedataconfess / interquartlie range
Created February 1, 2021 16:32
outlier_detection
dataset=[11,10,12,14,12,15,14,13,15,102,12,14,17,19,107,10,13,12,14,12,108,12,11,14,13,15,10,15,12,10,14,13,15,10]
dataset=sorted(dataset)
q1, q3= np.percentile(dataset,[25,75])
iqr = q3 - q1
lower_bound = q1 -(1.5 * iqr)
upper_bound = q3 +(1.5 * iqr)
print('lower_bound={},upper_bound={}'.format(lower_bound,upper_bound))
outliers_pt=[]
!pip install opencv-python
@letthedataconfess
letthedataconfess / Image reading.py
Last active September 19, 2021 09:18
opencv part 1
img = cv2.imread('Zebra.jpg')
plt.figure(figsize = (10,6))
plt.imshow(img)