Unnamed: 0 int64 0 16k | text_prompt stringlengths 110 62.1k | code_prompt stringlengths 37 152k |
|---|---|---|
5,500 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction to Earth Engine and TensorFlow in Cloud Datalab
This notebook walks you through a simple example of using Earth Engine and TensorFlow together in Cloud Datalab.
Specifically, we... | Python Code:
import ee
from IPython import display
import math
from matplotlib import pyplot
import numpy
from osgeo import gdal
import tempfile
import tensorflow as tf
import urllib
import zipfile
Explanation: Introduction to Earth Engine and TensorFlow in Cloud Datalab
This notebook walks you through a simple example... |
5,501 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Getting Started
During this tutorial, we are using IPython/Jupyter Notebooks. Jupyter notebooks are a web based Python development environment allowing you to combine documentation (markdown... | Python Code:
#include some package which we use later on
import numpy as np
#test np.ar -> tab
a = np.array([1,2,3,4])
#test np.array -> shift-tab or np.array?
Explanation: Getting Started
During this tutorial, we are using IPython/Jupyter Notebooks. Jupyter notebooks are a web based Python development environment allo... |
5,502 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Testing the Rating System
Let's generate some bernoulli based data based on my soon to be rating model and see if we can recover the parameters via pymc
Step1: Generate players and Data
Ste... | Python Code:
import pandas as pd
import numpy as np
from scipy.stats import norm, bernoulli
%matplotlib inline
Explanation: Testing the Rating System
Let's generate some bernoulli based data based on my soon to be rating model and see if we can recover the parameters via pymc
End of explanation
true_team_skill = {
... |
5,503 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
%matplotlib inline
Example
Step1: Backpropagation
Now that feedforward can be done, the next step is to decide how the parameters should change such that they minimize the cost function.
... | Python Code:
# Autograd will be used for later, so the numpy wrapper for Autograd must be imported
import autograd.numpy as np
from autograd import grad, elementwise_grad
import autograd.numpy.random as npr
from matplotlib import pyplot as plt
def sigmoid(z):
return 1/(1 + np.exp(-z))
def neural_network(params, x):... |
5,504 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Run a GOEA. Print study genes as either IDs symbols
We use data from a 2014 Nature paper
Step1: 1b. Download Associations, if necessary
Step2: 2. Load Ontologies, Associations and Backgrou... | Python Code:
# Get http://geneontology.org/ontology/go-basic.obo
from goatools.base import download_go_basic_obo
obo_fname = download_go_basic_obo()
Explanation: Run a GOEA. Print study genes as either IDs symbols
We use data from a 2014 Nature paper:
Computational analysis of cell-to-cell heterogeneity
in single-cel... |
5,505 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
DES Y6 Deep Field Exposures
Step1: 2. User Input
2.1. General User Input
Step2: 2.2. Logical Variables to Indicate which Code Cells to Run
Step3: 2.3. Sky Region Definitions
Step4: 2.4.... | Python Code:
import numpy as np
import pandas as pd
from scipy import interpolate
import glob
import math
import os
import subprocess
import sys
import gc
import glob
import pickle
import easyaccess as ea
#import AlasBabylon
import fitsio
from astropy.io import fits
import astropy.coordinates as coord
from astropy.coor... |
5,506 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Description
Step1: Init
Step2: Creating DR consensus seqs & loading into CLdb
Step3: That's it! Now, the CLdb.sqlite file contains the DR consensus sequences for each CRISPR locus
Assessi... | Python Code:
# directory where you want the spacer blasting to be done
## CHANGE THIS!
workDir = "/home/nyoungb2/t/CLdb_Ecoli/DR_consensus/"
Explanation: Description:
This notebook goes through the creation and assessment of direct repeat (DR) consensus sequences
Before running this notebook:
run the Setup notebook
Use... |
5,507 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Atmoschem
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Speci... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'sandbox-3', 'atmoschem')
Explanation: ES-DOC CMIP6 Model Properties - Atmoschem
MIP Era: CMIP6
Institute: INM
Source ID: SANDBOX-3
Topic: Atmoschem
Sub-Topics: Transport, Emiss... |
5,508 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Aerobee 150 Engine
The Aerobee 150 flew on an AJ11-26 IRFNA and ANFA hypergolic pressure fed liquid motor.
We have some information to start with.
Step1: First lets compute the fuel density... | Python Code:
from math import pi, log
# Physics
g_0 = 9.80665 # kg.m/s^2 Standard gravity
# Chemistry
rho_rfna = 1500.0 # kg/m^3 Density of IRFNA
rho_fa = 1130.0 # kg/m^3 Density of Furfuryl Alcohol
rho_an = 1021.0 # kg/m^3 Density of Aniline
# Data
Isp = 209.0 # s... |
5,509 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Correlating microstripline model to measurement
Target
The aim of this example is to correlate the microstripline model to the measurement over 4 frequency decades from 1MHz to 5GHz.
Plan
Tw... | Python Code:
%load_ext autoreload
%autoreload 2
import skrf as rf
import numpy as np
from numpy import real, log10, sum, absolute, pi, sqrt
import matplotlib.pyplot as plt
from scipy.optimize import minimize, differential_evolution
rf.stylely()
Explanation: Correlating microstripline model to measurement
Target
The aim... |
5,510 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>GetsDrawn DotCom</h1>
This is a python script to generate the website GetsDrawn. It takes data from /r/RedditGetsDrawn and makes something awesome.
The script has envolved and been rewri... | Python Code:
import os
import requests
from bs4 import BeautifulSoup
import re
import json
import time
import praw
import dominate
from dominate.tags import *
from time import gmtime, strftime
#import nose
#import unittest
import numpy as np
import pandas as pd
from pandas import *
from PIL import Image
from pprint i... |
5,511 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: TV Script Generation
In this project, you'll generate your own Simpsons TV scripts using RNNs. You'll be using part of the Simpsons dataset of scripts from 27 seasons. The Neural Ne... | Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
Explanation: TV Script Generation
In this project, you'll generate your own Simpsons TV script... |
5,512 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
controlling jobs locally
This is a set of convenient commands used to control simulations locally.
🏄 running scripts 🏄
Step1: managing lock files
counting
Step2: removing older files
⚠️... | Python Code:
!ipython3 experiment_fle.py
!ipython3 experiment_speed.py
!ipython3 experiment_contrast.py
!ipython3 experiment_MotionReversal.py
!ipython3 experiment_SI_controls.py
Explanation: controlling jobs locally
This is a set of convenient commands used to control simulations locally.
🏄 running scripts 🏄
End of... |
5,513 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Best practices
Let's start with pep8 (https
Step1: Look at Pandas Dataframes
this is italicized
Step2: Pivot Tables w/ pandas
http
Step3: Enhanced Pandas Dataframe Display
Step4: Tab
Ste... | Python Code:
%matplotlib inline
%config InlineBackend.figure_format='retina'
# Add this to python2 code to make life easier
from __future__ import absolute_import, division, print_function
import numpy as np
# don't do:
# from numpy import *
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
imp... |
5,514 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Topic Modelling
Author
Step1: 1. Corpus acquisition.
In this notebook we will explore some tools for text processing and analysis and two topic modeling algorithms available from Python too... | Python Code:
%matplotlib inline
# Required imports
from wikitools import wiki
from wikitools import category
import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
import gensim
import numpy as np
import lda
import lda.datasets
from time import time... |
5,515 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Welcome
This notebook accompanies the Sunokisis Digital Classics common session on Named Entity Extraction, see https
Step1: And more precisely, we are using the following versions
Step2: ... | Python Code:
########
# NLTK #
########
import nltk
from nltk.tag import StanfordNERTagger
########
# CLTK #
########
import cltk
from cltk.tag.ner import tag_ner
##############
# MyCapytain #
##############
import MyCapytain
from MyCapytain.resolvers.cts.api import HttpCTSResolver
from MyCapytain.retrievers.cts5 impo... |
5,516 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Calculating Transit Timing Variations (TTV) with REBOUND
The following code finds the transit times in a two planet system. The transit times of the inner planet are not exactly periodic, du... | Python Code:
import rebound
import numpy as np
Explanation: Calculating Transit Timing Variations (TTV) with REBOUND
The following code finds the transit times in a two planet system. The transit times of the inner planet are not exactly periodic, due to planet-planet interactions.
First, let's import the REBOUND and n... |
5,517 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Integration Exercise 1
Imports
Step2: Trapezoidal rule
The trapezoidal rule generates a numerical approximation to the 1d integral
Step3: Now use scipy.integrate.quad to integrate the f an... | Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
Explanation: Integration Exercise 1
Imports
End of explanation
def trapz(f, a, b, N):
Integrate the function f(x) over the range [a,b] with N points.
pts = np.linspace(a, b, N + 1)
vals = f(pts)
... |
5,518 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Your first neural network
In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've provided some of the code, but left the implementat... | Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Explanation: Your first neural network
In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've provided some of t... |
5,519 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
- Iterators are easy to understand
Step1: Python Generators
Step2: Generators are a simple and powerful tool for creating iterators.
Each iteration is computed on demand
In general terms t... | Python Code:
spam = [0, 1, 2, 3, 4]
for item in spam:
print item
else:
print "Looped whole list"
# What is really happening here?
it = iter(spam) # Obtain an iterator
try:
item = it.next() # Retrieve first item through the iterator
while True:
# Bo... |
5,520 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Chapter 3
Step1: if ... else statement
python
if <condition>
Step2: if ...elif ... else statement
python
if <condition>
Step3: Imagine that in the above program, 23 is the tem... | Python Code:
password = input("Please enter the password:")
if password == "Simsim":
print("\t> Welcome to the cave")
x = "Mayank"
y = "TEST"
if y == "TEST":
print(x)
if y:
print("Hello World")
z = None
if z:
print("TEST")
x = 11
if x > 10:
print("Hello")
if x > 10.999999999999:
print("H... |
5,521 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
2012 Presidential Campaign Finance Analysis
Chisheng Li
Introduction
This project analyzes the 2012 Presidential Campaign Contributions data to compare Barack Obama's and Mitt Romney's campa... | Python Code:
import pandas as pd
import numpy as np
donations = pd.read_csv('donations.txt', dtype={'contbr_zip': 'str', 'file_num': 'str'}, index_col=False)
# How many rows and columns does the dataframe have?
donations.shape
# The first 5 lines of the dataset
donations.head()
# Now, look at the last 5 lines
donations... |
5,522 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sierpinski Cube
Start with a cube, on iteration
Step1: Save the data
Step2: Get a mesh representation of the cube | Python Code:
def sierp_cube_iter(x0, x1, y0, y1, z0, z1, cur_depth, max_depth=3, n_pts=10, cur_index=0):
if cur_depth >= max_depth:
x = np.linspace(x0, x1, n_pts)
y = np.linspace(y0, y1, n_pts)
z = np.linspace(z0, z1, n_pts)
xx, yy, zz = np.meshgrid(x, y, z)
... |
5,523 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
In Depth - Decision Trees and Forests
Step1: Here we'll explore a class of algorithms based on decision trees.
Decision trees at their root are extremely intuitive. They
encode a series of... | Python Code:
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
Explanation: In Depth - Decision Trees and Forests
End of explanation
from figures import make_dataset
x, y = make_dataset()
X = x.reshape(-1, 1)
plt.figure()
plt.xlabel('Feature X')
plt.ylabel('Target y')
plt.scatter(X, y);
from sklea... |
5,524 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Document retrieval from wikipedia data
Fire up GraphLab Create
Step1: Load some text data - from wikipedia, pages on people
Step2: Data contains
Step3: Explore the dataset and checkout th... | Python Code:
import graphlab
Explanation: Document retrieval from wikipedia data
Fire up GraphLab Create
End of explanation
people = graphlab.SFrame('people_wiki.gl/')
Explanation: Load some text data - from wikipedia, pages on people
End of explanation
people.head()
len(people)
Explanation: Data contains: link to wik... |
5,525 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Toplevel
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specif... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-hh', 'toplevel')
Explanation: ES-DOC CMIP6 Model Properties - Toplevel
MIP Era: CMIP6
Institute: MOHC
Source ID: HADGEM3-GC31-HH
Sub-Topics: Radiative Forcings.
... |
5,526 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Converting $\LaTeX$ to <span style="font-variant
Step1: Now the variable data contains the text that is stored in this file.
Step2: $$ c = \sqrt{a^{2}+b^{2}} $$
Let us look at the output f... | Python Code:
with open('example.tex') as f:
data = f.read()
Explanation: Converting $\LaTeX$ to <span style="font-variant:small-caps;">Html</span>
The purpose of the following exercise is to implement a translator from $\LaTeX$ to
MathML. $\LaTeX$ is a document markup language
that is especially well suited to pr... |
5,527 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Python Crash Course Exercises
This is an optional exercise to test your understanding of Python Basics. If you find this extremely challenging, then you probably are not ready for the rest o... | Python Code:
7**4
Explanation: Python Crash Course Exercises
This is an optional exercise to test your understanding of Python Basics. If you find this extremely challenging, then you probably are not ready for the rest of this course yet and don't have enough programming experience to continue. I would suggest you tak... |
5,528 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>Traffic Signs Classification</h1>
<p>Using German Traffic Sign Dataset (http
Step1: <h1>Loading the Data</h1>
Step2: <h1>Data Info</h1>
<p>Spliting the train data as train and validati... | Python Code:
import matplotlib.pyplot as plt
import random as rn
import numpy as np
from sklearn.model_selection import train_test_split
import pickle
from keras.models import Sequential
from keras.layers import Dense, Input, Activation
from keras.utils import np_utils
%matplotlib inline
Explanation: <h1>Traffic Signs ... |
5,529 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: AST - Abstract Syntax Tree
For reasons, I want to parse a python source code file and extract certain elements. The case in point involves looking for all functions with a given decor... | Python Code:
import ast
example_module = '''
@my_decorator
def my_function(my_argument):
My Docstring
my_value = 420
return my_value
def foo():
pass
@Some_decorator
@Another_decorator
def bar():
pass
@MyClass.subpackage.my_deco_function
def baz():
pass'''
Explanation: AST - Ab... |
5,530 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
使用行业内的排序,进行因子测试;与回归版本,以及原始因子值版本进行比较。本部分参考自《QEPM》 p.p 117
请在环境变量中设置DB_URI指向数据库
参数设定
Step1: 样例因子
我们下面分三种方法,分别考查这几种方法在避免行业集中上面的效果:
使用原始因子的排序;
使用原始因子在行业内的排序;
使用原始因子在行业哑变量上回归后得到的残差排序。
1. 原始因子排序
... | Python Code:
%matplotlib inline
import os
import pandas as pd
import numpy as np
from PyFin.api import *
from alphamind.api import *
factor = "EMA5D"
universe = Universe('zz800')
start_date = '2020-01-01'
end_date = '2020-02-21'
freq = '10b'
category = 'sw'
level = 1
horizon = map_freq(freq)
engine = SqlEngine(os.envir... |
5,531 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Bandpass calibration demonstration
Step1: Construct LOW core configuration
Step2: We create the visibility. This just makes the uvw, time, antenna1, antenna2, weight columns in a table
Ste... | Python Code:
%matplotlib inline
import os
import sys
sys.path.append(os.path.join('..', '..'))
from data_models.parameters import arl_path
results_dir = arl_path('test_results')
from matplotlib import pylab
import numpy
from astropy.coordinates import SkyCoord
from astropy import units as u
from astropy.wcs.utils impor... |
5,532 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: Cargando datos en Pandas
Objetivo
La finalidad de este capítulo es mostrar como cargar datos desde un archivo tipo csv, pero Pandas soporta más tipo de archivos. Debido a que el módul... | Python Code:
#
# Región de estabilidad absoluta
# Juan Luis Cano Rodríguez
import numpy as np
def region_estabilidad(p, X, Y):
Región de estabilidad absoluta
Computa la región de estabilidad absoluta de un método numérico, dados
los coeficientes de su polinomio característico de estabilidad.
Argumentos
... |
5,533 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2020 The TensorFlow Authors.
Step1: 畳み込み変分オートエンコーダ
<table class="tfo-notebook-buttons" align="left">
<td><a target="_blank" href="https
Step2: MNIST データセットを読み込む
それぞれの MNIST 画像は... | Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# dist... |
5,534 |
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
Problem:
The beam_search_decoder() function implements the beam search decoder for Natural Language Processing.
| Python Code::
# beam search
def beam_search_decoder(data, k):
sequences = [[list(), 0.0]]
# walk over each step in sequence
for row in data:
all_candidates = list()
# expand each current candidate
for i in range(len(sequences)):
seq, score = sequences[i]
for j in range(len(row)):
candidate = [seq + [... |
5,535 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Vendor Recommender - EDA
@olibolly
Open TO-DO
Link the notebook with github using ungit - DONE
Provide access to the project if we go for Big query - DONE
Re-pull EDA using updated 2016-2017... | Python Code:
import google.datalab.bigquery as bq
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder
from sklearn import cross_validatio... |
5,536 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step4: version 1.0.3
+
Text Analysis and Entity Resolution
Entity resolution is a common, yet difficult problem in data cleaning and integration. This lab will demonstrate how we can use A... | Python Code:
import re
DATAFILE_PATTERN = '^(.+),"(.+)",(.*),(.*),(.*)'
def removeQuotes(s):
Remove quotation marks from an input string
Args:
s (str): input string that might have the quote "" characters
Returns:
str: a string without the quote characters
return ''.join(i for i in... |
5,537 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Parallelization with QInfer
Setup
We begin by enabling Python 3–style division, as is recommended for use in Python 2.7.
Step1: Next, we import the IPython parallelization library ipyparall... | Python Code:
from __future__ import division
Explanation: Parallelization with QInfer
Setup
We begin by enabling Python 3–style division, as is recommended for use in Python 2.7.
End of explanation
import ipyparallel as ipp
import qinfer as qi
from functools import partial
Explanation: Next, we import the IPython paral... |
5,538 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Basic Usage
This section gives a quick overview of some features and conventions that are common to all the main analysis tools. While the main analysis tools will be briefly referenced here... | Python Code:
# PySCeS model instantiation using the `example_model.py` file
# with name `mod`
mod = pysces.model('example_model')
mod.SetQuiet()
# Parameter scan setup and execution
# Here we are changing the value of `Vf2` over logarithmic
# scale from `log10(1)` (or 0) to log10(100) (or 2) for a
# 100 points.
mod.sc... |
5,539 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step4: Who Am I?
Chris Fregly
Research Scientist @ PipelineIO
Video Series Author "High Performance Tensorflow in Production" @ OReilly (Coming Soon)
Founder @ Advanced Spark and Tensorflow ... | Python Code:
import numpy as np
import os
import tensorflow as tf
from tensorflow.contrib.session_bundle import exporter
import time
# make things wide
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
from IPython.display import clear_output, Image, di... |
5,540 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1 align = 'center'> Neural Networks Demystified </h1>
<h2 align = 'center'> Part 2
Step1: <h3 align = 'center'> Variables </h3>
|Code Symbol | Math Symbol | Definition | Dimensions
|
Ste... | Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('UJwK6jAStmg')
Explanation: <h1 align = 'center'> Neural Networks Demystified </h1>
<h2 align = 'center'> Part 2: Forward Propagation </h2>
<h4 align = 'center' > @stephencwelch </h4>
End of explanation
#Import code from last time
%pylab inline
from par... |
5,541 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Ocean
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify d... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', 'sandbox-3', 'ocean')
Explanation: ES-DOC CMIP6 Model Properties - Ocean
MIP Era: CMIP6
Institute: CAS
Source ID: SANDBOX-3
Topic: Ocean
Sub-Topics: Timestepping Framework, Adve... |
5,542 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Presentation
This notebook is modified version (with added comments) of presentation given by Bart Grasza on 2017.07.15
Goals of the notebook
This notebook has multiple purposes
Step1: Pyth... | Python Code:
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
from keras.layers.embeddings import Embedding
from keras.layers.core import Dense, Dropout, Lambda
from keras.layers import Input, GlobalAveragePooling1D
from keras.layers.convolutional import ... |
5,543 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Image classification from scratch
Author
Step1: Load the data
Step2: Now we have a PetImages folder which contain two subfolders, Cat and Dog. Each
subfolder contains image files for each... | Python Code:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
Explanation: Image classification from scratch
Author: fchollet<br>
Date created: 2020/04/27<br>
Last modified: 2020/04/28<br>
Description: Training an image classifier from scratch on the Kaggle Cats vs Dogs dataset.
... |
5,544 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Q2
In this question, we'll again look at classification, but with a more sophisticated algorithm. We'll also use the Iris dataset again.
Part A
In this question, you'll use a powerful classi... | Python Code:
import sklearn.svm as svm
import numpy as np
np.random.seed(13775)
X = np.random.random((20, 2))
y = np.random.randint(2, size = 20)
m1 = train_svm(X, y, 100.0)
assert m1.C == 100.0
np.testing.assert_allclose(m1.coef_, np.array([[ 0.392707, -0.563687]]), rtol=1e-6)
import numpy as np
np.random.seed(598497)... |
5,545 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<center> Monty-Hall</center>
Problema cunoscuta sub numele Monty Hall sau Let's make a deal este o problema de probabilitati a carei solutie
pare nefireasca. Ea este legata de emisiunile/spe... | Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('mhlc7peGlGg#t=15')
Explanation: <center> Monty-Hall</center>
Problema cunoscuta sub numele Monty Hall sau Let's make a deal este o problema de probabilitati a carei solutie
pare nefireasca. Ea este legata de emisiunile/spectacolele TV cu aceste nume.
F... |
5,546 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Text Vectorization
Step1: Let's remove stop words and include bigrams...
Step2: tf-idf weighting
tf - Term Frequency
idf - Inverse Document Frequency
The tf-idf weight of a term is the pro... | Python Code:
# Import python libs
import sqlite3 as sqlite # work with sqlite databases
import os # used to set working directory
import pandas as pd # process data with pandas dataframe
import numpy as np
# Setup pandas display options
pd.options.display.max_colwidth = 500
# Const... |
5,547 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1 style="font-size
Step1: <h2> Part 2
Step2: Getting the view as map of coordinates and values
Use Case
Step3: Getting the number of cells
Use Case
Step4: Getting data as CSV fomat
Use... | Python Code:
#import pandas to get data from csv file
import pandas as pd
# pd.read_csv will store the information into a pandas dataframe called df
df = pd.read_csv('reading_data.csv')
#A pandas dataframe has lots of cool pre-built functions such as:
# print the result
df.head()
#write data to csv
df.to_csv('my_new_fi... |
5,548 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
FEniCS overview
https
Step1: Set domain and mesh
Step2: List of other default meshes are available here
Also you can create your own mesh in the following manner
Step3: Set function space... | Python Code:
%matplotlib notebook
from __future__ import print_function
import fenics
import matplotlib.pyplot as plt
Explanation: FEniCS overview
https://fenicsproject.org/
Overview
FEniCS means Finite Elements + Computational Software and 'ni' just "sits nicely in the middle"
Finite elements solver for PDE
Easy-to-us... |
5,549 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Dependencies
Step1: Loading Data
First, we want to create our word vectors. For simplicity, we're going to be using a pretrained model.
As one of the biggest players in the ML game, Google... | Python Code:
# Tensorflow
import tensorflow as tf
print('Tested with TensorFlow 1.2.0')
print('Your TensorFlow version:', tf.__version__)
# Feeding function for enqueue data
from tensorflow.python.estimator.inputs.queues import feeding_functions as ff
# Rnn common functions
from tensorflow.contrib.learn.python.learn.e... |
5,550 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Logistic Regression with L2 regularization
The goal of this second notebook is to implement your own logistic regression classifier with L2 regularization. You will do the following
Step1: ... | Python Code:
from __future__ import division
import graphlab
Explanation: Logistic Regression with L2 regularization
The goal of this second notebook is to implement your own logistic regression classifier with L2 regularization. You will do the following:
Extract features from Amazon product reviews.
Convert an SFrame... |
5,551 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href='http
Step1: Creating a Series
You can convert a list,numpy array, or dictionary to a Series
Step2: Using Lists
Step3: Using NumPy Arrays
Step4: Using Dictionaries
Step5: Data i... | Python Code:
import numpy as np
import pandas as pd
Explanation: <a href='http://www.pieriandata.com'><img src='../Pierian_Data_Logo.png'/></a>
<center><em>Copyright Pierian Data</em></center>
<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>
Series... |
5,552 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
DATASCI W261
Step1: Part 1
Step2: (1b) Sparse vectors
Data points can typically be represented with a small number of non-zero OHE features relative to the total number of features that o... | Python Code:
labVersion = 'MIDS_MLS_week12_v_0_9'
Explanation: DATASCI W261: Machine Learning at Scale
W261-1 Fall 2015
Week 12: Criteo CTR Project
November 14, 2015
Student name INSERT STUDENT NAME HERE
Click-Through Rate Prediction Lab
This lab covers the steps for creating a click-through rate (CTR) prediction p... |
5,553 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Land
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify do... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'cnrm-esm2-1-hr', 'land')
Explanation: ES-DOC CMIP6 Model Properties - Land
MIP Era: CMIP6
Institute: CNRM-CERFACS
Source ID: CNRM-ESM2-1-HR
Topic: Land
Sub-Topics: Soi... |
5,554 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
E2E ML on GCP
Step1: Restart the kernel
Once you've installed the additional packages, you need to restart the notebook kernel so it can find the packages.
Step2: Set up your Google Cloud ... | Python Code:
import os
# The Vertex AI Workbench Notebook product has specific requirements
IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME")
IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(
"/opt/deeplearning/metadata/env_version"
)
# Vertex AI Notebook requires dependencies to be installed with '--user'
U... |
5,555 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: Creating a simple model based on Gender
Step2: Load training data
Step3: Take a look at the training data
Step4: Playing w/ the data
I have an array of 12 columns and 891 rows.
I c... | Python Code:
This simple code is desinged to teach a basic user to read in the files in python, simply find what proportion of males and females survived and make a predictive model based on this
Author : AstroDave
Date : 18 September 2012
Revised: 28 March 2014
import csv as csv
import numpy as np
Explanation: Creati... |
5,556 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href='http
Step1: The Data
Read the yelp.csv file and set it as a dataframe called yelp.
Step2: Check the head, info , and describe methods on yelp.
Step3: Create a new column called "... | Python Code:
import numpy as np
import pandas as pd
Explanation: <a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>
Natural Language Processing Project
Welcome to the NLP Project for this section of the course. In this NLP project you will be attempting to classify Yelp Reviews into 1 star... |
5,557 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
finance4py plotting example
In this example I'm going to evaluate different indicator and plot them one using pyplot subplots.
Step1: Problems
There are some problems here | Python Code:
# reading data from google finance
stock = DataReader('NFLX', 'google')
# extract bollinger bands
boll_bands = fp.bbands(stock.Close)
boll_bands.tail()
# extract average true range
atr = fp.average_true_range(stock.High, stock.Low, stock.Close)
atr.tail()
# extract RSI
rsi = fp.rsi(stock.Close).to_frame()... |
5,558 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Mission capabilities
Maximum acceleration and delta-v limit missions which can be conducted by space ship. Typical mission is composed of two parts
1. accelerated motion with active trust ... | Python Code:
from py import timeToDistance
timeToDistance.main()
Explanation: Mission capabilities
Maximum acceleration and delta-v limit missions which can be conducted by space ship. Typical mission is composed of two parts
1. accelerated motion with active trust - during this phase traveled distance grows quadrati... |
5,559 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Understanding sequential ensembles
The SequentialEnsemble object is one of the more powerful, but also more difficult, tools in the OpenPathSampling toolkit.
At first, it looks deceptively s... | Python Code:
xval = paths.FunctionCV(name="x", f=lambda snap : snap.coordinates[0][0])
state = paths.CVDefinedVolume(xval, lambda_min=float("-inf"), lambda_max=0.0)
# building example trajectories
delta = 0.1
x_out = 0.9; x_in = -1.1
traj1 = trajectory_1D([x_in, x_out, x_in])
x_in += delta; x_out += delta
traj2 = traje... |
5,560 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: 2016 US Bike Share Activity Snapshot
Table of Contents
Introduction
Posing Questions
Data Collection and Wrangling
Condensing the Trip Data
Exploratory Data Analysis
Statistics
Visual... | Python Code:
## import all necessary packages and functions.
import csv # read and write csv files
from datetime import datetime # operations to parse dates
from datetime import time
from datetime import date
import pprint # use to print data structures like dictionaries in
# a nicer way than... |
5,561 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
RF to B-Mode Generation
Ultrasound imaging employs acoustic pressure waves to gather information describing changes in tissue permeability. A transducer emits an ultrasound beam at discrete ... | Python Code:
# Install notebook dependencies
import sys
#!{sys.executable} -m pip install itk itk-ultrasound numpy matplotlib itkwidgets
import itk
from matplotlib import pyplot as plt
from itkwidgets import view, compare
Explanation: RF to B-Mode Generation
Ultrasound imaging employs acoustic pressure waves to gather ... |
5,562 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Writing Keras Models With TensorFlow NumPy
Author
Step1: Optionally, you can call tnp.experimental_enable_numpy_behavior() to enable type promotion in TensorFlow.
This allows TNP to more cl... | Python Code:
import tensorflow as tf
import tensorflow.experimental.numpy as tnp
import keras
import keras.layers as layers
import numpy as np
Explanation: Writing Keras Models With TensorFlow NumPy
Author: lukewood<br>
Date created: 2021/08/28<br>
Last modified: 2021/08/28<br>
Description: Overview of how to use the T... |
5,563 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Deep Inverse Regression with Yelp reviews
In this note we'll use gensim to turn the Word2Vec machinery into a document classifier, as in Document Classification by Inversion of Distributed L... | Python Code:
# ### uncomment below if you want...
# ## ... copious amounts of logging info
# import logging
# logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
# rootLogger = logging.getLogger()
# rootLogger.setLevel(logging.INFO)
# ## ... or auto-reload of gensim during develo... |
5,564 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Basic Pie Chart
Step1: Update Data
Step2: Display Values
Step3: Enable sort
Step4: Set different styles for selected slices
Step5: For more on piechart interactions, see the Mark Intera... | Python Code:
data = np.random.rand(3)
fig = plt.figure(animation_duration=1000)
pie = plt.pie(data, display_labels="outside", labels=list(string.ascii_uppercase))
fig
Explanation: Basic Pie Chart
End of explanation
n = np.random.randint(1, 10)
pie.sizes = np.random.rand(n)
Explanation: Update Data
End of explanation
wi... |
5,565 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Ocean
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify d... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-3', 'ocean')
Explanation: ES-DOC CMIP6 Model Properties - Ocean
MIP Era: CMIP6
Institute: IPSL
Source ID: SANDBOX-3
Topic: Ocean
Sub-Topics: Timestepping Framework, Ad... |
5,566 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<div align="right">Python 3.6 Jupyter Notebook</div>
Privacy by design
Step1: 1.2 Calculate uniqueness
In order to calculate uniqueness, as defined earlier, you need to define a function th... | Python Code:
import pandas
# Load the data set.
df = pandas.read_csv('privacy/belgium_100k.csv')
df = df.where((pandas.notnull(df)), None)
df['birthday'] = df['birthday'].astype('datetime64[ns]')
df.head()
Explanation: <div align="right">Python 3.6 Jupyter Notebook</div>
Privacy by design: Big data and personal data pr... |
5,567 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<div style="font-size
Step1: <h3>Generalized Hooke's Law</h3>
1) ε<sub>x</sub> = $\frac{1}{E}[$σ<sub>x</sub> - ν(σ<sub>y</sub> + σ<sub>z</sub>)$]$ <br/>
2) ε<s... | Python Code:
import sympy as sp
from sympy import init_printing
init_printing(use_unicode=True)
# Declare the symbols
EPx, EPy, EPz = sp.symbols("\u03B5x \u03B5y \u03B5z")
Qx, Qy, Qz = sp.symbols("\u03C3x \u03C3z \u03C3z")
E, v = sp.symbols("E \u03C5")
Explanation: <div style="font-size:24px;background-color:blue;color... |
5,568 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Map functions
These functions are probably the most commonly used functions when dealing with an RDD object.
map()
mapValues()
flatMap()
flatMapValues()
map
The map() method applies a functi... | Python Code:
# create an example RDD
map_exp_rdd = sc.textFile('../../data/mtcars.csv')
map_exp_rdd.take(4)
# split auto model from other feature values
map_exp_rdd_1 = map_exp_rdd.map(lambda x: x.split(',')).map(lambda x: (x[0], x[1:]))
map_exp_rdd_1.take(4)
# remove the header row
header = map_exp_rdd_1.first()
# the... |
5,569 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction
This notebook demonstrates basic usage of BioThings Explorer, an engine for autonomously querying a distributed knowledge graph. BioThings Explorer can answer two classes of que... | Python Code:
%%capture
!pip install git+https://github.com/biothings/biothings_explorer#egg=biothings_explorer
Explanation: Introduction
This notebook demonstrates basic usage of BioThings Explorer, an engine for autonomously querying a distributed knowledge graph. BioThings Explorer can answer two classes of queries -... |
5,570 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Examinging NetCDF files using xray
The simplest way that I have found for opening and exploring NetCDF files in python, depends on the python package called xray. Here is a little graphical ... | Python Code:
from IPython.display import Image
Image(url='http://xray.readthedocs.org/en/latest/_images/dataset-diagram.png', embed=True, width=950, height=300)
Explanation: Examinging NetCDF files using xray
The simplest way that I have found for opening and exploring NetCDF files in python, depends on the python pack... |
5,571 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Python datastructures notes
This contains operations on lists, dictionaries and tuples
Also covers
- Augumented assignment trick
- Map, filter and lambda
- Iterators
- Generators
List operat... | Python Code:
a = [1,2,3,4]
b = a
a[2] = 44 # b list also changes here
b
a is b # This shows a and b references are same
Explanation: Python datastructures notes
This contains operations on lists, dictionaries and tuples
Also covers
- Augumented assignment trick
- Map, filter and lambda
- Iterators
- Generators
List ope... |
5,572 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Homework 2 (solutions)
Problem 1
Construct a function, which will ask the user to input several numbers separated by commas
and will calculate their average. (e.g. if the user inputs 3,5,7 t... | Python Code:
inputted_numbers = input("Please, input some numbers seprated by a comma: ")
def simple_mean(inputted_numbers):
return float( sum(inputted_numbers) ) / float( len(inputted_numbers) )
print simple_mean(inputted_numbers)
Explanation: Homework 2 (solutions)
Problem 1
Construct a function, which will ask t... |
5,573 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
12-752
Step1: Short Introduction to Python and Jupyter
Jupyter notebooks consist of cells. This cell is a Markdown cell. Try double-clicking this cell. You can write pretty text and even La... | Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import sys
print('Python version:')
print(sys.version)
print('Numpy version:')
print(np.__version__)
import sklearn
print('Sklearn version:')
print(sklearn.__version__)
Explanation: 12-752: Data-Driven Building Energy Management
Fall 20... |
5,574 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: Übungsblatt 7
Präsenzaufgaben
Aufgabe 1 CFG
Step3: Aufgabe 2 CFG
Step5: Hausaufgaben
Aufgabe 7 Plural für das Subjekt
Ergänz... | Python Code:
grammar =
S -> NP VP
NP -> DET[GEN=?x] NOM[GEN=?x]
NOM[GEN=?x] -> ADJ NOM[GEN=?x] | N[GEN=?x]
ADJ -> "schöne" | "kluge" | "dicke"
DET[GEN=mask,KAS=nom] -> "der"
DET[GEN=fem,KAS=dat] -> "der"
DET[GEN=fem,KAS=nom] -> "die"
DET[GEN=fem,KAS=akk] -> "die"
DET[GEN=neut,KAS=nom] -> "das"
DET[GEN=neut,KAS=akk] ->... |
5,575 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Experiments
Step1: Let's create an experiment
Step2: Let's see the evolution of this vocabulary, after 20, 50 and 100 interactions.
Step3: We can graph measures on this population (more i... | Python Code:
import naminggamesal.ngsimu as ngsimu
Explanation: Experiments
End of explanation
xp_cfg={
'pop_cfg':{
'voc_cfg':{
'voc_type':'matrix',
'M':5,
'W':10
},
'strat_cfg':{
'strat_type':'success_threshold',
'voc_update':'... |
5,576 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Wiki Networking - Extended Example
Introduction
Network graphs consisting of nodes and edges and be used to visualize the relationships between people. The results can inform a viewer of gro... | Python Code:
import wikinetworking as wn
import networkx as nx
from pyquery import PyQuery
%matplotlib inline
print "OK"
Explanation: Wiki Networking - Extended Example
Introduction
Network graphs consisting of nodes and edges and be used to visualize the relationships between people. The results can inform a viewer of... |
5,577 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Variational Auto-Encoder notebook using tensorflow
(Edit) I fixed this notebook so that it can be run top to bottom to reproduce everything. Also to get the ipython notebook format, change "... | Python Code:
import sys
import os
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
%matplotlib inline
np.random.seed(0)
tf.set_random_seed(0)
# get the script bellow from
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/input_data.py
import input_data... |
5,578 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Creating MNE-Python data structures from scratch
This tutorial shows how to create MNE-Python's core data structures using an
existing
Step1: Creating ~mne.Info objects
.. sidebar
Step2: ... | Python Code:
import mne
import numpy as np
Explanation: Creating MNE-Python data structures from scratch
This tutorial shows how to create MNE-Python's core data structures using an
existing :class:NumPy array <numpy.ndarray> of (real or synthetic) data.
We begin by importing the necessary Python modules:
End of ... |
5,579 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Loading Data
Statistis for my data
Step1: Loading Data using Pandas
Step2: Hypothesis and Questions
..........
Things I need to do
Step5: Interpretation of Histograms
Based on the histog... | Python Code:
# Identitfy version of software used
pd.__version__
#Identify version of software used
np.__version__
# import libraries
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
#stats library
import statsmodels.api as sm
import scipy
#T-test is imported to complete the statistical analysis
f... |
5,580 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ApJdataFrames Rayner et al. 2009
Title
Step1: Table 7 - Strong metal lines in the Arcturus spectrum
Step2: This is a verbose way to do this, but whatever, it works
Step3: Finally
Step4: ... | Python Code:
import warnings
warnings.filterwarnings("ignore")
from astropy.io import ascii
import pandas as pd
Explanation: ApJdataFrames Rayner et al. 2009
Title: THE INFRARED TELESCOPE FACILITY (IRTF) SPECTRAL LIBRARY: COOL STARS
Authors: John T. Rayner, Michael C. Cushing, and William D. Vacca
Data is from this pap... |
5,581 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sebastian Raschka, 2015
Python Machine Learning Essentials
Chapter 10 - Predicting Continuous Target Variables with Regression Analysis
Note that the optional watermark extension is a small ... | Python Code:
%load_ext watermark
%watermark -a 'Sebastian Raschka' -u -d -v -p numpy,pandas,matplotlib,scikit-learn,seaborn
# to install watermark just uncomment the following line:
#%install_ext https://raw.githubusercontent.com/rasbt/watermark/master/watermark.py
Explanation: Sebastian Raschka, 2015
Python Machine Le... |
5,582 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
11. Machine Translation — Lab exercises
Preparations
Introduction
In this lab, we will be using Python Natural Language Toolkit (nltk) again to get to know the IBM models better. There are p... | Python Code:
import os
import shutil
import urllib
import nltk
def download_file(url, directory=''):
real_dir = os.path.realpath(directory)
if not os.path.isdir(real_dir):
os.makedirs(real_dir)
file_name = url.rsplit('/', 1)[-1]
real_file = os.path.join(real_dir, file_name)
if not os.pa... |
5,583 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Load-signals" data-toc-modified-id="Load-signals-1"><span class="toc-item-nu... | Python Code:
# Add MOSQITO to the Python path
import sys
sys.path.append('..')
# Import numpy
import numpy as np
# Import plot function
import matplotlib.pyplot as plt
# Import multiple spectrum computation tool
from scipy.signal import stft
# Import mosqito functions
from mosqito.utils import load
from mosqito.sound_l... |
5,584 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Chapter 1
An introduction to the Jupyter Notebook and some practice with probability ideas from Chapter 1.
1.1 Probability
1.1.1 Moments of Measured Data
The Jupyter Notebook has two primary... | Python Code:
import matplotlib.pyplot as plt
from numpy import array, sin, sqrt, dot, outer
%matplotlib inline
Explanation: Chapter 1
An introduction to the Jupyter Notebook and some practice with probability ideas from Chapter 1.
1.1 Probability
1.1.1 Moments of Measured Data
The Jupyter Notebook has two primary types... |
5,585 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Real World Considerations for the Lomb-Scargle Periodogram
Version 0.2
By AA Miller (Northwestern/CIERA)
23 Sep 2021
In Lecture III we built the software necessary to estimate the power spec... | Python Code:
np.random.seed(185)
# calculate the periodogram
x = 10*np.random.rand(100)
y = gen_periodic_data(x, period=5.25, amplitude=7.4, noise=0.8)
y_unc = np.ones_like(x)*np.sqrt(0.8)
Explanation: Real World Considerations for the Lomb-Scargle Periodogram
Version 0.2
By AA Miller (Northwestern/CIERA)
23 Sep 2021
I... |
5,586 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Day 4
Step1: Day 4
Step2: Day 4
Step3: Normal Distribution with mean=0 and std. dev=1
x ~ N(0, 1)
Normal Distribution with mean=205 and std. dev=15
x ~ N(205, 15)
Normal Distribution with... | Python Code:
# #Distribution
scipy.stats.norm(30, 4)
scipy.stats.norm(30, 4).cdf(40)
1 - scipy.stats.norm(30, 4).cdf(21)
scipy.stats.norm(30, 4).cdf(35) - scipy.stats.norm(30, 4).cdf(30)
Explanation: Day 4: Normal Distribution #1
Objective
In this challenge, we practice solving problems with normally distributed variab... |
5,587 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Preparing German Wikipedia to train a fast.ai (ULMFiT) model for German
(should work with most other languages, too)
Thomas Viehmann tv@lernapp... | Python Code:
%matplotlib inline
%reload_ext autoreload
%autoreload 2
from fastai.text import *
import html
from matplotlib import pyplot
import numpy
import time
BOS = 'xbos' # beginning-of-sentence tag
FLD = 'xfld' # data field tag
LANG='de'
datasetpath = Path('/home/datasets/nlp/wiki/')
# I ran this: wikiextractor... |
5,588 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<center><u><u>Bayesian Modeling for the Busy and the Confused - Part I</u></u></center>
<center><i>Basic Principles of Bayesian Computation and the Grid Approximation</i><center>
Currently, ... | Python Code:
import pickle
import warnings
import sys
import pandas as pd
import numpy as np
from scipy.stats import norm as gaussian, uniform
import seaborn as sb
import matplotlib.pyplot as pl
from matplotlib import rcParams
from matplotlib import ticker as mtick
print('Versions:')
print('---------')
print(f'python: ... |
5,589 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
The netCDF file format
popular scientific file format for ocean and atmospere gridded datasets
netCDF is a collection of formats for storing arrays
netCDF classic
more widespread
2 GB file l... | Python Code:
# Import everything that we are going to need... but not more
import pandas as pd
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap, cm
%matplotlib inline
DF=pd.DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6])],
... |
5,590 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Lesson 41
Step1: The webdriver.Chrome() command launches an interactive browser using selenium. All commands referencing this new browser variable will use this specific browser window. The... | Python Code:
from selenium import webdriver
Explanation: Lesson 41:
Controlling the Browser with the Selenium Module
We download and parse webpages using beautifulsoup module, but some pages require logins and other dependencies to function properly.
We can simulate these effects using selenium to launch a programmati... |
5,591 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Continuous training with TFX and Google Cloud AI Platform
Learning Objectives
Use the TFX CLI to build a TFX pipeline.
Deploy a new TFX pipeline version with tuning enabled to a hosted AI Pl... | Python Code:
import yaml
# Set `PATH` to include the directory containing TFX CLI and skaffold.
PATH=%env PATH
%env PATH=/home/jupyter/.local/bin:{PATH}
Explanation: Continuous training with TFX and Google Cloud AI Platform
Learning Objectives
Use the TFX CLI to build a TFX pipeline.
Deploy a new TFX pipeline version w... |
5,592 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
2 samples permutation test on source data with spatio-temporal clustering
Tests if the source space data are significantly different between
2 groups of subjects (simulated here using one su... | Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Eric Larson <larson.eric.d@gmail.com>
# License: BSD (3-clause)
import os.path as op
import numpy as np
from scipy import stats as stats
import mne
from mne import spatial_src_connectivity
from mne.stats import spatio_temporal_cluster_t... |
5,593 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
机器学习纳米学位
非监督学习
项目 3
Step1: 分析数据
在这部分,你将开始分析数据,通过可视化和代码来理解每一个特征和其他特征的联系。你会看到关于数据集的统计描述,考虑每一个属性的相关性,然后从数据集中选择若干个样本数据点,你将在整个项目中一直跟踪研究这几个数据点。
运行下面的代码单元给出数据集的一个统计描述。注意这个数据集包含了6个重要的产品类型:'Fresh', ... | Python Code:
%%time
# 引入这个项目需要的库
import numpy as np
import pandas as pd
import visuals as vs
from IPython.display import display # 使得我们可以对DataFrame使用display()函数
# 设置以内联的形式显示matplotlib绘制的图片(在notebook中显示更美观)
%matplotlib inline
# 载入整个客户数据集
try:
data = pd.read_csv("customers.csv")
data.drop(['Region', 'Channel'], a... |
5,594 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
P3 - Data Wrangling with MongoDB
OpenStreetMap Project Data Wrangling with MongoDB
Gangadhara Naga Sai<a name="top"></a>
Data used -<a href=https
Step1: <hr>
Over-abbreviated Names<a name=... | Python Code:
def isEnglish(string):
try:
string.encode('ascii')
except UnicodeEncodeError:
return False
else:
return True
Explanation: P3 - Data Wrangling with MongoDB
OpenStreetMap Project Data Wrangling with MongoDB
Gangadhara Naga Sai<a name="top"></a>
Data used -<a href=https://m... |
5,595 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Front page heatmap
If we view the front page of each newspaper as an MxN matrix, we can assign each pixel an intensity P based off the font size of the character at that location. Averaging ... | Python Code:
import pandas as pd
df = pd.read_sql_table('frontpage_texts', 'postgres:///frontpages')
df.head()
Explanation: Front page heatmap
If we view the front page of each newspaper as an MxN matrix, we can assign each pixel an intensity P based off the font size of the character at that location. Averaging the in... |
5,596 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Researching a Pairs Trading Strategy
By Delaney Granizo-Mackenzie
Part of the Quantopian Lecture Series
Step1: Explaining the Concept
Step2: Now we generate Y. Remember that Y is supposed ... | Python Code:
import numpy as np
import pandas as pd
import statsmodels
from statsmodels.tsa.stattools import coint
# just set the seed for the random number generator
np.random.seed(107)
import matplotlib.pyplot as plt
Explanation: Researching a Pairs Trading Strategy
By Delaney Granizo-Mackenzie
Part of the Quantopian... |
5,597 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Classifying Structured Data using Keras Preprocessing Layers
Learning Objectives
Load a CSV file using Pandas.
Build an input pipeline to batch and shuffle the rows using tf.data.
Map from c... | Python Code:
!pip install -q sklearn
Explanation: Classifying Structured Data using Keras Preprocessing Layers
Learning Objectives
Load a CSV file using Pandas.
Build an input pipeline to batch and shuffle the rows using tf.data.
Map from columns in the CSV to features used to train the model using Keras Preprocessing ... |
5,598 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Outline
Glossary
1. Radio Science using Interferometric Arrays
Previous
Step1: Import section specific modules
Step2: 1.6.1 Synchrotron Emission
Step3: The frequency of gyration in the no... | Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
Explanation: Outline
Glossary
1. Radio Science using Interferometric Arrays
Previous: 1.5 Black body radiation
Next: 1.7 Line emission
Import standard modul... |
5,599 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
while loops
The while statement in Python is one of most general ways to perform iteration. A while statement will repeatedly execute a single statement or group of statements as long as the... | Python Code:
x = 0
while x < 10:
print 'x is currently: ',x
print ' x is still less than 10, adding 1 to x'
x+=1
Explanation: while loops
The while statement in Python is one of most general ways to perform iteration. A while statement will repeatedly execute a single statement or group of statements as lon... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.