Skip to content

Instantly share code, notes, and snippets.

View victormurcia's full-sized avatar
😀
Playing with data :]

Victor Murcia victormurcia

😀
Playing with data :]
View GitHub Profile
@victormurcia
victormurcia / rotate.py
Created October 20, 2022 04:08
rotating an image
#Rotating an image
rotated0 = imutils.rotate_bound(rgb_img,0)
rotated45 = imutils.rotate_bound(rgb_img,45)
rotated90 = imutils.rotate_bound(rgb_img,90)
fig,axs = plt.subplots(1,3, figsize=(30,15))
axs[0].imshow(rotated0)
axs[1].imshow(rotated45)
axs[2].imshow(rotated90)
plt.show()
@victormurcia
victormurcia / bgrrgb.py
Created October 20, 2022 04:05
converting bgr to rgb
#Convert image to RGB from BGR
rgb_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2RGB)
plt.figure(figsize=figsize)
plt.imshow(rgb_img)
plt.show()
@victormurcia
victormurcia / opencv_load_urimg.py
Created October 20, 2022 04:01
loading image from url with open cv
#Render image from URL
req = urllib.request.urlopen('https://www.sportbible.com/cdn-cgi/image/width=648,quality=70,format=webp,fit=pad,dpr=1/https%3A%2F%2Fs3-images.sportbible.com%2Fs3%2Fcontent%2Fcf2701795dd2a49b4d404d9fa38f99fd.jpg')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
bgr_img = cv2.imdecode(arr, -1) # 'Load it as it is'
# Determine the figures size in inches to fit image
dpi = plt.rcParams['figure.dpi']
height, width, depth = bgr_img.shape
figsize = width / float(dpi), height / float(dpi)
@victormurcia
victormurcia / get_thermo_info.py
Last active October 16, 2022 06:20
get thermodynamic properties from NIST Chemistry WebBook
def get_thermo_info(material):
'''Carries out query from NIST Chemistry WebBook for thermodynamic properties of a chemical compound
Args:
material (str): Name of compound to get thermodynamic info for
Returns:
Pandas dataframe containing query results
Raises:
If table is not found, then dataframe is filled with NaNs.
@victormurcia
victormurcia / nist_cwb_name_corr.py
Created October 16, 2022 05:30
ensure compound name is formatted correctly
#Replace commas with %2C for proper querying (this is the HEX code to represent a comma)
mat_corr = material.replace(",", "%2C").replace("(", "%28").replace(")", "%29").replace("+", "%2B")
@victormurcia
victormurcia / contingency.py
Created October 11, 2022 22:34
contingency opeth
contigency= pd.crosstab(vid_df_copy['sentiment'],vid_df_copy['Live or Studio'])
@victormurcia
victormurcia / nrc_opeth_2.py
Created October 11, 2022 16:17
nrc sentiments opeth videos concise
emotions = ['joy', 'positive', 'anticipation', 'sadness','surprise', 'negative', 'anger', 'disgust', 'trust','fear']
for emotion in emotions:
vid_df_copy[emotion] = [0 if emotion not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores[emotion] for x in vid_df_copy['denoised_str']]
@victormurcia
victormurcia / nrc_opeth.py
Created October 11, 2022 16:13
nrc sentiment scores opeth comments youtube
vid_df_copy['joy'] = [0 if 'joy' not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores['joy'] for x in vid_df_copy['denoised_str']]
vid_df_copy['positive'] = [0 if 'positive' not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores['positive'] for x in vid_df_copy['denoised_str']]
vid_df_copy['anticipation'] = [0 if 'anticipation' not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores['anticipation'] for x in vid_df_copy['denoised_str']]
vid_df_copy['sadness'] = [0 if 'sadness' not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores['sadness'] for x in vid_df_copy['denoised_str']]
vid_df_copy['surprise'] = [0 if 'surprise' not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores['surprise'] for x in vid_df_copy['denoised_str']]
vid_df_copy['negative'] = [0 if 'negative' not in NRCLex(x).raw_emotion_scores else NRCLex(x).raw_emotion_scores['negative'] for x in vid
@victormurcia
victormurcia / vader_opeth.py
Created October 11, 2022 03:01
vader_opeth comments
sid = SentimentIntensityAnalyzer()
vid_df_copy['compound'] = [sid.polarity_scores(x)['compound'] for x in vid_df_copy['denoised_str']]
vid_df_copy['neg'] = [sid.polarity_scores(x)['neg'] for x in vid_df_copy['denoised_str']]
vid_df_copy['neu'] = [sid.polarity_scores(x)['neu'] for x in vid_df_copy['denoised_str']]
vid_df_copy['pos'] = [sid.polarity_scores(x)['pos'] for x in vid_df_copy['denoised_str']]
vid_df_copy
@victormurcia
victormurcia / train_gnb.py
Created October 10, 2022 05:51
train gaussian naive bayes and test accuracy
classifier = NaiveBayesClassifier.train(train_data)
print("Gaussian Naive Bayes accuracy is:", classify.accuracy(classifier, test_data))
print(classifier.show_most_informative_features(10))