Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
12,800 | <ASSISTANT_TASK:>
Python Code:
from bokeh.palettes import YlOrRd as palette #Spectral6 as palette
from bokeh.plotting import figure, save
from bokeh.models import ColumnDataSource, HoverTool, LogColorMapper
from bokeh.palettes import RdYlGn10 as palette
import geopandas as gpd
import pysal as ps
import numpy as np
# ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step7: Next, let's create a set of functions that are used for getting the x and y coordinates of the geometries. Shapefiles etc. can often have Multi-... |
12,801 | <ASSISTANT_TASK:>
Python Code:
# Import pandas and numpy
import pandas as pd
import numpy as np
# Import the classifiers we will be using
from sklearn.naive_bayes import GaussianNB
from sklearn.neighbors import KNeighborsClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomFores... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read the data
Step2: Train/test split
Step3: Modelling with standard train/test split
Step4: Modelling with k-fold cross validation
|
12,802 | <ASSISTANT_TASK:>
Python Code:
# 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... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hourglass
Step2: Download ImageNet32/64 data
Step3: Load the ImageNet32 model
Step4: Evaluate on the validation set
Step5: ImageNet32 evalua... |
12,803 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
#Typical imports
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
import pandas as pd
# plots on fleek
matplotlib.style.use('ggplot')
# Read the housing data from the txt file into a pandas dataframe
# delim_whitespace tells ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If you look at the raw data, you can see that the columns are separated by tabs, not commas. This changes the way we need to read the data in.
S... |
12,804 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
import cartopy.crs as ccrs
from sklearn.cluster import KMeans
z500 = xr.open_dataset('data\z500.DJF.anom.1979.2010.nc', decode_times=False)
print(z500)
da = z500.sel(P=500).phi.load()
print(da.name,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Load data
Step2: 3. Perform KMeans clustering to idenfity weather regimes
Step3: Get the fraction of a given cluster denoted by label.
Step... |
12,805 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
df = pd.DataFrame({'AAA' : [4,5,6,7],
'BBB' : [10,20,30,40],
'CCC' : [100,50,-30,-50]})
df
# If AAA >= 5, BBB = -1
df.loc[df.AAA >= 5, 'BBB'] = -1; df
df.loc[df.AAA >= 5, ['BBB','CCC']] = 555; df
df.loc[df.AAA ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Idioms
Step2: Execute an if-then statement on one column
Step3: If-then with assignment to 2 columns
Step4: Now you can perform another opera... |
12,806 | <ASSISTANT_TASK:>
Python Code:
!pip install -q numpyro@git+https://github.com/pyro-ppl/numpyro funsor
import numpyro
from jax import numpy as jnp, random, ops
from jax.scipy.special import expit
from numpyro import distributions as dist, sample
from numpyro.infer.mcmc import MCMC
from numpyro.infer.hmc import NUTS
from... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we will simulate data with correlated binary covariates. The assumption is that we wish to estimate parameter for some parametric model wi... |
12,807 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Math
from math import frexp, pi
import math
#Convert a float into its mantissa and exponent and print as LaTeX
def fprint(x):
m,e = frexp(x)
return Math('{:4} \\times 2^{{{:}}}'.format(m, int(e)))
#Convert a mantissa from decimal to binary and prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A 'decimal' in binary is challenging to think about, because each integer location is a $1 / 2^{n}$, where $n$ is the location. That means to re... |
12,808 | <ASSISTANT_TASK:>
Python Code:
#Importamos las librerías utilizadas
import numpy as np
import pandas as pd
import seaborn as sns
#Mostramos las versiones usadas de cada librerías
print ("Numpy v{}".format(np.__version__))
print ("Pandas v{}".format(pd.__version__))
print ("Seaborn v{}".format(sns.__version__))
#Abrimos... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Representamos ambos diámetro y la velocidad de la tractora en la misma gráfica
Step2: Comparativa de Diametro X frente a Diametro Y para ver el... |
12,809 | <ASSISTANT_TASK:>
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 writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Qudits
Step3: Most of the time in quantum computation, we work with qubits, which are 2-level quantum systems. However, it is possible to also ... |
12,810 | <ASSISTANT_TASK:>
Python Code:
from GongSu22_Statistics_Population_Variance import *
prices_pd.head()
ny_pd = prices_pd[prices_pd['State'] == 'New York'].copy(True)
ny_pd.head(10)
ny_pd_HighQ = ny_pd.iloc[:, [1, 7]]
ny_pd_HighQ.columns = ['NY_HighQ', 'date']
ny_pd_HighQ.head()
ca_pd_HighQ = california_pd.iloc[:, [... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 주의
Step2: 상관분석 설명
Step3: 이제 정수 인덱싱을 사용하여 상품(HighQ)에 대한 정보만을 가져오도록 하자.
Step4: 위 코드에 사용된 정수 인덱싱은 다음과 같다.
Step5: 준비 작업
Step6: 준비 작업
Step7: 캘리... |
12,811 | <ASSISTANT_TASK:>
Python Code:
# For using the same code in either Python 2 or 3
from __future__ import print_function
## Note: Python 2 users, use raw_input() to get player input. Python 3 users, use input()
from IPython.display import clear_output
def display_board(board):
clear_output()
print(' | ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: Step 2
Step3: Step 3
Step4: Step 4
Step5: Step 5
Step6: Step 6
Step7: Step 7
Step8: Step 8
Step9: Step 9
Step10: Step 10
|
12,812 | <ASSISTANT_TASK:>
Python Code:
Assignment between variables creates aliases.
animal = "giraffe"
creature = animal
print("Is creature an alias of animal?", creature is animal)
Assignment of the same value to different variables does not necessarily create aliases.
weather_next_5_days = ["Sunny", "Partly sunny", "C... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Glossary
Step4: clone
Step6: <h4 style="color
Step10: delimiter
Step12: element
Step14: index
Step17: list
Step19: List comprehensions
St... |
12,813 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import tensorflow as tf
import tflearn
from tflearn.data_utils import to_categorical
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
reviews = pd.read_csv('reviews.txt', header=None)
labels = pd.read_csv('labels.txt', header=None... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Preparing the data
Step2: Counting word frequency
Step3: Let's keep the first 10000 most frequent words. As Andrew noted, most of the words in... |
12,814 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from math import log
from sklearn import linear_model
#comment below if not using ipython notebook
%matplotlib inline
#read csv
anscombe_i = pd.read_csv('../datasets/anscombe_i.csv')
anscombe_i
plt.scatter(anscombe_i.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now lets read the first set of data, take a look at the dataset and make a simple scatter plot.
Step2: Luckly for us, we do not need to impleme... |
12,815 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
%matplotlib inline
import sys
from pathlib import Path
p = Path(".")
p = p.absolute().parent
sys.path.insert(0,str(p))
import codes
def draw_2d(dataset,k):
#colors = cm.rainbow(np.linspace(0, 1, k))
Color = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w']
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 使用sklearn实现k-means聚类
Step2: 查看模型训练结束后各个向量的标签
Step3: 模型训练结束后用于预测向量的标签
Step4: 模型训练结束后的各个簇的中心点
|
12,816 | <ASSISTANT_TASK:>
Python Code:
%load_ext sql
%sql mysql://studentuser:studentpw@172.17.0.4/dognitiondb
import socket
socket.gethostbyname('mysqlserver')
#mysqlserver
%config SqlMagic
%sql USE dognitiondb
%sql SHOW tables
%sql SHOW columns FROM dogs
%sql DESCRIBE reviews
%sql DESCRIBE complete_tests
%sql DESCRIBE ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The "%" in this line of code is syntax for Python, not SQL. The "cell" I am referring to is the empty box area beside the "In [ ]
Step2: <mar... |
12,817 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY AN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
12,818 | <ASSISTANT_TASK:>
Python Code:
# Initialize parameter values
y0 = 0
rho = 0.5
w1 = 1
# Compute the period 1 value of y
y1 = rho*y0 + w1
# Print the result
print('y1 =',y1)
# Compute the period 2 value of y
w2=0
y2 = rho*y1 + w2
# Print the result
print('y2 =',y2)
# Compute
# Initialize the variables T and w
T = 10
w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The variable y1 in the preceding example stores the computed value for $y_1$. We can continue to iterate on Equation (4) to compute $y_2$, $y_3$... |
12,819 | <ASSISTANT_TASK:>
Python Code:
# Set up feedback system
from learntools.core import binder
binder.bind(globals())
from learntools.sql.ex5 import *
print("Setup Complete")
from google.cloud import bigquery
# Create a "Client" object
client = bigquery.Client()
# Construct a reference to the "chicago_taxi_trips" dataset
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You'll work with a dataset about taxi trips in the city of Chicago. Run the cell below to fetch the chicago_taxi_trips dataset.
Step2: Exercise... |
12,820 | <ASSISTANT_TASK:>
Python Code:
sample = np.random.choice([1,2,3,4,5,6], 100)
# посчитаем число выпадений каждой из сторон:
from collections import Counter
c = Counter(sample)
print("Число выпадений каждой из сторон:")
print(c)
# теперь поделим на общее число подбрасываний и получим вероятности:
print("Вероятности ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Представим теперь, что эта выборка была получена не искусственно, а путём подбрасывания симметричного шестигранного кубика 100 раз. Оценим вероя... |
12,821 | <ASSISTANT_TASK:>
Python Code:
x = -5
if x < 0:
x = 0
print 'Negative changed to zero'
elif x == 0:
print 'Zero'
elif x == 1:
print 'Single'
else:
print 'More'
print x
x = -5
if x < 0:
print "X is negative"
x = 5
if x == 0: print 'X is zero'
for pet in ['cat', 'dog', 'pig']:
print 'I ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: the body of the if is indented
Step2: for statements
Step3: if you need to iterate over a sequence of numbers, using built-in function <code>r... |
12,822 | <ASSISTANT_TASK:>
Python Code:
import essentia.standard as es
filename = 'audio/dubstep.flac'
# Load the whole file in mono
audio = es.MonoLoader(filename=filename)()
print(audio.shape)
# Load the whole file in stereo
audio, _, _, _, _, _ = es.AudioLoader(filename=filename)()
print(audio.shape)
# Load and resample to 1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading file metadata
Step2: The output contains standard metadata fields (track name, artist, name, album name, track number, etc.) as well as... |
12,823 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils
# Fix random seed for reproducibility
seed = 7
np.random.seed(seed)
# Load data
(X_train, y_train), (X_test, y_test) = mnist.load_data()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: num_pixels is equal to 748
Step2: one-hot-encoding is used because in the network, there is one neuron for one number...
Step3: 'softmax' is a... |
12,824 | <ASSISTANT_TASK:>
Python Code:
pow(7, 4)
s = "Hi there Sam!"
s.split(' ')
planet = "Earth"
diameter = 12742
"The diameter of {0} is {1} kilometers.".format(planet, diameter)
lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7]
lst[3][1][2][0]
d = {'k1':[1,2,3,{'tricky':['oh','man','inception',{'target':[1,2,3,'hello... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 分割以下字符串
Step2: 提供了一下两个变量
Step3: 提供了以下嵌套列表,使用索引的方法获取单词‘hello'
Step4: 提供以下嵌套字典,从中抓去单词 “hello”
Step5: 字典和列表之间的差别是什么??
Step6: 编写一个函数,该函数能够获取类... |
12,825 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nerc', 'hadgem3-gc31-hh', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("nam... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
12,826 | <ASSISTANT_TASK:>
Python Code:
%run -i initilization.py
from classification.ExecuteClassificationWorkflow import ExecuteWorkflowClassification
import classification.CreateParametersClasification as create_params
from shared import GeneralDataImport
from IPython.display import display
data_import = GeneralDataImport.Ge... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import data and select columns for id and features
Step2: Lets divide the data into a training- and test-set.
Step3: Select an algorithm and i... |
12,827 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
#Importamos las librerías utilizadas
import numpy as np
import pandas as pd
import seaborn as sns
#Mostramos las versiones usadas de cada librerías
print ("Numpy v{}".format(np.__version__))
print ("Pandas v{}".format(pd.__version__))
print ("Seaborn v{}".format(sns.__versio... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Representamos ambos diámetro y la velocidad de la tractora en la misma gráfica
Step2: Con esta segunda aproximación se ha conseguido estabiliza... |
12,828 | <ASSISTANT_TASK:>
Python Code:
import graphlab
tmp = graphlab.SArray([1., 2., 3.])
tmp_cubed = tmp.apply(lambda x: x**3)
print tmp
print tmp_cubed
ex_sframe = graphlab.SFrame()
ex_sframe['power_1'] = tmp
print ex_sframe
def polynomial_sframe(feature, degree):
# assume that degree >= 1
# initialize the SFrame... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next we're going to write a polynomial function that takes an SArray and a maximal degree and returns an SFrame with columns containing the SArr... |
12,829 | <ASSISTANT_TASK:>
Python Code:
df = hc.sample.df_timeseries(N=2, Nb_bd=15+0*3700) #<=473
df.info()
display(df.head())
display(df.tail())
g = hc.Highstock()
g.chart.width = 650
g.chart.height = 550
g.legend.enabled = True
g.legend.layout = 'horizontal'
g.legend.align = 'center'
g.legend.maxHeight = 100
g.tooltip.enabled... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Example 2
Step2: Example 3
Step4: Example 4
Step5: Column, Bar
Step6: Pie
Step7: Pie, Column Drilldown
Step8: Pie Drilldown - 3 levels
Ste... |
12,830 | <ASSISTANT_TASK:>
Python Code:
def is_sorted(lst):
'''
Given a list of numbers, return whether or not they are sorted
in ascending order. If list has more than 1 duplicate of the same
number, return False. Assume no negative numbers and only integers.
Examples
is_sorted([5]) ➞ True
is_sorted... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
12,831 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import os as os
import preprocessing_helper as preprocessing_helper
import matplotlib as plt
% matplotlib inline
filename = "train_users_2.csv"
folder = 'data'
fileAdress = os.path.join(folder, filename)
df = pd.read_csv(fileAdress)
df.head()
df.isnull().any()
df = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Data exploration and cleaning
Step2: There are missing values in the columns
Step3: Ages
Step4: The following graph presents the distribu... |
12,832 | <ASSISTANT_TASK:>
Python Code:
# Run some setup code for this notebook.
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
from __future__ import print_function
# This is a bit of magic to make matplotlib figures appear inline in the notebook
# rather than in a n... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We would now like to classify the test data with the kNN classifier. Recall that we can break down this process into two steps
Step2: Inline Qu... |
12,833 | <ASSISTANT_TASK:>
Python Code:
import csv
from scipy.stats import kurtosis
from scipy.stats import skew
from scipy.spatial import Delaunay
import numpy as np
import math
import skimage
import matplotlib.pyplot as plt
import seaborn as sns
from skimage import future
import networkx as nx
%matplotlib inline
# Read in the... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We'll start with just looking at analysis in euclidian space, then thinking about weighing by synaptic density later. Since we hypothesize that ... |
12,834 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
from scipy.optimize import fmin
from scipy.linalg import cholesky, cho_solve, inv
#np.set_printoptions(formatter={'float': '{: 0.4f}'.format})
%matplotlib inline
%load_ext autoreload
%autoreload 2
def get_ker... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We will define kernel function here
Step2: Predictive gaussian parameter finding (with gaussian cumulative likelihood)
|
12,835 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from scipy.linalg import hadamard
from scipy.fftpack import dct
%matplotlib inline
n = 10 #dimension of data (rows in plot)
K = 3 #number of centroids
m = 4 #subsampling dimension
p = 6 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Data Matrices
Step4: Color Functions
Step11: Plotting Functions
Step12: Generate the Plots
|
12,836 | <ASSISTANT_TASK:>
Python Code:
depth = -0.7
width = 5.0
gaussian_A_depth = depth
gaussian_A_alpha = np.array([width, width])
gaussian_A_center = np.array([-0.5, -0.5])
gaussian_B_depth = depth
gaussian_B_alpha = np.array([width, width])
gaussian_B_center = np.array([0.5, 0.5])
pes = (
toys.OuterWalls([1.0, 1.0]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Furthermore we need a method to define states $A$ and $B$, we use circles around the respective gaussian well centers
Step2: Given the symmetry... |
12,837 | <ASSISTANT_TASK:>
Python Code:
# Useful Functions
def check_for_stationarity(X, cutoff=0.01):
# H_0 in adfuller is unit root exists (non-stationary)
# We must observe significant p-value to convince ourselves that the series is stationary
pvalue = adfuller(X)[1]
if pvalue < cutoff:
print 'p-valu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise 1
Step2: b. Checking for Normality
Step3: c. Constructing Examples I
Step4: d. Constructing Examples II
Step5: Exercise 2
Step6: E... |
12,838 | <ASSISTANT_TASK:>
Python Code:
import pandas as pnd
import matplotlib.pylab as plt
import matplotlib.patches as mpatches
from IPython.display import HTML
%matplotlib inline
img = plt.imread("rueildigital.jpg")
plt.axis('off')
plt.imshow(img);
HTML("<iframe src='http://datea.pe/NanterreDigital/nanterredigital?tab=map' ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Lecture des données relatives aux acteurs du numérique (www.datea.pe)
Step2: Lecture des données relatives aux équipements de Nanterre (www.nan... |
12,839 | <ASSISTANT_TASK:>
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 writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Migrate from Estimator to Keras APIs
Step2: TensorFlow 1
Step3: Instantiate your Estimator, and train the model
Step4: Evaluate the program w... |
12,840 | <ASSISTANT_TASK:>
Python Code:
import graphlab
products = graphlab.SFrame('amazon_baby.gl/')
products.head()
products['word_count'] = graphlab.text_analytics.count_words(products['review'])
products.head()
graphlab.canvas.set_target('ipynb')
products['name'].show()
giraffe_reviews = products[products['name'] == 'Vu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read some product review data
Step2: Let's explore this data together
Step3: Build the word count vector for each review
Step4: Examining the... |
12,841 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from __future__ import print_function
from orphics import io, maps, stats, cosmology
from enlib import enmap, resample
import numpy as np
shape, wcs = maps.rect_geometry(width_deg = 5.0, px_res_arcmin = 0.5)
cc = cosmology.Cosmology(lmax=2000,pickling=T... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We want to first define a geometry for our map, by obtaining a numpy array shape and a WCS from a physical geometry. We then create a Cosmology ... |
12,842 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from jupyterthemes import jtplot ; jtplot.style()
np.random.seed(1969-7-20)
N = 51
b = np.linspace(0.5, 1.5, N) + (np.random.random(N)-0.5)/100
z = 0.035
D = 1/np.sqrt((1-b*b)**2+(2*z*b)**2) * (1 + (np.random.random(N)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We simulate a dynamic testing, using a low sampled, random error affected sequence of frequencies to compute a random error affected sequence of... |
12,843 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import os
path = ""
data = pd.read_csv("https://github.com/JamesByers/GA-SEA-DAT2/raw/master/data/ozone.csv")
print data.head()
data.columns
print data.head(2)
print data.count()
print data.tail(2)
print data.loc[47:47,['Ozone']]
pd.isnull(data... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Print the column names of the dataset to the screen, one column name per line.
Step2: Extract the first 2 rows of the data frame and print them... |
12,844 | <ASSISTANT_TASK:>
Python Code:
from numpy import random, array
#Create fake income/age clusters for N people in k clusters
def createClusteredData(N, k):
random.seed(10)
pointsPerCluster = float(N)/k
X = []
for i in range (k):
incomeCentroid = random.uniform(20000.0, 200000.0)
ageCentroi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We'll use k-means to rediscover these clusters in unsupervised learning
|
12,845 | <ASSISTANT_TASK:>
Python Code:
import fst
# Let's see the input as a simple linear chain FSA
def make_input(srcstr, sigma = None):
converts a nonempty string into a linear chain acceptor
@param srcstr is a nonempty string
@param sigma is the source vocabulary
assert(srcstr.split())
return... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step4: Helper code
Step5: All permutations
Step6: Window of length d
Step7: Examples
Step8: Input
Step9: All permutations
Step10: For a toy examp... |
12,846 | <ASSISTANT_TASK:>
Python Code:
import paver
import trigrid
import matplotlib.pyplot as plt
import numpy as np
import field
%matplotlib notebook
# Load and display a 25k cell grid of San Francisco Bay
p=paver.Paving(suntans_path='/home/rusty/models/suntans/spinupdated/rundata/original_grid')
fig,ax=plt.subplots()
p.tg_p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Remove the nodes/edges where the refinement is needed. In this example,
Step2: Remove edges which are significantly longer than the target res... |
12,847 | <ASSISTANT_TASK:>
Python Code:
from transformers import AutoTokenizer
checkpoint = "distilbert-base-uncased-finetuned-sst-2-english"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
raw_inputs = [
"I've been waiting for a HuggingFace course my whole life.",
"I hate this so much!",
]
inputs = tokenizer(raw... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The output itself is a dictionary containing two keys, input_ids and attention_mask. input_ids contains two rows of integers (one for each sente... |
12,848 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import os
import sys
import pandas as pd
import numpy as np
%matplotlib inline
from matplotlib import pyplot as plt
import seaborn as sns
import datetime
#set current working directory
os.chdir('D:/Practical Time Series')
#Read the dataset into a pand... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To make sure that the rows are in the right order of date and time of observations,
Step2: Gradient descent algorithms perform better (for exam... |
12,849 | <ASSISTANT_TASK:>
Python Code:
# Import all necessary libraries, this is a configuration step for the exercise.
# Please run it before the simulation code!
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# Show the plots in the Notebook.
plt.switch_backend("nbagg")
# Initial... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Initialization of setup
Step2: 2. Initial condition
Step3: 3. Solution for the homogeneous problem
Step4: 4. Finite Volumes solution
|
12,850 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.interpolate import interp1d
with np.load('trajectory.npz') as data:
x = data['x']
y = data['y']
t = data['t']
assert isinstance(x, np.ndarray) and len(x)==40
assert isinstan... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2D trajectory interpolation
Step2: Use these arrays to create interpolated functions $x(t)$ and $y(t)$. Then use those functions to create the ... |
12,851 | <ASSISTANT_TASK:>
Python Code:
cd /notebooks/exercise-08/
import yaml
txt =
{ "yaml": 'is', 'a superset': 'of json'}
ret = yaml.load(txt)
print(ret)
# Yoda loves dictionaries ;)
print(yaml.dump(ret))
# Customized dumper
print(yaml.dump(ret, default_flow_style=False))
txt =
# Yaml comments starts with hash
you: {'can... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: What's yaml?
Step11: Quoting
Step13: Long texts
Step15: Or write a multi_line string with proper carets
Step16: Exercise
|
12,852 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def test_mul():
arr = np.array([0.0, 1.0, 1.1])
v, expected = 1.1, np.array([0.0, 1.1, 1.21])
assert arr * v == expected, 'bad multiplication'
test_mul()
np.array([1,2,3]) == np.array([1, 1, 3])
bool(np.array([1, 2, 3]))
np.all([True, True, True])
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The Naive Approach
Step2: This is due to the fact that when we compare two numpy arrays with == we'll get an array of boolean values comparing ... |
12,853 | <ASSISTANT_TASK:>
Python Code:
%%bigquery df1
SELECT
team_code,
AVG(SAFE_DIVIDE(fgm + 0.5 * fgm3,fga)) AS offensive_shooting_efficiency,
AVG(SAFE_DIVIDE(opp_fgm + 0.5 * opp_fgm3,opp_fga)) AS opponents_shooting_efficiency,
AVG(win) AS win_rate,
COUNT(win) AS num_games
FROM lab_dev.team_box
WHERE fga IS NOT NU... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's remove the entries corresponding to teams that played fewer than 100 games, and then plot it.
Step2: Does the relationship make sense? Do... |
12,854 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from collections import Counter
data = np.fromfile('/home/daniel/debian_testing_chroot/tmp/shockburst.u8', dtype = 'uint8').reshape((-1,34))
crc_table = [
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The data shockburst.u8 contains ShockBurst frames without the 0xE7E7E7E7E7 address header (including frame counter, image payload and CRC). It h... |
12,855 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-1', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("n... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
12,856 | <ASSISTANT_TASK:>
Python Code:
from google.cloud import aiplatform
REGION = "us-central1"
PROJECT_ID = !(gcloud config get-value project)
PROJECT_ID = PROJECT_ID[0]
# Set `PATH` to include the directory containing KFP CLI
PATH = %env PATH
%env PATH=/home/jupyter/.local/bin:{PATH}
!cat trainer_image_vertex/Dockerfile
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Understanding the pipeline design
Step2: Let's now build and push this trainer container to the container registry
Step3: To match the ml fram... |
12,857 | <ASSISTANT_TASK:>
Python Code:
# Ensure compatibility with Python 2 and 3
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from climlab import constants as const
from climlab.solar.insolation import daily_insolation
help(daily_insolation)
daily_in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Contents
Step2: First, get a little help on using the daily_insolation function
Step3: Here are a few simple examples.
Step4: Same location, ... |
12,858 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
d = {'l': ['left', 'right', 'left', 'right', 'left', 'right'],
'r': ['right', 'left', 'right', 'left', 'right', 'left'],
'v': [-1, 1, -1, 1, -1, np.nan]}
df = pd.DataFrame(d)
def g(df):
return df.groupby('l')['v'].apply(pd.Series.sum,s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
12,859 | <ASSISTANT_TASK:>
Python Code:
import control as ct
import numpy as np
import matplotlib.pyplot as plt
import math
saturation=ct.saturation_nonlinearity(0.75)
x = np.linspace(-2, 2, 50)
plt.plot(x, saturation(x))
plt.xlabel("Input, x")
plt.ylabel("Output, y = sat(x)")
plt.title("Input/output map for a saturation nonli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Built-in describing functions
Step2: Backlash nonlinearity
Step3: User-defined, static nonlinearities
Step4: Stability analysis using describ... |
12,860 | <ASSISTANT_TASK:>
Python Code:
from goatools.base import download_ncbi_associations
# fin -> Filename of input file (file to be read)
fin_gene2go = download_ncbi_associations()
from goatools.anno.genetogo_reader import Gene2GoReader
objanno_hsa = Gene2GoReader(fin_gene2go, taxids=[9606])
objanno_all = Gene2GoReader(f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2) Read NCBI annotation file, "gene2go"
Step2: 2b) Read all taxids
Step4: 3) Get associations, split by namespace (Only human annotations load... |
12,861 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from eden.util import configure_logging
import logging
BABELDRAW=False
DEBUG=False
NJOBS=4
if DEBUG: NJOBS=1
configure_logging(logging.getLogger(),verbosity=1+DEBUG)
from IPython.core.display import HTML
HTML('<style>.container { width:95% !important; }<... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: demonstration of the preprocesor learning the abstraction
Step2: lets see if these wrappers give us CIPS as this is their only purpose.
Step3: ... |
12,862 | <ASSISTANT_TASK:>
Python Code:
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
import pandas as pd
class PCAForPandas(PCA):
This class is just a small wrapper around the PCA estimator of sklearn including normalization to make it
compatible with pandas DataFrames.
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: tsfresh returns a great number of features. Depending on the dynamics of the inspected time series, some of them maybe highly correlated.
Step6... |
12,863 | <ASSISTANT_TASK:>
Python Code:
import datetime
import pickle
import os
import pandas as pd
import xgboost as xgb
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import FeatureUnion, make_pipeline
from sklearn.utils import shuffle
from sklearn.base import clone
from sklearn.mode... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Before we continue, note that we'll be using your Qwiklabs project id a lot in this notebook. For convenience, set it as an environment variable... |
12,864 | <ASSISTANT_TASK:>
Python Code:
from six.moves import range
sum_sq_diff = lambda n: sum(range(1, n+1))**2 - sum(i**2 for i in range(1, n+1))
sum_sq_diff(10)
sum_sq_diff(100)
sum_sq_diff = lambda n: n*(3*n+2)*(n-1)*(n+1)/12
sum_sq_diff(100)
<END_TASK> | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <!-- TEASER_END -->
|
12,865 | <ASSISTANT_TASK:>
Python Code:
import file_processor as fp #contains simple routines for sorting files and making directories
import processing_tools as pt #bulk of the processing
import int_plot as ip #allows for interactive plots
directory = './example'
fp.plot_defaults(directory, file_ending='.h5')
list_of_files ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plotting entire directories
Step2: Interactive plots
Step3: Quick plotting
|
12,866 | <ASSISTANT_TASK:>
Python Code:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline
# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'
# import functions from the modsim.py module
from modsim import *
data = pd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data
Step2: The insulin minimal model
Step3: Exercise
Step4: Exercise
Step6: Exercise
Step7: Exercise
Step8: Exercise
|
12,867 | <ASSISTANT_TASK:>
Python Code:
import random,math
def fuc(i,a,b):
j=0
total_1=0
total_2=0
while j<i:
j=j+1
number=random.randint(a,b)
print(number)
total_1=total_1+math.ceil(math.log(number, 2))
total_2=total_2+1/math.ceil(math.log(number, 2))
print('西格玛log(随机... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 练习 3:写函数,求s=a+aa+aaa+aaaa+aa...a的值,其中a是[1,9]之间的随机整数。例如2+22+222+2222+22222(此时共有5个数相加),几个数相加由键盘输入。
Step2: 挑战性练习:将猜数游戏改成由用户随便选择一个整数,让计算机来猜测的猜数游戏。
|
12,868 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
# Ensure the right version of Tensorflow is installed.
!pip freeze | grep tensorflow==2.1
# change these to try this notebook out
BUCKET = 'cloud-training-demos-ml'
PROJECT = 'cloud-training-demos'
REGION = 'us-central1'
i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: <h2> Create ML dataset by sampling using BigQuery </h2>
Step3: There are only a limited number of years and months in the dataset. Let's see wh... |
12,869 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
from sklearn.cross_validation import train_test_split
from keras.models import Sequential
from keras.layers.core import Dense, Activation, Dropout
from keras.utils import np_utils
import numpy as np
import matplotlib.pyplot as plt
%matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linearly Separable Data
Step2: Our y values need to be in sparse one-hot encoding format, so we convert the labels to this format. We then spli... |
12,870 | <ASSISTANT_TASK:>
Python Code:
import helper
#get_ipython().magic('matplotlib notebook')
helper.create_show_p_curve()
helper.create_plot_new_np_curve()
# PCA analysis and plot
helper.plot_PCA_errors()
#Non-Planar Errors
helper.ae_with_pca_wt_np_errors()
helper.ae_with_pca_wt_p_errors()
# non-planar curves
helper... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Non-Planar Curve Generation
Step2: Discriminate Planarity with PCA
Step3: Autoencoder model with PCA Weights
Step4: Autoencoder model with Ra... |
12,871 | <ASSISTANT_TASK:>
Python Code:
# YOUR CODE HERE
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import SVG, display
s =
<svg width="100" height="100">
<circle cx="50" cy="50" r="... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Interact with SVG display
Step4: Write a function named draw_circle that draws a circle using SVG. Your function should take the parameters of ... |
12,872 | <ASSISTANT_TASK:>
Python Code:
# A bit of setup
import numpy as np
import matplotlib.pyplot as plt
from time import time
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# for auto-reloading ex... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introducing TinyImageNet
Step2: TinyImageNet-100-A classes
Step3: Visualize Examples
Step4: Test human performance
Step5: Download pretraine... |
12,873 | <ASSISTANT_TASK:>
Python Code:
### Simulation
%matplotlib inline
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(1)
import math
N=1000
s=0
def R(x,y):
return math.sqrt(x*x+y*y)
for i in range(N):
r=-100
y=0
x=0
while R(x,y)>r:
S=np.random.uni... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The simulation results do not seem to be close to the expected results of 0.15
Step2: Starting state $\phi$
Step3: Starting state $\alpha$
Ste... |
12,874 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
time = [0, 0, 0, 1, 1, 2, 2]
x = [216, 218, 217, 280, 290, 130, 132]
y = [13, 12, 12, 110, 109, 3, 56]
car = [1, 2, 3, 1, 3, 4, 5]
df = pd.DataFrame({'time': time, 'x': x, 'y': y, 'car': car})
import numpy as np
def g(df):
time = df.time.tolist()
car = df.car.t... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
12,875 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import mxnet as mx
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from data import mnist_iterator
dev = mx.gpu()
batch_size = 100
train_iter, val_iter = mnist_iterator(batch_size=batch_size, input_shape = (1,28,28))
# input
data = mx.symb... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Build Network
Step2: Prepare useful data for the network
Step3: Init weight
Step4: Train a network
Step5: Get pertubation by using fast sign... |
12,876 | <ASSISTANT_TASK:>
Python Code:
import os
testfolder = os.path.abspath(r'..\..\bifacial_radiance\TEMP\Demo1')
print ("Your simulation will be stored in %s" % testfolder)
from bifacial_radiance import *
import numpy as np
demo = RadianceObj('bifacial_example',testfolder)
albedo = 0.62
demo.setGround(albedo)
epwfi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load bifacial_radiance
Step2: <a id='step2'></a>
Step3: This will create all the folder structure of the bifacial_radiance Scene in the design... |
12,877 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
12,878 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact
o='ahjshd'
list(o)
x,y=letter_prob(list(o))
dict(zip(x,y))
def letter_prob(data):
letter_dictionary={}
for i in data:
if i not in letter_dictionary:
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Character counting and entropy
Step4: The entropy is a quantiative measure of the disorder of a probability distribution. It is used extensivel... |
12,879 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# 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 l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Predict Shakespeare with Cloud TPUs and Keras
Step3: Build the data generator
Step5: Build the model
Step6: Train the model
Step7: Make pred... |
12,880 | <ASSISTANT_TASK:>
Python Code:
# Ignore
%load_ext sql
%sql sqlite://
%config SqlMagic.feedback = False
%%sql
-- Create a table of criminals
CREATE TABLE criminals (pid, name, age, sex, city, minor);
INSERT INTO criminals VALUES (412, 'James Smith', 15, 'M', 'Santa Rosa', 1);
INSERT INTO criminals VALUES (234, NULL, 22... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create Data
Step2: Select Name And Ages Only When The Name Is Known
|
12,881 | <ASSISTANT_TASK:>
Python Code:
import vcsn
a0 = vcsn.B.expression('ab*c').standard()
a0
a1 = a0.lift()
a1
a2 = a1.eliminate_state(2)
a2
a1
a3 = a2.eliminate_state(1)
a3
a4 = a3.eliminate_state(0)
a4
a5 = a4.eliminate_state(1)
a5
a1.eliminate_state()
a1.eliminate_state().eliminate_state().eliminate_state().elimi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The following examples with be using this simple automaton as input.
Step2: We first need to convert this automaton into a spontaneous automato... |
12,882 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import requests
# get some CSV data from the SDSS SQL server
URL = "http://skyserver.sdss.org/dr12/en/tools/search/x_sql.aspx"
cmd =
SELECT TOP 1000
p.u, p.g, p.r, p.i, p.z, s.class, s.z, s.zerr
FROM
PhotoObj AS p
JOIN
SpecObj AS s ON s.bestobjid ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting data into Python
Step2: Using numpy.loadtxt
Step3: Using astropy.io.ascii
Step4: Using pandas
Step5: Specialized text formats
Step6:... |
12,883 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
import numpy as np
b = phoebe.default_binary()
b.set_value('q', value=0.7)
b.set_value('period', component='binary', value=10)
b.set_value('sma', component='binary', value=25)
b.set_value('incl', component='binary', value=0)
b.set_value(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle.
Step2: Now we need a highly eccentric system that nearly overflows at per... |
12,884 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format='retina'
%matplotlib inline
# Silence warnings
import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
warnings.simplefilter(action="ignore", category=UserWarning)
warnings.simplefilter(action="ignore", category=RuntimeWarning)
im... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Each model we have met so far has several parameters that need tuning. So called hyper-parameters. This lecture will discuss methods for systema... |
12,885 | <ASSISTANT_TASK:>
Python Code:
flights={}
minn=1.0
for i in mdg.index.get_level_values(0).unique():
#2 weeks downloaded. want to get weekly freq. but multi by 2 dept+arrv
d=4.0
if i not in flights:flights[i]={}
for j in mdg.loc[i].index.get_level_values(0).unique():
if len(mdg.loc[i].loc[j])>min... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: manual fix TGM - all flights are departing from CLJ, therefore doublecounting + BUD not represented
|
12,886 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
# use seaborn plotting defaults
import seaborn as sns; sns.set()
from sklearn.cluster import KMeans
from sklearn.datasets.samples_generator import make_blobs, make_circles
from sklearn.utils impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Introduction
Step2: Note that we have computed two data matrices
Step3: Note, again, that we have computed both the sorted (${\bf X}_{2s}$)... |
12,887 | <ASSISTANT_TASK:>
Python Code:
# convention recommended in documentation
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#enable inline plotting in notebook
%matplotlib inline
df = pd.read_csv("../data/iris.data")
df = df.sample(frac=0.2) # only use 20% of the data so the results aren't so long
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's start by reading in a dataset. This dataset is about different subclasses of the iris flower.
Step2: DataFrame is the basic building bloc... |
12,888 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(filename='minimize.png', width=500, height=500)
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x= np.array([0.,1.,2.,3.])
data = np.array([1.3,1.8,5.,10.7])
plt.scatter(x,data)
xarray=np.arange(-1,4,0.1)
plt.plot(xarray, xa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: LMFIT package
Step2: Lets visualize how a quadratic curve fits to it
Step3: Lets build a general quadratic model
Step4: Questions ?
Step5: L... |
12,889 | <ASSISTANT_TASK:>
Python Code:
double(5)
lst = list(range(1,5))
km_rechner(5)
km_rechner(123)
km_rechner(53)
#Unsere Formate
var_first = { 'measurement': 3.4, 'scale': 'kilometer' }
var_second = { 'measurement': 9.1, 'scale': 'mile' }
var_third = { 'measurement': 2.0, 'scale': 'meter' }
var_fourth = { 'measurement':... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2.Baue einen for-loop, der durch vordefinierte Zahlen-list geht, und mithilfe der eben kreierten eigenen Funktion, alle Resultate verdoppelt aus... |
12,890 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a = np.array([1, 2, 3, 4])
a
type(a)
2*a # multiple ndarray by number
b = np.array([2, 3, 4, 5])
print(a)
print(b)
a+b # two array summation
a*b
np.log(a) # apply functions to array
a
a[1]
a[1:3]
# omitted boundaries are assumed to be the beginning (or end) of the a... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: index and slicing
Step2: Multi-Dimensional Arrays
Step3: Basic info of array
Step4: Joining arrays
Step5: Array Calculation Methods
Step6: ... |
12,891 | <ASSISTANT_TASK:>
Python Code:
# Read data
in_xlsx = (r'C:\Data\James_Work\Staff\Heleen_d_W\ICP_Waters\TOC_Trends_Analysis_2015'
r'\Trends_Maps\heleen_toc_trends_data.xlsx')
df = pd.read_excel(in_xlsx)
df.head()
def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'):
'''
From ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Absolute trends
|
12,892 | <ASSISTANT_TASK:>
Python Code:
# Standard Python libraries
from __future__ import absolute_import, division, print_function, unicode_literals
from typing import Any, Iterator, Mapping, NamedTuple, Sequence, Tuple
import os
import time
import numpy as np
import glob
import matplotlib.pyplot as plt
import PIL
import imag... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Manipulating data without using TFDS
Step2: Now we make one pass (epoch) over the data, computing random minibatches of size 30. There are 100 ... |
12,893 | <ASSISTANT_TASK:>
Python Code:
from k2datascience import yelp
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline
ydc = yelp.YDC()
ydc.load_data()
business = ydc.file_data['business']
business.shape
business.head()
business.tail()
ydc.get_zip_c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Data
Step2: Exercise 1
Step3: Exercise 2
Step4: Exercise 3
Step5: Exercise 4
Step6: Exercise 5
Step7: Exercise 6
|
12,894 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.fc_net import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array
from cs231n.solver impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dropout
Step2: Dropout forward pass
Step3: Dropout backward pass
Step4: Fully-connected nets with Dropout
Step5: Regularization experiment
|
12,895 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
import scipy.misc # for image resizing
#import scipy.io.wavfile
# pip install soundfile
import soundfile
from IPython.display import Audio as audio_playback_widget
f = './data/raw-from-phone.wav'
#f = './data/num_phone_en-UK_m_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Normally an audio file needs clipping
Step2: Now, let's select the region of interest
Step3: When satisfied, write the file to disk - and upda... |
12,896 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from modules.helpers import plot_images
from functools import partial
from sklearn.metrics import (roc_auc_score, roc_curve)
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
imshow = partial(plt.imshow, cmap='gray', interpolation='nearest', aspec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate topics
Step2: Generate documents from topics
Step3: Generate responses
Step4: Estimate parameters
Step5: Predict response of test d... |
12,897 | <ASSISTANT_TASK:>
Python Code:
import json
import copy
from functools import reduce
import numpy as np # contains helpful math functions like numpy.exp()
import numpy.random as random # see numpy.random module
# import random # alternative to numpy.random module
from typing import Tuple, List, Any
import matplotlib.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: I. Introduction
Step5: II. Simulated Annealing -- Main Loop
Step12: III. Representing the Problem
Step13: Testing TravelingSalesmanProblem
St... |
12,898 | <ASSISTANT_TASK:>
Python Code:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline
# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'
import numpy as np
import pandas as pd
class BayesTable(pd.DataFrame):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As an example, I'll use the "cookie problem", which is a version of a classic probability "urn problem".
Step2: Here's an instance that represe... |
12,899 | <ASSISTANT_TASK:>
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 writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TFRecord 和 tf.Example
Step5: tf.Example
Step6: 注:为了简单起见,本示例仅使用标量输入。要处理非标量特征,最简单的方法是使用 tf.io.serialize_tensor 将张量转换为二进制字符串。在 TensorFlow 中,字符串是标... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.