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
class Vector(): | |
def __new__(cls, x, y): | |
print("__new__ was invoked") | |
instance = object.__new__(cls) | |
return instance | |
def __init__(self, x, y): | |
print("__init__ was invoked") | |
self.x = x | |
self.y = y |
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
import seaborn as sns | |
sns.set(rc={'figure.figsize':(12,8)}) | |
df = sns.load_dataset('iris') | |
sns.regplot(x = "sepal_length", | |
y = "petal_length", | |
data = df, | |
color="r") |
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
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib import cm | |
import numpy as np | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') # Create the axes | |
# Data | |
X = np.linspace(-8, 8, 100) |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set_style('whitegrid') | |
% matplotlib inline | |
from sklearn.preprocessing import PolynomialFeatures | |
n_samples = 100 | |
X = np.linspace(0, 10, 100) | |
y = X ** 3 + np.random.randn(n_samples) * 100 + 100 |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set_style('whitegrid') | |
% matplotlib inline | |
from sklearn.linear_model import LinearRegression | |
n_samples = 100 | |
X = np.linspace(0, 10, 100) | |
y = X ** 3 + np.random.randn(n_samples) * 100 + 100 |
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
import os | |
count = 0 | |
for i in os.listdir(): | |
os.rename(i,str(count)+ '.'+ i.split('.')[-1]) | |
count+=1 |
Loading
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
def dividend_info(article): | |
headline = nlp(article['title']) | |
if 'date' in [token.text.lower() for token in headline]: | |
date = get_date(headline) | |
if date: | |
org = get_org(headline) | |
ticker = get_ticker(headline) | |
amount = get_amount_summary(nlp(article['summary'])) | |
pay_date = get_pay_date(nlp(article['summary'])) | |
print("HEADLINE: " + article['title']) |
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
def tagged_document(list_of_list_of_words): | |
for i, list_of_words in enumerate(list_of_list_of_words): | |
yield gensim.models.doc2vec.TaggedDocument(list_of_words, [i]) | |
training_data = list(tagged_document(data)) | |
model = gensim.models.doc2vec.Doc2Vec(vector_size=40, min_count=2, epochs=30) | |
model.build_vocab(training_data) | |
model.train(training_data, total_examples=model.corpus_count, epochs=model.epochs) |
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 newscatcher import describe_url | |
websites = ['nytimes.com', 'cronachediordinariorazzismo.org', 'libertaegiustizia.it'] | |
for website in websites: | |
print(describe_url(website)) |
OlderNewer