This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gensim.models import Word2Vec | |
# read the evaluation file, get it at: | |
# https://word2vec.googlecode.com/svn/trunk/questions-words.txt | |
>>> questions = 'questions-words.txt' | |
>>> evals = open(questions, 'r').readlines() | |
>>> num_sections = len([l for l in evals if l.startswith(':')]) | |
>>> print('total evaluation sentences: {} '.format(len(evals) - num_sections)) | |
total evaluation sentences: 19544 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> # Multi-layer perceptron in Theano see: http://ir.hit.edu.cn/~jguo/docs/notes/a_simple_tutorial_on_theano.pdf | |
>>> import numpy | |
>>> import theano | |
>>> import theano.tensor as T | |
>>> rng = numpy.random | |
>>> N = 400 | |
>>> feats = 784 | |
>>> D = (rng.randn(N, feats), rng.randint(size=N, low=0,high=2) ) | |
>>> training_steps = 10000 | |
>>> x = T.matrix('x') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate gensim docset | |
# http://radimrehurek.com/gensim/ | |
#---------------------------------- | |
# built-in packages | |
import sqlite3 | |
import os | |
import urllib | |
import plistlib |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CREATING A DEDICATED NOTEBOOKS App (for IPYTHON/JUPYTER/JUPYTERLAB) INSTEAD OF THE BROWSER | |
# Fri Sep 30 02:56:42 EDT 2016 | |
# Oftentimes I get lost when I open Python notebooks in the same browser I use to surf the web. | |
# Specially when the tabs start cluttering and growing exponentially with every wild click on every tempting link. | |
# So I wanted to find a way where I can open my notebooks away from the browser's mess. | |
# I tried Pineapple.app (https://nwhitehead.github.io/pineapple/), it's cool. Specially when it comes to opening a notebook instantly just by clicking on its .ipynb file just like any other file. The problem is that Pineapple is not maintained and lack some features. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup as bs | |
import requests | |
def stars_count(url): | |
html = requests.get(url).text | |
soup = bs(html, 'lxml') | |
stars_class = "social-count js-social-count" | |
stars = soup.find('a', class_=stars_class).text.strip() | |
return stars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.1.1.js"></script> | |
<title>Weather API</title> | |
<!-- to be in a script.js --> | |
<script type="text/javascript"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create a data structure that mimics Python's list. | |
IDEA: convert each element to a base representation with a fixed size (byte / binary / octal / hexadecimal ... etc) | |
then, concat elements as a string. | |
Based on meetup: https://www.meetup.com/Deep-Dive-into-Python-Know-Thy-Interpreter/events/238587475/ | |
""" | |
class List(object): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.