随笔分类 - Python
摘要:#!/usr/bin/python import random import numpy import matplotlib.pyplot as plt import pickle from outlier_cleaner import outlierCleaner from sklearn.lin
阅读全文
摘要:Predicting Student Admissions with Neural Networks In this notebook, we predict student admissions to graduate school at UCLA based on three pieces of
阅读全文
摘要:PyPi vs. Test PyPi Note that pypi.org and test.pypy.org are two different websites. You'll need to register separately at each website. If you only re
阅读全文
摘要:In this next section, you'll convert the Distributions code into a Python package. A package is a collection of Python modules. Although the previous
阅读全文
摘要:def my_decorator(func): def wrapper(): print("Something is happening before the function is called.") func() print("Something is happening after the f
阅读全文
摘要:The same as Javascript: // Javascript function sayHello(name) { return `Hello ${name}` } //python def say_hello(name): return f"Hello {name}"
阅读全文
摘要:class Clothing: def __init__(self, color, size, style, price): self.color = color self.size = size self.style = style self.price = price def change_pr
阅读全文
摘要:Thinking how to add tow Guessin object together? It is similar idea to Functional programming, Data type. import math import matplotlib.pyplot as plt
阅读全文
摘要:import math import matplotlib.pyplot as plt class Gaussian(): """ Gaussian distribution class for calculating and visualizing a Gaussian distribution.
阅读全文
摘要:import time import pandas as pd import numpy as np with open('books_published_last_two_years.txt') as f: recent_books = f.read().split('\n') with open
阅读全文
摘要:Using the open function, and the as and with keywords, we'll open up and read from a file. At the end of this lesson, you will be able to loop through
阅读全文
摘要:In this lesson, you will learn how to statically type variables in Python 3.6 Static typing can help you avoid errors when consumers of your variables
阅读全文
摘要:How to install Flask Use Flask to create a minimal website Build routes in Flask to respond to website endpoints Use Variable Rules to pass parts of t
阅读全文
摘要:In this lesson, you will learn how to implement pytest fixtures. Many unit tests have the same resource requirements. For example, an instantiated obj
阅读全文
摘要:In this lesson you will create a new project with a virtual environment and write your first unit test with pytest. In doing so, you will learn: insta
阅读全文
摘要:Let's you have $10000, and you inverst 4 stocks. ['SPY', 'IBM', 'XOM', 'GOOG']. The allocation is [0.4, 0.4, 0.1, 0.1] separately. The way to calculat
阅读全文
摘要:Sploe = 2: means that SPY move up 1, ABC move up 2 Correlation: how close those dots close to the line.
阅读全文
摘要:In this lesson, you will be introduced to Python generators. You will see how a generator can replace a common function and learn the benefits of doin
阅读全文
摘要:A histogram is an accurate representation of the distribution of numerical data. Y axis is the occurances, X axis is the % of daily return. There are
阅读全文
摘要:In the store marketing, for many reason, one stock's data can be incomplete: We can use 'forward fill' and 'backward fill' to fill the gap: forward fi
阅读全文