This file contains hidden or 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
| # coding: utf-8 | |
| import spacy | |
| import textacy.extract | |
| ### Load spaCy's English NLP model | |
| nlp = spacy.load('en_core_web_lg') | |
| ### The text we want to examine | |
| text = """Washington, D.C., formally the District of Columbia and commonly referred to as Washington or D.C., is the capital of the United States of America.[4] Founded after the American Revolution as the seat of government of the newly independent country, Washington was named after George Washington, first President of the United States and Founding Father.[5] Washington is the principal city of the Washington metropolitan area, which has a population of 6,131,977.[6] As the seat of the United States federal government and several international organizations, the city is an important world political capital.[7] Washington is one of the most visited cities in the world, with more than 20 million annual tourists.[8][9] |
This file contains hidden or 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
| 'airconditioningtypeid' | Type of cooling system present in the home (if any) | |
|---|---|---|
| 'architecturalstyletypeid' | Architectural style of the home (ie 'ranch' 'colonial' 'split-level' etc) | |
| 'basementsqft' | Finished living area below or partially below ground level | |
| 'bathroomcnt' | Number of bathrooms in home including fractional bathrooms | |
| 'bedroomcnt' | Number of bedrooms in home | |
| 'buildingqualitytypeid' | Overall assessment of condition of the building from best (lowest) to worst (highest) | |
| 'buildingclasstypeid' | The building framing type (steel frame wood frame concrete or brick) | |
| 'calculatedbathnbr' | Number of bathrooms in home including fractional bathroom | |
| 'decktypeid' | Type of deck (if any) present on parcel | |
| 'threequarterbathnbr' | Number of 3/4 bathrooms in house (shower + sink + toilet) |
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 hidden or 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
| # A string variable | |
| name = "george" | |
| statement = " is great" | |
| ### The variable "sentence" now contains the string "george is great" | |
| sentence = name + statement | |
| # An integer variable | |
| age = 24 | |
| factor = 2 | |
| ### The variable "result" now contains the integer 48 |
This file contains hidden or 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
| a = 2000 | |
| if a > 1000: | |
| print("Big number!") | |
| elif a >= 500 and a < 1000: | |
| print("Medium number!") | |
| elif a >= 0 and a < 500: | |
| print("Small number!") | |
| else: |
This file contains hidden or 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
| # A for loop printing numbers from 1 to 10 | |
| for num in range(1, 11): | |
| print(num) | |
| # A while loop printing numbers from 1 to 10 | |
| num = 1 | |
| while num < 11: | |
| print(num) | |
| num = num + 1 | |
This file contains hidden or 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
| # We can easily story any kind of data in a list or tuple | |
| a = [1, 2, 3] | |
| b = (4, 5, 6) | |
| a = [1, 2.6, "hello"] | |
| b = (4, 5.8, "goodbye") | |
| # We can initialize an empty list and populate late it dynamically too | |
| a = list() # Method 1 of initializing | |
| a = [] # Method 2 of intializing (same results as method 1!) |
This file contains hidden or 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
| # Data is stored in a dictionary as key-values pairs | |
| my_dict = { | |
| "bob": "bob1991@gmail.com", | |
| "claire": "claire1986@gmail.com", | |
| "john": "john_22@gmail.com" | |
| } | |
| # You can initialize an empty dictionary in 2 ways | |
| my_dict = {} | |
| my_dict = dict() |
This file contains hidden or 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 math | |
| from keras import backend as K | |
| # Define our custom metric | |
| def PSNR(y_true, y_pred): | |
| max_pixel = 1.0 | |
| return 10.0 * math.log10((max_pixel ** 2) / (K.mean(K.square(y_pred - y_true)))) | |
| # Define our custom loss function | |
| def charbonnier(y_true, y_pred): |
This file contains hidden or 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 tensorflow as tf | |
| def tf_int_round(num): | |
| return tf.cast(tf.round(num), dtype=tf.int32) | |
| class resize_layer(layers.Layer): | |
| # Initialize variables | |
| def __init__(self, scale, **kwargs): | |
| self.scale = scale | |
| super(resize_layer, self).__init__(**kwargs) |