Skip to content

Instantly share code, notes, and snippets.

View Steboss's full-sized avatar

Steboss Steboss

View GitHub Profile
while True:
current_page +=1
#print("Retrieving urls...")
#connect to the url and read all the infor
res = session.get(url,verify=True) #get the url of the user
data = get_shared_data(res)
try:
media = data['entry_data'][page_name][0][section_name]['media']
media_info = data['entry_data'][page_name][0][section_name]['media']["nodes"]
count_photos = 0
@Steboss
Steboss / lovInstagram Scraping 1
Created March 8, 2018 16:27
Retrieving data from the Instagram pages
https://gist.github.com/Steboss/34d109ba95b63062e69bdab58ad806cf
@Steboss
Steboss / nltk_classifier_dict
Created March 9, 2018 11:33
nltk Bayes Classifier training with positive and negative dictionaries
https://github.com/Steboss/lovInstagram/blob/master/politics_rev1.1/berlusconi/test/basic_dict/classifier.py#L22:L26
@Steboss
Steboss / nltk
Created March 9, 2018 11:35
nltk BayesClassifier with dictionary
positive_feature = [ (format_sentence(pos_term),"pos") for pos_term in pos]
negative_feature = [ (format_sentence(neg_term),"neg") for neg_term in neg]
train_test = positive_feature + negative_feature
classifier = NaiveBayesClassifier.train(train_test)
@Steboss
Steboss / nltk_classifier_comments
Created March 9, 2018 11:38
nltk Bayes Classifier with real comments
#Training part
training = pos[:int((.5)*len(pos))] + neg[:int((.5)*len(neg))]
#this cryptic way to write it's just to select the last half part of the
#data set (above)
#and the first half dataset (below)
test = pos[int((.5)*len(pos)):] + neg[int((.5)*len(neg)):]
counter = 0
test_dataset = []
with open("basic_positive.csv","r") as reader:
@Steboss
Steboss / precision_recall_F1
Last active March 9, 2018 11:42
nltk precision, recall and F1 score
, Silvio Berlusconi, Matteo Salvini, Matteo Renzi, Luigi Di Maio
Precision, 0.96, 0.88, 0.95, 0.86
Recall, 0.85, 0.83, 0.86, 0.91
F1 score,0.90, 0.86, 0.90, 0.88
@Steboss
Steboss / precision_recall_F1.csv
Created March 9, 2018 11:43
Precision, recall and F1 score
Silvio Berlusconi Matteo Salvini Matteo Renzi Luigi Di Maio
Precision 0.96 0.88 0.95 0.86
Recall 0.85 0.83 0.86 0.91
F1 score 0.90 0.86 0.90 0.88
@Steboss
Steboss / likes_for_all_the_posts.csv
Created March 9, 2018 12:45
Total number of comments and likes received per post
Candidate Total Number of Comments Total Number of Likes
Silvio Berlusconi 4324 359'279
Matteo Salvini 5397 995'240
Matteo Renzi 1794 264'722
Luigi Di Maio 7303 820'654
@Steboss
Steboss / in_boxes.py
Created March 26, 2018 20:29
Points in a rectangle -- Python Function
def in_boxes(boxes, points):
# (N, 4, 2) = boxes.shape
# (M, 2) = points.shape
w = np.zeros(points.shape[0])
start = time.time()
for (i, point) in enumerate(points):
in_box = False
for box in boxes:
(A, B, C, D) = box
AP = (point - A)
@Steboss
Steboss / C_in_boxes.c
Created March 27, 2018 10:46
in_boxes function in C
int in_rect(double *boxes, int n_boxes,int n_boxes_coords, double *points, int n_points)
{
int counter = 0 ;
int i,j,k;
/*
Here we could cycle through the first box, retrieve the coords of Axy,B,C,D
into arrays or one array?
then cycle through th epoints and compute Ax - pointX, Ay - pointY
*/