Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
2,600 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from jyquickhelper import add_notebook_menu
add_notebook_menu()
# Répare une incompatibilité entre scipy 1.0 et statsmodels 0.8.
from pymyinstall.fix import fix_scipy10_for_statsmodels08
fix_scipy10_for_statsmodels08()
import pyensae.dat... | <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: Prérequis de l'énoncé
Step2: Exercice 1
Step3: Je reprends également le graphique montrant la matrice de corrélations qu'on peut également ob... |
2,601 | <ASSISTANT_TASK:>
Python Code:
import os
import re
import time
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
BASE_PATH = "/Volumes/LaCie/from_macHD/Github/crossing_paper2017"
# BASE_PATH = ".."
def offspring_empirical(Dmnk, levels, laplace=False):
# Get pooled frequencie... | <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: Compute the empirical probabilities by averaging across all replications
Step2: Get theoretical values of the probability according to the conj... |
2,602 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
3 + math.sqrt(3)
expr = 3 * sqrt(3)
expr
init_printing(use_latex='mathjax')
expr
expr = sqrt(8)
expr
x, y = symbols("x y")
expr = x**2 + y**2
expr
expr = (x+y)**3
expr
a = Symbol("a")
a.is_imaginary
b = Symbol("b", integer=True)
b.is_imaginary
c = Symbol("c", positiv... | <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: symbols() & Symbol()
Step2: Assumptions for symbols
Step3: Imaginary Numbers
Step4: Rational()
Step5: Numerical evaluation
Step6: subs()
St... |
2,603 | <ASSISTANT_TASK:>
Python Code:
'''
:entrée n: int, SAISIE au clavier
:pré-cond: n ≥ 0
:sortie f: int, AFFICHÉE à l'écran
:post-cond: f = n! = 1×2×3×...×n
'''
n = int(input("Valeur de n (entier positif ou nul) ? "))
f = 1
i = 2
while i < n:
f = f*i
i = i+1
print(f)
'''
:entrée n: int, AFFECTÉE précédemment
:pré-... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: On admettra que, dans une fonction, lorsque qu'on ne spécifie pas le mode de transmission des entrées-sorties, il est forcément "PASSÉE en param... |
2,604 | <ASSISTANT_TASK:>
Python Code:
theta = 0.1
lam = 18000
grid_size = int(theta * lam)
def kernel_oversample(ff, Qpx, s=None, P = 1):
Takes a farfield pattern and creates an oversampled convolution
function.
If the far field size is smaller than N*Qpx, we will pad it. This
essentially means we apply 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: First, some grid characteristics. Only theta is actually important here, the rest is just decides the range of the example $u/v$ values.
Step2: ... |
2,605 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data')
def model_inputs(real_dim, z_dim):
inputs_real = tf.placeholde... | <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: Model Inputs
Step2: Generator network
Step3: Discriminator
Step4: Hyperparameters
Step5: Build network
Step6: Discriminator and Generator L... |
2,606 | <ASSISTANT_TASK:>
Python Code:
### BEGIN SOLUTION
import sympy as sym
x = sym.Symbol("x")
y = 2 * x * (x - 3) * (x - 5)
sym.diff(y, x)
### END SOLUTION
q1_a_answer = _
feedback_text = Your output is not a symbolic expression.
You are expected to use sympy for this question.
try:
assert q1_a_answer.is_algebraic_expr... | <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: Computing for Mathematics - Example individual coursework
Step5: b. y =\(\frac{3x ^ 3 + 6 \sqrt{x} + 3) }{ (3 x ^{(1 / 4)})}\)
Step8: \(y=2 x... |
2,607 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras import layers
from keras.layers import Input, Add, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D, AveragePooling2D, MaxPooling2D, GlobalMaxPooling2D
from keras.models import Model, load_model
from keras.preprocessing import image
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:
Step2: 1 - The problem of very deep neural networks
Step4: Expected Output
Step6: Expected Output
Step7: Run the following code to build the model's... |
2,608 | <ASSISTANT_TASK:>
Python Code:
import time
from poppy.creatures import PoppyTorso
poppy = PoppyTorso(simulator='vrep')
io = poppy._controllers[0].io
name = 'cube'
position = [0.2, 0, 1] # X, Y, Z
sizes = [0.15, 0.15, 0.15] # in meters
mass = 0.1 # in kg
io.add_cube(name, position, sizes, mass)
#ouvrir
poppy.l_arm_z.g... | <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: Ajouter un objet
Step2: Quelques exemples de mouvement "utile"
Step3: Solution possible
Step4: Encore buger ? essaie celles-ci
Step5: Tu as... |
2,609 | <ASSISTANT_TASK:>
Python Code:
# 为这个项目导入需要的库
import numpy as np
import pandas as pd
from time import time
from IPython.display import display # 允许为DataFrame使用display()
# 导入附加的可视化代码visuals.py
import visuals as vs
# 为notebook提供更加漂亮的可视化
%matplotlib inline
# 导入人口普查数据
data = pd.read_csv("census.csv")
# 成功 - 显示第一条记录
display(... | <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: 对于高度倾斜分布的特征如'capital-gain'和'capital-loss',常见的做法是对数据施加一个<a href="https
Step4: 规一化数字特征
Step5: 练习:数据预处理
Step6: 混洗和切... |
2,610 | <ASSISTANT_TASK:>
Python Code:
# a is a tensor with require grad
a = torch.tensor(2., requires_grad=True);a
b = a.detach();b # with deatch() no grad.
c = a.data;c
d = a.item();d
<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: tensor.data returns a new tensor that shares storage with tensor. However, it always has requires_grad=False (even if the original tensor had re... |
2,611 | <ASSISTANT_TASK:>
Python Code:
def digitDividesK(num , k ) :
while(num ) :
d = num % 10
if(d != 0 and k % d == 0 ) :
return True
num = num // 10
return False
def findCount(l , r , k ) :
count = 0
for i in range(l , r + 1 ) :
if(digitDividesK(i , k ) ) :
count += 1
return count
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
2,612 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import HTML
def css_styling():
sheet = '../css/custom.css'
styles = open(sheet, "r").read()
return HTML(styles)
css_styling()
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: Tasks
Step4: Magic Methods Extension
|
2,613 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'uhh', 'sandbox-3', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <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... |
2,614 | <ASSISTANT_TASK:>
Python Code:
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from metpy.calc import get_wind_components
from metpy.calc import reduce_point_density
from metpy.cbook import get_test_data
from metpy.plots import add_met... | <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 setup
Step2: This sample data has way too many stations to plot all of them. The number
Step3: Now that we have the data we want, we need ... |
2,615 | <ASSISTANT_TASK:>
Python Code:
# import the modules
import GPy
import csv
import sys
import numpy as np
import pandas as pd
import seaborn as sns
import cPickle as pickle
from matplotlib import cm
import scipy.stats as stats
from scipy.stats import norm
import sklearn.metrics as metrics
from numpy import sqrt, abs, rou... | <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 Loading
Step2: Statistical Significance Tests
Step3: Plotting
|
2,616 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
sample_numpy_data = np.array(np.arange(24)).reshape((6,4))
dates_index = pd.date_range('20160101', periods=6)
sample_df = pd.DataFrame(sample_numpy_data, index=dates_index, columns=list('ABCD'))
sample_df
sample_df['C']
sample_df[1:4]
sample_df['2... | <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: selection using column name
Step2: selection using slice
Step3: selection using date time index
Step4: Selection by label
Step5: Selecting u... |
2,617 | <ASSISTANT_TASK:>
Python Code:
from fretbursts import *
from fretbursts.phtools import phrates
sns = init_notebook(apionly=True)
sns.__version__
# Tweak here matplotlib style
import matplotlib as mpl
mpl.rcParams['font.sans-serif'].insert(0, 'Arial')
mpl.rcParams['font.size'] = 12
%config InlineBackend.figure_format = ... | <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: KDE considerations
Step5: Notes on Kernel Shape
Step6: FRET-2CDE Results
Step7: Next, we get the timestamps and selection m... |
2,618 | <ASSISTANT_TASK:>
Python Code:
import ipywidgets
import IPython.display
import iris
import numpy as np
import iris.quickplot as iplt
import matplotlib.pyplot as plt
cube = iris.load_cube(iris.sample_data_path('A1B.2098.pp'))
print cube
plot_type_dict = {'contour': iplt.contour, 'contourf': iplt.contourf, 'pcolor': ip... | <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 cube.
Step2: Compose and sort a dictionary of plot-types and then construct widget to present them, along with a default option. Display t... |
2,619 | <ASSISTANT_TASK:>
Python Code:
from quspin.operators import hamiltonian # Hamiltonians and operators
from quspin.basis import spinless_fermion_basis_1d, tensor_basis # Hilbert space fermion and tensor bases
import numpy as np # generic math functions
##### define model parameters #####
L=4 # system size
J=1.0 # hopping... | <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 build the basis for spinful fermions, we take two copies of the basis for spinless fermions and tensor them using the tensor_basis constructo... |
2,620 | <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: AQT Cirq Tutorial
Step2: AQT supports Cirq as a third party software development kit and offers access to various quantum computing devices and... |
2,621 | <ASSISTANT_TASK:>
Python Code:
df = pd.read_csv("congress.csv", error_bad_lines=False)
df.head()
#bioguide: The alphanumeric ID for legislators in http://bioguide.congress.gov.
df['chamber'].value_counts() #sounds like a lot. We might have repetitions.
df['bioguide'].describe() #we count the bioguide, which is unique... | <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: Do a .head() to get a feel for your data
Step2: Write down 12 questions to ask your data, or 12 things to hunt for in the data
Step3: 2) How m... |
2,622 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import scipy
import sklearn
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import confusion_matrix, classification_report
from sklearn.model_selection import train_test_split,cross_val_score, KFold, cros... | <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: PCA Analysis
Step2: Feature Selection
Step3: Random Forest
Step4: Gradient Boosting
Step5: Neural Network
|
2,623 | <ASSISTANT_TASK:>
Python Code:
%pylab nbagg
import sygma as s
reload(s)
s.__file__
#from imp import *
#s=load_source('sygma','/home/nugrid/nugrid/SYGMA/SYGMA_online/SYGMA_dev/sygma.py')
from scipy.integrate import quad
from scipy.interpolate import UnivariateSpline
import matplotlib.pyplot as plt
import numpy as np
k_... | <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: Results
Step2: Includes stars from 10Msun to 30Msun (upper end consistent with higher Z).
Step3: Test of distinguishing between massive PoPII... |
2,624 | <ASSISTANT_TASK:>
Python Code:
s= 'wordsmith'
vowels = {'a','e','i','o','u'}
count = 0
for char in s:
if char in vowels:
count+=1
print "Number of vowels: " + str(count)
s = 'azcbobobegghakl'
pattern = 'bob'
count =0
for position in range(0,len(s)):
if s[position:position+3]==pattern:
count+=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: 2. COUNTING BOBS
|
2,625 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'csiro-bom', 'sandbox-1', 'ocnbgchem')
# 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: 1... |
2,626 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df_train = pd.read_csv("http://bit.do/house-price")
df_train.head()
df_train.columns
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.distplot(df_train["SalePrice"]);
df_train.plot.scatter(x="GrLivArea", y="SalePrice")
df_train.plot.scat... | <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: Some info about the attributes
Step2: Sale Price
Step3: grlivarea vs Sale Price
Step4: TotalBsmtSF vs Sale Price
Step5: box plot overallqual... |
2,627 | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
# Sheraz Khan <sheraz@khansheraz.com>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.connectivity import ... | <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: Here we do some things in the name of speed, such as crop (which will
Step2: Now we band-pass filter our data and create epochs.
Step3: Comput... |
2,628 | <ASSISTANT_TASK:>
Python Code:
import os
import urllib
import webbrowser
import pandas as pd
from bs4 import BeautifulSoup
url = 'http://grad-schools.usnews.rankingsandreviews.com/best-graduate-schools/top-humanities-schools/sociology-rankings/page+1'
webbrowser.open_new_tab(url)
def extract_page_data(table_rows):
... | <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: open US News Rankings for Sociology webpage
Step3: create a function to extract page data from US News
Step4: make empty lists for US News Ran... |
2,629 | <ASSISTANT_TASK:>
Python Code:
def get_data(x, mag=100, pl=-2.5, xmin=50.0):
C = (-pl - 1)*xmin**(-pl-1)
return mag/0.03*C*x**(pl)
get_data(50)
50**-2.5
100**(-1/2.5) * 50**-2.5
pl = -2.5
xmin = 50
C = (-pl - 1)*xmin**(-pl-1)
get_data(50)
plt.loglog(tb.logspace(50, 5000, 10), get_data(tb.logspace(50, 5... | <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% efficiency integral channels
|
2,630 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import pickle
import os
from IPython.display import Image
from IPython.display import display
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing imp... | <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: Custom functions and global variables
Step2: Dataset
Step3: Next, read the two documents describing the dataset (data/ACS2015_PUMS_README.pdf ... |
2,631 | <ASSISTANT_TASK:>
Python Code:
# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import matplotlib.pyplot as plt
import numpy as np
import mne
from mne.datasets import sample
from mne.beamformer import lcmv
print(__doc__)
data_path = sample.data_path()
raw_fname = data_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: Get epochs
|
2,632 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from astropy.io import fits
from astropy import wcs
import pickle
import dill
import sys
import os
import xidplus
import copy
from xidplus import moc_routines, catalogue
from xidplus import posterior_maps as postmaps
from builtins import input
from healpy import pixelf... | <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: Work out what small tiles are in the test large tile file for PACS
Step2: You can fit with the numpyro backend.
|
2,633 | <ASSISTANT_TASK:>
Python Code::
model.save('filename')
<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:
|
2,634 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import pandas as pd
import mne
kiloword_data_folder = mne.datasets.kiloword.data_path()
kiloword_data_file = os.path.join(kiloword_data_folder,
'kword_metadata-epo.fif')
epochs = mne.read_epochs(kiloword_data_file)
epochs.met... | <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: Viewing Epochs metadata
Step2: Viewing the metadata values for a given epoch and metadata variable is done
Step3: Modifying the metadata
Step4... |
2,635 | <ASSISTANT_TASK:>
Python Code:
data_in_shape = (6, 6)
L = AveragePooling1D(pool_size=2, strides=None, padding='valid')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(250)
data_in = 2 * np.rand... | <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: [pooling.AveragePooling1D.1] input 6x6, pool_size=2, strides=1, padding='valid'
Step2: [pooling.AveragePooling1D.2] input 6x6, pool_size=2, str... |
2,636 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
A_log, B = load_data()
for i in range(len(A_log)):
if A_log[i] == 1:
A_log[i] = 0
else:
A_log[i] = 1
C = B[:, A_log.bool()]
<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:
|
2,637 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from numpy import pi
import plotly.graph_objects as go
u = np.array([0.5 + 0.5*np.exp(2*k*np.pi*1j/8) for k in range(8)], dtype=np.complex)
fig = go.Figure(go.Scatter(
x = u.real,
y= u.imag,
mode='markers',
marker=dict( si... | <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: Define data that will be updated by each animation frame
Step2: Set the plot layout
Step3: The black disk is defined as a Plotly shape, and th... |
2,638 | <ASSISTANT_TASK:>
Python Code:
# Import the usual libraries
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
# Enable inline plotting at lower left
%matplotlib inline
import pynrc
from pynrc import nrc_utils
from pynrc.nrc_utils import S, jl_poly_fit
from pynrc.pynrc_core import table_filter
pynrc.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:
Step1: Example 1
Step2: RESULTS
Step3: Example 3
Step4: Mock observed spectrum
Step5: Example 4
Step6: Example 5
|
2,639 | <ASSISTANT_TASK:>
Python Code:
def round_down(n):
s = str(n)
if n <= 20:
return n
elif n < 100:
return int(s[0] + '0'), int(s[1])
elif n<1000:
return int(s[0] + '00'),int(s[1]),int(s[2])
assert round_down(5) == 5
assert round_down(55) == (50,5)
assert round_down(222) == ... | <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: Project Euler
Step2: Now write a set of assert tests for your number_to_words function that verifies that it is working as expected.
Step4: No... |
2,640 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# Python List
L = [1, 2, 3]
A = np.array([1, 2, 3])
# You can operate A with mathmatically operation. L cannot.
print(2*A)
print(A**2)
print(np.sqrt(A))
print(np.log(A))
a = np.array([1, 2])
b = np.array([3, 4])
# dot product in different ways:
np.dot(a, b) # 11
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:
Step1: Array vs List
Step2: Dot Product
Step3: Matrix
|
2,641 | <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: Save and restore models
Step2: Get an example dataset
Step3: Define a model
Step4: Save checkpoints during training
Step5: This creates a si... |
2,642 | <ASSISTANT_TASK:>
Python Code:
from PIL import Image, ImageOps
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
%matplotlib inline
test_image = 'harvard_2008_08_24_120140.jpg'
test_mask = 'harvard_DB_0001_01.tif'
# read in mask image and convert to nparray
mask_img = Image.ope... | <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: The quantity we use for phenological studies is the "green chromatic coordinate" or "gcc" value. This is defined as
Step3: To get a better ide... |
2,643 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
import pickle
import matplotlib.pyplot as plt
import numpy as np
from collections import defaultdict
from scipy.spatial.distance import pdist
from scipy.stats import gaussian_kde
pythonpath_for_regnmf = os.path.realpath(os.path.join(os.path.pardir, os.path.pardir))
sy... | <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: Parameter for creation of surrogate Data
Step2: Parameter for Matrix Factorization
Step3: Helper Functions
Step4: Perform chained matrix fact... |
2,644 | <ASSISTANT_TASK:>
Python Code:
X, y = make_circles(n_samples=1000, noise=0.1)
# 75/25 train/test split
orig_X_train, orig_X_test, orig_y_train, orig_y_test = train_test_split(X, y, test_size=0.25)
# Transform data into tensors.
X = torch.tensor(orig_X_train, dtype=torch.float)
y = torch.tensor(orig_y_train, dtype=torch... | <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: Visualize data
Step2: Basic Neural Net
Step3: What do the activation regions look like?
Step6: What is the classification performance?
Step9:... |
2,645 | <ASSISTANT_TASK:>
Python Code:
from dx import *
me = market_environment(name='me', pricing_date=dt.datetime(2015, 1, 1))
me.add_constant('initial_value', 0.01)
me.add_constant('volatility', 0.1)
me.add_constant('kappa', 2.0)
me.add_constant('theta', 0.05)
me.add_constant('paths', 1000)
me.add_constant('frequency', '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: Second, the instantiation of the class.
Step2: The following is an example list object containing datetime objects.
Step3: The call of the met... |
2,646 | <ASSISTANT_TASK:>
Python Code:
def flip_case(string: str) -> str:
return string.swapcase()
<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:
|
2,647 | <ASSISTANT_TASK:>
Python Code:
from collections import defaultdict
import sys
def countFreq(arr , n ) :
mp1 = defaultdict(int )
for i in range(n ) :
mp1[arr[i ] ] += 1
mp2 = defaultdict(int )
for it in mp1 :
mp2[mp1[it ] ] += 1
M = - sys . maxsize - 1
for it in mp2 :
M = max(M , mp2[it ] )
fo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
2,648 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
import numpy as np
from sklearn import datasets
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
# Set random seed
np.random.seed(... | <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 Iris Dataset
Step2: Create Pipeline With Model Selection Search Space
Step3: Create Model Selection Using Grid Search
Step4: Conduct Mod... |
2,649 | <ASSISTANT_TASK:>
Python Code:
# Solution
import numpy as np
import math
def dist(pt1, pt2):
return math.sqrt( (pt1[0] - pt2[0])**2 + (pt1[1] - pt2[1])**2 )
pts1 = [ (25,125), (44,105), (29,97), (35, 63), (55, 63), (42, 57), (23, 40), (64,37), (33,22), (55,20) ]
pts2 = [ (28,145), (38,115), (50,130),(65,140), (55,... | <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: Q2.
Step2: Q3.
Step3: Q2.
Step4: Solution 2.
|
2,650 | <ASSISTANT_TASK:>
Python Code:
class Corpus:
def __init__(self):
'''
A corpus object maintains a mapping from a word (string) to a unique id (int).
'''
self.word_idx_dict = {}
self.uniq_word_cnt = 0
def update_vocab(self, words):
'''
Updates the corpu... | <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: Download and extract datasets
Step2: Parse datasets to (memories, question, answer) tuples, perform word -> idx mapping
Step3: Example Descrip... |
2,651 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
import gzip
%matplotlib inline
def normalise_01(K):
Normalise values of kernel matrix to have smallest value 0 and largest value 1.
smallest = np.min(K)
largest = np.max(K)
return (K - smallest)/... | <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: Normalisation
Step4: In the following, we use the fact that kernels ($k(\cdot, \cdot)$) are inner products in a feature space with feature mapp... |
2,652 | <ASSISTANT_TASK:>
Python Code:
def h2percentile(h,p):
import numpy as np
s = h.sum()
k = ((s-1) * p/100.)+1
dw = np.floor(k)
up = np.ceil(k)
hc = np.cumsum(h)
if isinstance(p, int):
k1 = np.argmax(hc>=dw)
k2 = np.argmax(hc>=up)
else:
k1 = np.argmax(hc>=dw[:,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:
Step1: Examples
Step2: Numeric Example
Step3: Image Example
|
2,653 | <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: Text Searcher with TensorFlow Lite Model Maker
Step2: Import the required packages.
Step3: Prepare the dataset
Step10: Then, save the data in... |
2,654 | <ASSISTANT_TASK:>
Python Code:
# HIDDEN - generic nonsense for setting up environment
from datascience import *
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
from ipywidgets import interact
# datascience version number of last run of this notebook
version.__v... | <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 a table as a model of a stochastic phenomenom
Step2: Composition
Step3: Visualization
Step4: Computing on distributions
Step6: Statis... |
2,655 | <ASSISTANT_TASK:>
Python Code:
import numpy as np # modulo de computo numerico
import matplotlib.pyplot as plt # modulo de graficas
import pandas as pd # modulo de datos
import seaborn as sns
import scipy as sp
import scipy.interpolate, scipy.integrate # para interpolar e integrar
import wget, tarfile # para bajar dat... | <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: Graficas chidas!
Step2: 1 A graficar el Hermoso Espectro Solar
Step3: Para usarlo convertimos numeros a unidades, por ejemplo
Step4: Bajar d... |
2,656 | <ASSISTANT_TASK:>
Python Code:
str_massaction =
A -> B; 'k1'
B + C -> A + C; 'k2'
2 B -> B + C; 'k3'
rsys3 = ReactionSystem.from_string(str_massaction, substance_factory=lambda formula: Substance(formula))
rsys3.substance_names()
odesys3, extra3 = get_odesys(rsys3, include_params=False, lower_bounds=[0, 0, 0])
extra3[... | <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: We could also have parsed the reactions from a string
Step3: For larger systems it is easy to loose track of what substances are actually playi... |
2,657 | <ASSISTANT_TASK:>
Python Code:
import graphlab
from em_utilities import *
wiki = graphlab.SFrame('people_wiki.gl/').head(5000)
wiki['tf_idf'] = graphlab.text_analytics.tf_idf(wiki['text'])
tf_idf, map_index_to_word = sframe_to_scipy(wiki, 'tf_idf')
tf_idf = normalize(tf_idf)
for i in range(5):
doc = tf_idf[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: We also have a Python file containing implementations for several functions that will be used during the course of this assignment.
Step2: Load... |
2,658 | <ASSISTANT_TASK:>
Python Code:
data_dir = os.path.join(os.environ['DATA_DIR'], 'uci')
exp_dir = os.path.join(os.environ['EXP_DIR'], 'apm_mcmc')
data_set = 'pima'
method = 'pmmh'
n_chain = 10
chain_offset = 0
seeds = np.random.random_integers(10000, size=n_chain)
n_imp_sample = 1
adapt_run = dict(
low_acc_thr = 0.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: Specify main run parameters
Step2: Load data and normalise inputs
Step3: Specify prior parameters (data dependent so do after data load)
Step4... |
2,659 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.linear_model import LogisticRegression
%matplotlib inline
df_train = pd.read_csv('../input/train.csv')
df_test = pd.read_csv('../input/test.csv')
df_train.head()
df_train.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: Load training data and test data.
Step2: Well, I don't really have any idea how to handle these data. So let's just take a look at them. Let's ... |
2,660 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
url = 'http://aima.cs.berkeley.edu/data/iris.csv'
df = pd.read_csv(url,delimiter=',')
df.head(2)
df.describe()
from numpy import genfromtxt, zeros
data = genfromtxt(url,delimiter=',',usecols=(0,1,2... | <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: 创建一个变量url,指向一个csv文件。然后通过read_csv()函数来加载它。
Step2: 变量df包含了一个DataFrame对象,一种二维表的pandas数据结构。 接下来就调用head(n)方法来显示前n列的数据吧。notebook会将其显示为一个HTML的表,如下所示:
|
2,661 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
from mpltools import style
import numpy as np
style.use('ggplot')
%matplotlib inline
import pandas as pd
import shelve
from collections import defaultdict
count_dict = {}
for line in open('../mapreduce/predicted_label_counts.txt'):
uri, label, values =... | <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: Construct original counts file
Step3: Generate excludes by ambiguity
Step4: Generate typed n-grams
|
2,662 | <ASSISTANT_TASK:>
Python Code:
# Author: Martin Luessi <mluessi@nmr.mgh.harvard.edu>
# Daniel Strohmeier <daniel.strohmeier@tu-ilmenau.de>
#
# License: BSD-3-Clause
import numpy as np
import mne
from mne.datasets import sample
from mne.inverse_sparse import gamma_map, make_stc_from_dipoles
from mne.viz import (... | <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: Plot dipole activations
Step2: Show the evoked response and the residual for gradiometers
Step3: Generate stc from dipoles
Step4: View in 2D ... |
2,663 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/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: The following circuit diagram (from Wikipedia) shows a low-pass filter built with one resistor and one capacitor.
Step3: Now we can pass the ... |
2,664 | <ASSISTANT_TASK:>
Python Code:
# Standard library
import datetime
import time
# Third party libraries
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Digitre code
import digitre_preprocessing as prep
import digitre_model
import digitre_classifier
# Reload digitre code in the same session (during... | <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 id="TF"></a>
Step2: <a id="Digitre"></a>
Step3: <a id="Class"></a>
|
2,665 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import numpy as np
import scipy.io
import matplotlib.pyplot as plt
import math
from scipy.optimize import fmin_l_bfgs_b
from sklearn.metrics import accuracy_score
import pickle
# Load data
with open('./data/pickled/xtrain.pickle', 'rb') as f:
xtrain = pickle.load(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: First, we load the data. For details, please see the accompanying notebook MNIST-loader.ipynb for details.
Step2: Now let's define some useful ... |
2,666 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division # Gunakan print(...) dan bukan print ...
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import random
import keras
from keras.models import Sequential, load_model
from keras.layers import Dense, ... | <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. Eksplorasi Awal Data - Advertising (6 poin)
Step2: Soal 1.1.a (1 poin)
Step3: Soal 3.1 (1 poin)
|
2,667 | <ASSISTANT_TASK:>
Python Code:
from atmPy.instruments.POPS import housekeeping
%matplotlib inline
filename = './data/POPS_housekeeping.csv'
hk = housekeeping.read_csv(filename)
out = hk.plot_all()
<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: Reading a housekeeping file
Step2: Done! hk is an instance of TimeSeries and you can do with it what ever the instance is capable of (see here)... |
2,668 | <ASSISTANT_TASK:>
Python Code:
import espressomd
import espressomd.magnetostatics
espressomd.assert_features(['DIPOLES', 'DP3M', 'LENNARD_JONES'])
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18})
import numpy as np
import tqdm
# Lennard-Jones parameters
LJ_SIGMA = 1.
LJ_EPSILON... | <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: and set up the simulation parameters where we introduce a new dimensionless parameter
Step2: Now we set up the system. As in part I, the orien... |
2,669 | <ASSISTANT_TASK:>
Python Code:
# import the required packages
from swat import *
from pprint import pprint
import numpy as np
import matplotlib.pyplot as plt
import cv2
# define the function to display the processed image files.
def imageShow(session, casTable, imageId, nimages):
a = session.table.fetch(sastypes=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: Set up the environment and Connect to SAS from Python
Step2: Load images and resize
Step3: Convert colours
Step4: Apply noise reduction and b... |
2,670 | <ASSISTANT_TASK:>
Python Code:
# Some functions already covered
nums = [num**2 for num in range(1,11)]
print(nums) #print is a function, atleast Python 3.x onwards
# In Python 2.x - Not a function, it's a statement.
# Will give an error in Python 3.x
print nums
len(nums)
max(nums)
min(nums)
sum(nums)
nums.reverse()
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: So as you can see, you have used a lot of functions already.
Step2: Best Practices in Importing
Step3: Let's also look at the 'return' stateme... |
2,671 | <ASSISTANT_TASK:>
Python Code::
import tensorflow as tf
from tensorflow.keras.utils import image_dataset_from_directory
PATH = ".../Citrus/Leaves"
ds = image_dataset_from_directory(PATH,
validation_split=0.2, subset="training",
image_size=(256,256), 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:
|
2,672 | <ASSISTANT_TASK:>
Python Code:
import pygeogrids.grids as grids
import pygeogrids.shapefile as shapefile
import numpy as np
import os
testgrid = grids.genreg_grid(0.1, 0.1)
austria = shapefile.get_gad_grid_points(
testgrid, os.path.join('/home', os.environ['USER'], 'Downloads', 'gadm', 'gadm28_levels.shp.zip'), 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: We can now subset the 0.1x0.1 degree regular grid with the shapefiles from http
Step2: We can the plot the resulting grid using a simple scatte... |
2,673 | <ASSISTANT_TASK:>
Python Code:
!python -m spacy download en_core_web_sm
from __future__ import unicode_literals, print_function
import boto3
import json
import numpy as np
import pandas as pd
import spacy
S3_BUCKET = "verta-strata"
S3_KEY = "english-tweets.csv"
FILENAME = S3_KEY
boto3.client('s3').download_file(S3_BU... | <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: And import the boilerplate code.
Step2: Data prep
Step3: Clean and load data using our library.
Step4: Train the model
Step5: Update the mod... |
2,674 | <ASSISTANT_TASK:>
Python Code:
import csv
import pandas as pd
titanic_df = pd.read_csv('titanic.csv', quoting=csv.QUOTE_MINIMAL, skiprows=[0],
names=['passenger_id', 'survived', 'class', 'name', 'sex', 'age',
'sib_sp', 'par_ch', 'ticket_id', 'fare', 'cabin', 'por... | <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 Wrangling
Step2: Next, to ensure that the dataset is ready for analysis, check whether any attributes have missing values.
Step3: The age... |
2,675 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from datetime import datetime, timedelta
import utils_data
from os.path import join
from IPython.display import display
dates_2016 = [datetime(2016, 1, 1) + timedelta(days=i) for i in range(366)]
dat... | <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 in dataset and split into fraud/non-fraud
Step2: Print some basic info about the dataset
Step3: Percentage of fraudulent cards also in ge... |
2,676 | <ASSISTANT_TASK:>
Python Code:
project = Project('test')
print project.files
print project.generators
print project.models
engine = project.generators.c(Engine).one
modeller = project.generators.c(Analysis).one
pdb_file = project.files.f('*.pdb').one
print project.trajectories
# for f in project.files:
# print 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: Set up the project and pick a resource. This should be done only the first time, when the project is created.
Step2: Opening a project will ope... |
2,677 | <ASSISTANT_TASK:>
Python Code:
# BE SURE TO RUN THIS CELL BEFORE ANY OF THE OTHER CELLS
import psycopg2
import pandas as pd
# put your code here
# ------------------
statement =
SELECT DISTINCT iso_language, job_id,COUNT(*)
FROM
(SELECT
DISTINCT ON (from_user, iso_language)
*
FROM (SELECT * FROM twitter.tweet WHER... | <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: Twitter
Step2: Databases can do a lot, but there are somethings that are more easily acheived through throught the flexibility of a general-pur... |
2,678 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
assert os.path.isfile('yearssn.dat')
data=np.loadtxt('yearssn.dat')
year=data[:,0]
ssc=data[:,1]
assert len(year)==315
assert year.dtype==np.dtype(float)
assert len(ssc)==315
assert ssc.dtype==np.dtype(float... | <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: Line plot of sunspot data
Step2: Use np.loadtxt to read the data into a NumPy array called data. Then create two new 1d NumPy arrays named year... |
2,679 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import mne
import os.path as op
from matplotlib import pyplot as plt
# Load an example dataset, the preload flag loads the data into memory now
data_path = op.join(mne.datasets.sample.data_path(), 'MEG',
'sample', 'sample_audvis_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:
Step1: Continuous data is stored in objects of type
Step2: Information about the channels contained in the
Step3: You can also pass an index direct... |
2,680 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import helper
import tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-... | <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: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
2,681 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
points = pd.read_csv('rand.txt')
points.tail()
y = points["class"]
X = points[['r1', 'r2', 'r3', 'r4', 'r5', 'r6', 'r7', 'r8', 'r9', 'r10', 'r11']]
# Разбиваем на обучающее и тестовое множества:
from sklearn.model_selection import train_test_split
X_... | <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,682 | <ASSISTANT_TASK:>
Python Code:
#Ensure that we have Apache Beam version installed.
!pip freeze | grep apache-beam || sudo pip install apache-beam[gcp]==2.12.0
import tensorflow as tf
import apache_beam as beam
import shutil
import os
print(tf.__version__)
PROJECT = "cloud-training-demos" # Replace with your PROJECT
B... | <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, set the environment variables related to your GCP Project.
Step3: Save the query from earlier
Step5: Create ML dataset using Dataflow
St... |
2,683 | <ASSISTANT_TASK:>
Python Code:
def getamzProd(a,i,search_1):#取得連線後的DataFrame資料,a是index,i是DataFrame總長度
while(a<=i):
ProdId=search_1.iloc[a]['pindex']
pname=search_1.iloc[a]['pname']
# totalRev=search_1.iloc[a]['totalRev']
totalRev=1#快速測試用
return ProdId,pname,totalRev
def Autho... | <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: short summary
Step2: the following results are the same
Step3: 我們先前確立了我們的爬蟲程式完全可以抓到我們想要抓的東西,且抓了幾個有數千評論的商品,測試結果均正常。接下來,我們要指派特定吸塵器種類底下的商品給各爬蟲程式去... |
2,684 | <ASSISTANT_TASK:>
Python Code:
x_sc = LinearScale()
y_sc = LinearScale()
x_data = np.arange(20)
y_data = np.random.randn(20)
scatter_chart = Scatter(
x=x_data,
y=y_data,
scales={"x": x_sc, "y": y_sc},
colors=["dodgerblue"],
interactions={"click": "select"},
selected_style={"opacity": 1.0, "fill"... | <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: Alternately, the selected attribute can be directly set on the Python side (try running the cell below)
Step2: Scatter Chart Interactions and T... |
2,685 | <ASSISTANT_TASK:>
Python Code:
p=Function('p')
m,s,h = symbols('m s h')
m=M(x,y,z)
q=Q(x,y,t)
d=D(x,y,t)
e=E(x,y)
dtt=as_finite_diff(p(x,y,z,t).diff(t,t), [t-s,t, t+s])
dt=as_finite_diff(p(x,y,t).diff(t), [t-s, t+s])
# Spacial finite differences can easily be extended to higher order by increasing the list of sampling... | <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: Time and space discretization as a Taylor expansion.
Step2: Solve forward in time
Step3: Rewriting the discret PDE as part of an Inversion
St... |
2,686 | <ASSISTANT_TASK:>
Python Code:
# The path to the local git repo for Indic NLP library
INDIC_NLP_LIB_HOME="/home/development/anoop/installs/indic_nlp_library"
# The path to the local git repo for Indic NLP Resources
INDIC_NLP_RESOURCES="/usr/local/bin/indicnlp/indic_nlp_resources"
import sys
sys.path.append('{}/src'.fo... | <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: Add Library to Python path
Step2: Export environment variable
Step3: Initialize the Indic NLP library
Step4: Let's actually try out some of... |
2,687 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import GPy
from emukit.model_wrappers import GPyModelWrapper
from emukit.experimental_design.experimental_design_loop import ExperimentalDesignLoop
from emukit.core import ParameterSpace, ContinuousParameter
from emukit.core.loop import UserFunctionWrapper
x_min = -30.... | <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 assume we have built a GPy model of some function that we would like to understand. In this toy example we will use sin(x), but of course ... |
2,688 | <ASSISTANT_TASK:>
Python Code:
BATCH_SIZE = 64
EPOCHS = 10
training_images_file = 'gs://mnist-public/train-images-idx3-ubyte'
training_labels_file = 'gs://mnist-public/train-labels-idx1-ubyte'
validation_images_file = 'gs://mnist-public/t10k-images-idx3-ubyte'
validation_labels_file = 'gs://mnist-public/t10k-labels... | <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: Imports
Step3: tf.data.Dataset
Step4: Let's have a look at the data
Step5: Keras model
Step6: Learning Rate schedule
Step7: Train and valid... |
2,689 | <ASSISTANT_TASK:>
Python Code:
import asyncio
import functools
def callback(arg, *, kwarg='default'):
print('callback invoked with {} and {}'.format(arg, kwarg))
async def main(loop):
print('registering callbacks')
loop.call_soon(callback, 1)
wrapped = functools.partial(callback, kwarg='not default')
... | <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 callbacks are invoked in the order they are scheduled.
Step2: In this example, the same callback function is scheduled for several differen... |
2,690 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot
# We have this here to trigger matplotlib's font cache stuff.
# This cell is hidden from the output
import pandas as pd
import numpy as np
import matplotlib as mpl
df = pd.DataFrame([[38.0, 2.0, 18.0, 22.0, 21, np.nan],[19, 439, 6, 452, 226,232]],
... | <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 above output looks very similar to the standard DataFrame HTML representation. But the HTML here has already attached some CSS classes to ea... |
2,691 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import sys
import re
sys.path.append("../utils")
import loaders
employers = loaders.load_employers().set_index("CASE_ID")
cases = loaders.load_cases().set_index("CASE_ID")
cases_basics = cases[[ "DATE_CONCLUDED_FY", "INVEST_TOOL_DESC" ]]\
.join(employers[ "employe... | <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: Note
Step2: Number of H-2–related cases by overall investigation type and fiscal year concluded
Step3: Note
Step4: Data Loading — Certificati... |
2,692 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
print(tf.__version__)
# Some important imports
import math
import numpy as np
import colorsys
import matplotlib.pyplot as plt
%matplotlib inline
import random
import pickle
# If your files are named differently or placed in a different folder, please update lines... | <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: Be aware of version compatibility. This copybook uses functions form Trensorflow package version 1.3.0 and higher.
Step2: Load data
Step3: Bas... |
2,693 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls
import warnings
warnings.filterwarnings('ignore')
me... | <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: So much like every standard data exploration, let us load the data via the Pandas package and play around with it.
Step2: Quick checks on Data ... |
2,694 | <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: Eight Schools の問題
Step2: データ
Step4: モデル
Step5: ベイズ推論
Step6: 上記の集団 avg_effect への縮小が見られます。
Step7: 批評
Step8: 処置効果データとモデルの事後確率予測の間にある残差を見ることがで... |
2,695 | <ASSISTANT_TASK:>
Python Code:
#G = cf.load_seventh_grader_network()
G = nx.read_gpickle('Synthetic Social Network.pkl')
# Who are represented in the network?
G.nodes(data=True)
print(len(G.nodes()))
print(len(G))
# Who is connected to who in the network?
G.edges(data=True)
print(len(G.edges()))
# Let's get a list... | <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: Basic Network Statistics
Step2: Exercise
Step3: Let's now figure out who is connected to who in the network
Step4: Exercise
Step5: Concept
S... |
2,696 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
# TODO: Fill this in based on where you saved the training and testing data
training_file = 'trafficsign/train.p'
validation_file='trafficsign/valid.p'
testing_file = 'trafficsign/test.p'
with open(training_file, mode='rb') as f:
train = pickle.load(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: Step 1
Step2: Include an exploratory visualization of the dataset
Step3: Step 2
Step4: SetUp TensorFlow
Step5: Model Architecture
Step6: Fe... |
2,697 | <ASSISTANT_TASK:>
Python Code:
children = ["sally", "jenny", "latoya", "atalia", "yu"]
text = "s7p9r2o3ut5s3"
data="02:49:35 127.0.0.1 GET /index.html 200\n03:01:06 127.0.0.1 GET /images/logo.gif 304\n03:52:36 127.0.0.1 GET /search.php 200\n04:17:03 127.0.0.1 GET /style.css 200\n05:04:54 127.0.0.1 GET /favicon.ico 40... | <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: Make separate lists of letters and numbers.
Step2: A web server records information about who visits the web pages. Here's an example of the d... |
2,698 | <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 || pip install tensorflow==2.1
import os
import matplotlib.pyplot as plt
import tensorflow as tf
print(f"TensorFlow version: {tf.__... | <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: Configure imports
Step2: The Iris classification problem
Step3: Inspect the data
Step4: From this view of the dataset, notice the following
S... |
2,699 | <ASSISTANT_TASK:>
Python Code:
import sys # system module
import pandas as pd # data package
import matplotlib.pyplot as plt # graphics module
import datetime as dt # date and time module
import numpy as np # foundation for Pa... | <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: Creating and Prepping the Datasets
Step2: Once we were able to confirm that we have access to the Twitter API to access both Hillary Clinton's ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.