Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
7,700 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
def trapz(f, a, b, N):
Integrate the function f(x) over the range [a,b] with N points.
pts = np.linspace(a, b, N + 1)
vals = f(pts)
h = (b - a) / (1.0 * N)
area = .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:
Step2: Trapezoidal rule
Step3: Now use scipy.integrate.quad to integrate the f and g functions and see how the result compares with your trapz functio... |
7,701 | <ASSISTANT_TASK:>
Python Code:
class Base1:
pass
class Base2:
pass
class MultiDerived(Base1, Base2):
pass
class Base1:
def test(self):
print("in Base1 -> test")
class Base2:
def test(self):
print("in Base2 -> test")
class MultiDerived(Base1, Base2):
def test2(self):
super... | <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: Multilevel Inheritance
Step2: In the multiple inheritance scenario, any specified attribute is searched first in the current class. If not foun... |
7,702 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -v -d -u
import pyprind
n = 150000
bar = pyprind.ProgBar(n)
for i in range(n):
# do some computation
bar.update()
n = 1500
perc = pyprind.ProgPercent(n)
for i in range(n):
# do some computation
perc.update()
for i in pyprind.prog_bar(rang... | <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: PyPrind demo
Step2: <a name='bar_basic'></a>
Step3: <a name='percent_basic'></a>
Step4: <a name='percent_basic'></a>
Step5: <a name='info'><... |
7,703 | <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: Quantum circuits on Rigetti devices
Step2: Running this notebook requires the pyQuil QVM and Compiler. If you are running on Google Colab or a ... |
7,704 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -v -m -a "Lilian Besson (Naereen)" -p numpy,numba -g
import numpy as np
eps = 1e-15 #: Threshold value: everything in [0, 1] is truncated to [eps, 1 - eps]
def klBern(x, y):
r Kullback-Leibler divergence for Bernoulli distributions. https://en.wikiped... | <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: KL divergences and KL-UCB indexes, in naive Python
Step3: I will include docstrings and examples only for the naive implementation.
Step5: Bin... |
7,705 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/openai/baselines >/dev/null
!pip install gym >/dev/null
import numpy as np
import random
import gym
from gym.utils import seeding
from gym import spaces
def state_name_to_int(state):
state_name_map = {
'S': 0,
'A': 1,
'B': 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:
Step2: Environment
Step3: Try out Environment
Step4: Baseline
Step5: Train model
Step7: Step 1
Step8: Step 2
Step9: Visualizing Results
Step10: ... |
7,706 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111) # I'll explain the "111" later. Basically, 1 row and 1 column.
ax.set(xlim=[0.5, 4.5], ylim=[-2, 8], title='An Example Axes', ylabel='Y-Ax... | <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: Figures
Step2: Nothing happened! This is because by default mpl will not show anything until told to do so.
Step3: Notice the call to set. Mat... |
7,707 | <ASSISTANT_TASK:>
Python Code:
def mysum(a, b):
return a + b
def mysum(a, b):
내가 정의한 덧셈이다.
인자 a와 b에 각각 두 숫자를 입력받아 합을 되돌려준다.
return a + b
help(mysum)
x = 2
y = 3
z = mysum(x,y)
def print42():
print(42)
def return42():
return 42
b = return42()
b
a = print42()
print(a)
return42()
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:
Step2: 함수정의의 문서화
Step3: 함수 관련 용어
Step4: mysum(x,y)에서 x와 y는 mysum 함수를 호출할 때 사용되는 "인자(argument)" 들이다.
Step5: 주의
Step6: 모듈(Module)
Step7: dir 함수를 이용... |
7,708 | <ASSISTANT_TASK:>
Python Code:
##force not printing
%%capture
%matplotlib inline
!pip install h5py
import numpy as np
import numpy.ma as ma
import h5py
from scipy import sparse
import IPython.display as ipd
import matplotlib.pyplot as plt
import matplotlib.colors as col
from mpl_toolkits.mplot3d import Axes3D
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: 2.1.2) Weights with the average failure of connection
Step2: 2.1) Laplacian Matrix and its spectrum
Step3: 2.2) 2D and 3D Embeddings of the Mi... |
7,709 | <ASSISTANT_TASK:>
Python Code:
!pip install unidecode
# Import TensorFlow >= 1.10 and enable eager execution
import tensorflow as tf
# Note: Once you enable eager execution, it cannot be disabled.
tf.enable_eager_execution()
import numpy as np
import os
import re
import random
import unidecode
import time
path_to_fi... | <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 tensorflow and enable eager execution.
Step2: Download the dataset
Step3: Read the dataset
Step4: Creating dictionaries to map from ch... |
7,710 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import time
%matplotlib inline
# Import Dipy's procedures to process diffusion tensor
import dipy.reconst.dti as dti
# Import Dipy's functions that load and read CENIR data
from dipy.data import fetch... | <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: Downloading data (note 1.7 Gb of data will be downloaded)...
Step2: Estimate a brain mask...
Step3: Fitting the free water DTI model...
Step4:... |
7,711 | <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... |
7,712 | <ASSISTANT_TASK:>
Python Code:
# Exécutez cette cellule !
from IPython.core.display import HTML
styles = "<style>\n.travail {\n background-size: 30px;\n background-image: url('https://cdn.pixabay.com/photo/2018/01/04/16/53/building-3061124_960_720.png');\n background-position: left top;\n background-repeat:... | <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: Définition
Step2: Une liste peut contenir tous types d'objets comme dans l'exemple ci-dessus où maliste1 contient trois éléments, dans l'ordre ... |
7,713 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-3', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <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... |
7,714 | <ASSISTANT_TASK:>
Python Code:
# set up notebook to show plots within the notebook
% matplotlib inline
# Import necessary libraries:
# General utilities:
import os
import sys
from time import time
from scipy.misc import imsave
# Computation:
import numpy as np
import h5py
from skimage import measure
from scipy.cluster.... | <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 the image that will be cleaned
Step2: Make the image file pycroscopy compatible
Step3: Inspect the contents of this h5 data file
Step4: ... |
7,715 | <ASSISTANT_TASK:>
Python Code:
def hara(t, c, a, b, **params):
Hyperbolic Absolute Risk Aversion (HARA).
Notes
-----
For Constant Absolute Risk Aversion (CARA), set a=0; for
Constant Relative Risk Aversion (CRRA), set b=0.
return 1 / (a * c + b)
def cobb_douglas_output(k_tilde, al... | <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: <h1>Textbook example
Step2: To complete the model we need to define some parameter values.
Step3: <h2>Solving the model with pyCollocation</h2... |
7,716 | <ASSISTANT_TASK:>
Python Code:
# library to store and manipulate neural-network input and output data
import numpy as np
# library to graphically display any data
import matplotlib.pyplot as plt
# library to manipulate neural-network models
import torch
import torch.nn as nn
import torch.optim as optim
# the code is co... | <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 the data
Step2: Build the artificial neural-network
Step3: Train the artificial neural-network model
Step4: Evaluate the model
Step5: Pr... |
7,717 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import tensorflow as tf
import numpy as np
import time
import collections
import os
# Import MNIST data with TensorFlow
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets(os.path.join('datasets', 'mnist'), one_hot=True) # load d... | <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: 1st Step
Step2: Question 2
Step3: Question 3
Step4: Question 4
Step5: Question 5
Step6: Question 6
Step7: Question 7
Step8: Question 8
St... |
7,718 | <ASSISTANT_TASK:>
Python Code:
#record atom_name chain x y z occupancy atom_type
# | | | | | | | |
#ATOM 1086 CG LYS A 141 -4.812 9.683 2.584 1.00 26.78 N0
# | | | ... | <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 what the following will do
Step2: Write a program that
|
7,719 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.__version__
x = [1,2]
y = [[4, 1], [2, 2]]
#print np.dot(x, y)
#print np.dot(y, x)
#print np.matmul(x, y)
#print np.inner(x, y)
#print np.inner(y, x)
x = [[1, 0], [0, 1]]
y = [[4, 1], [2, 2], [1, 1]]
#print np.dot(y, x)
#print np.matmul(y, x)
x = np.array([[1, 4],... | <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: Matrix and vector products
Step2: Q2. Predict the results of the following code.
Step3: Q3. Predict the results of the following code.
Step4: ... |
7,720 | <ASSISTANT_TASK:>
Python Code:
a, b = symbols("a b")
r, r0 = symbols("r r0")
f = a*(r-r0) + b
f
dr = symbols("\Delta")
f0, fp = symbols("f_i f_{i+1}")
rm12 = r0 - Rational(1,2)*dr
rp12 = r0 + Rational(1,2)*dr
rp32 = r0 + Rational(3,2)*dr
r1 = r0 + dr
rm12, rp12, rp32
r0, r1
A = simplify(integrate(f*r/(r0*dr), (r, rm... | <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: constraints
Step2: interfaces
Step3: centers
Step4: The analytic forms of the integrals
Step5: Our linear system is now
Step6: And in prett... |
7,721 | <ASSISTANT_TASK:>
Python Code:
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
print("Downloading Colab files")
! shred -u setup_google_colab.py
! wget https://raw.githubusercontent.com/hse-aml/bayesian-methods-for-ml/master/setup_google_colab.py -O setup_google_co... | <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: Grading
Step2: GRADED 1 (3 points)
Step3: Search procedure
Step4: GRADED 2 (3 points)
Step5: Task 3.2. Finding person with the widest smile ... |
7,722 | <ASSISTANT_TASK:>
Python Code:
X, y = make_circles(noise=0.2, factor=0.5, random_state=1);
from sklearn.preprocessing import StandardScaler
X = StandardScaler().fit_transform(X)
from matplotlib.colors import ListedColormap
cm = plt.cm.RdBu
cm_bright = ListedColormap(['#FF0000', '#0000FF'])
ax = plt.subplot()
ax.set_ti... | <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: 好了,现在我们要对这个数据集进行SVM RBF分类了,分类时我们使用了网格搜索,在C=(0.1,1,10)和gamma=(1, 0.1, 0.01)形成的9种情况中选择最好的超参数,我们用了4折交叉验证。这里只是一个... |
7,723 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_digits
digits = load_digits()
digits.keys()
digits.images.shape
print(digits.images[0])
import matplotlib.pyplot as plt
%matplotlib notebook
plt.matshow(digits.images[0], cmap=plt.cm.Greys)
digits.data.shape
digits.target.shape
digits.target
from sklearn... | <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 is always a numpy array (or sparse matrix) of shape (n_samples, n_features)
Step2: Exercises
|
7,724 | <ASSISTANT_TASK:>
Python Code:
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
data_path = mne.datasets.sample.data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
print(evoked)
evoked_l_aud ... | <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 read the evoked object from a file. Check out
Step2: Notice that evoked is a list of
Step3: Let's start with a simple one. We plot e... |
7,725 | <ASSISTANT_TASK:>
Python Code:
from ipyparallel import Client
cl = Client()
cl.ids
cl[:].targets
%%px --noblock
# run a whole cell in non-blocking mode, by default on all engines
# note: the magic has to be at the top of the cell
import time
time.sleep(1)
time.time()
%pxresult
# get the result from the AsyncResult obje... | <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: Dadi should now be imported on all remote engines as well as locally.
Step2: The remote namespace can be checked with
Step3: As can be seen, d... |
7,726 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(filename='images/mdgxs.png', width=350)
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import openmc
import openmc.mgxs as mgxs
# Instantiate some Nuclides
h1 = openmc.Nuclide('H1')
o16 = openmc.Nuclide('O16')
u235 = openmc.... | <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 variety of tools employing different methodologies have been developed over the years to compute multi-group cross sections for certain applic... |
7,727 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
plt.style.use("seaborn-pastel")
%%capture
%pip install -qq --upgrade git+https://github.com/lawrennd/ods
%pip install -qq --upgrade git+https://github.com/SheffieldML/GPy.git
try:
import GPy, pods
except ModuleNotFoundError:
%pip install -qq GPy,
... | <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: CMU Mocap Database
Step2: The data dictionary contains the keys ‘Y’ and ‘skel,’ which represent
Step3: And extra information about the data is... |
7,728 | <ASSISTANT_TASK:>
Python Code:
from pipeline import meso
source_scan = dict(animal_id=25133, session=3, scan_idx=11)
target_scan = dict(animal_id=25133, session=4, scan_idx=13)
pairing = (meso.ScanInfo & source_scan).proj(src_session='session', src_scan_idx='scan_idx') * (meso.ScanInfo & target_scan).proj()
meso.Scan... | <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: Following demonstrates how to find matches between source scan
Step2: Designate the pairing as what needs to be matched
Step3: Now also specif... |
7,729 | <ASSISTANT_TASK:>
Python Code:
%%capture --no-stderr
!pip3 install kfp --upgrade
import kfp.components as comp
dataflow_template_op = comp.load_component_from_url(
'https://raw.githubusercontent.com/kubeflow/pipelines/1.7.0-rc.3/components/gcp/dataflow/launch_template/component.yaml')
help(dataflow_template_op)
!... | <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 the component using KFP SDK
Step2: Sample
Step3: Set sample parameters
Step4: Example pipeline that uses the component
Step5: Compile t... |
7,730 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from threeML import *
# we will need XPSEC models for extinction
from astromodels.xspec import *
# The filter library takes a while to load so you must import it explicitly..
from threeML.plugins.photometry.filter_libra... | <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: Setup
Step2: NOTE
Step3: 3ML filter library
Step4: Build your own filters
Step5: GROND Example
Step6: Model specification
Step7: We comput... |
7,731 | <ASSISTANT_TASK:>
Python Code:
import nltk
from nltk.book import text7 as text
letters = ' '.join(text)
letters = [letter.lower() for letter in letters] # Get the lowercase
symbols = set(letters)
Nletters = len(letters)
Nsymbols = len(symbols)
symbols
print('Number of letters', Nletters)
print('Nymbols', Nsymbols)
fr... | <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 extract the information from the text.
Step2: We get the frequency for all the letters and the most common which turns out to be a spa... |
7,732 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inm', 'inm-cm4-8', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <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... |
7,733 | <ASSISTANT_TASK:>
Python Code:
import ibis
import os
hdfs_port = os.environ.get('IBIS_WEBHDFS_PORT', 50070)
hdfs = ibis.hdfs_connect(host='quickstart.cloudera', port=hdfs_port)
con = ibis.impala.connect(host='quickstart.cloudera', database='ibis_testing',
hdfs_client=hdfs)
ibis.options.interac... | <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: Using scalar aggregates in filters
Step2: We could always compute some aggregate value from the table and use that in another expression, or we... |
7,734 | <ASSISTANT_TASK:>
Python Code:
# Authors: Eric Larson <larson.eric.d@gmail.com>
# License: BSD (3-clause)
from functools import partial
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # noqa, analysis:ignore
import mne
from mne.stats import (ttest_1sam... | <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: Hypothesis testing
Step2: The data averaged over all subjects looks like this
Step3: In this case, a null hypothesis we could test for each vo... |
7,735 | <ASSISTANT_TASK:>
Python Code:
import json
from mdf_forge.forge import Forge
mdf = Forge()
# First, let's aggregate all the nist_xps_db data.
all_entries = mdf.aggregate_sources("nist_xps_db")
print(len(all_entries))
# Now, let's parse out the enery_uncertainty_ev and print the results for analysis.
uncertainties = {}... | <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: aggregate_source - NIST XPS DB
Step2: aggregate - Multiple Datasets
|
7,736 | <ASSISTANT_TASK:>
Python Code:
print("Hello, world")
# Python 2 version
print("Hello, world")
print(“Hello world“)
print("Hello world")
import unicodedata
# Good double quote:
unicodedata.category('"')
# Good single quote
unicodedata.category("'")
# BAD...double quote
unicodedata.category('“')
# BAD...single quote
un... | <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: Not working
Step2: Troubleshooting
Step3: SOLUTION
|
7,737 | <ASSISTANT_TASK:>
Python Code:
from fastai.text import TextLMDataBunch as lmdb
from fastai.text.transform import Tokenizer
import pandas as pd
from pathlib import Path
# note: download the data and place in right directory before running this code!
valid_df = pd.read_hdf(Path('../data/2_partitioned_df/valid_df.hdf'))
... | <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 Data
Step2: Create The DataBunch
Step3: Specify path for saving language model artifacts
Step4: Create The Language Model Data Bunch... |
7,738 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -a 'Sebastian Raschka' -u -d -v -p numpy,pandas,matplotlib,scikit-learn
from sklearn.grid_search import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
from sklearn.datasets 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: Dataset and Estimator Setup
Step2: A. Nested Crossvalidation - Quick Version
Step3: B. Nested Crossvalidation - Manual Approach Printing the M... |
7,739 | <ASSISTANT_TASK:>
Python Code:
PROJECT_ID = "YOUR PROJECT ID"
BUCKET_NAME = "gs://YOUR BUCKET NAME"
REGION = "YOUR REGION"
SERVICE_ACCOUNT = "YOUR SERVICE ACCOUNT"
content_name = "tf-keras-img-cls-dist-multi-worker-cpu-cust-cont"
hostname = "gcr.io"
image_name = content_name
tag = "latest"
custom_container_image_uri =... | <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: Vertex Training using Vertex SDK and Custom Container
Step2: Initialize Vertex SDK
Step3: Create a Vertex Tensorboard Instance
Step4: Option
... |
7,740 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pylab as plt
import padasip as pa
%matplotlib inline
plt.style.use('ggplot') # nicer plots
np.random.seed(52102) # always use the same random seed to make results comparable
def measure_x():
# input vector of size 3
x = np.random.random(3)
... | <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: One Sample Ahead Prediction Example with the NLMS Filter
Step2: For prediction of the variable $d(k)$ it is possible to use any implemented fit... |
7,741 | <ASSISTANT_TASK:>
Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# Retrieve the training and test data
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
# Visualizing the data
import 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: Retrieving training and test data
Step2: Visualize the training data
Step3: Building the network
Step4: Training the network
Step5: Testing
|
7,742 | <ASSISTANT_TASK:>
Python Code:
import pymc3 as pm
with pm.Model() as model:
parameter = pm.Exponential("poisson_param", 1)
data_generator = pm.Poisson("data_generator", parameter)
with model:
data_plus_one = data_generator + 1
parameter.tag.test_value
with pm.Model() as model:
theta = pm.Exponential(... | <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: This is an extra layer of convenience compared to PyMC. Any variables created within a given Model's context will be automatically assigned to t... |
7,743 | <ASSISTANT_TASK:>
Python Code:
import pandas
titanic = pandas.read_csv('data/titanic.csv')
titanic.head()
# basic statistics
titanic[['Age', 'Fare']].describe()
# percentage of missing values
titanic[['Age', 'Fare']].isna().mean()
# imputing missing values with the median
titanic['Age'].fillna(titanic['Age'].median(), ... | <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: This is pandas, and it is super cool
Step2: ...you know you did something wrong
Step3: Why pandas? Why not pure Python?
Step4: Special number... |
7,744 | <ASSISTANT_TASK:>
Python Code:
# 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'
import os
os.environ['BUCKET'] = BUCKET
os.environ['PROJECT'] = PROJ... | <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 Keras model
Step2: Next, define the feature columns. mother_age and gestation_weeks should be numeric.
Step3: We can visualize the DNN ... |
7,745 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'messy-consortium', 'emac-2-53-vol', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contribu... | <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... |
7,746 | <ASSISTANT_TASK:>
Python Code:
# set the midpoint
midpoint = 5
# make two empty lists
lower = []; upper = []
# split the numbers into lower and upper
for i in range(10):
if (i < midpoint):
lower.append(i)
else:
upper.append(i)
print("lower:", lower)
print("upper:", upper)
x = 1 + 2 + 3... | <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: This script is a bit silly, but it compactly illustrates several of the important aspects of Python syntax.
Step2: It is also possible to conti... |
7,747 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import numpy.linalg as la
A = np.array(range(1,5)).reshape(2,2)
determinant_A = la.det(A)
print(A)
print("Determinant is: {}".format(determinant_A)) # Notice the rounding error.
# Let's check it's eigenvalues.
print("The Matrix A has eigenvalues: {}".format([x for x 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: Hmm.... is this related to anything??
Step2: Hmm... Interesting.
Step3: It looks like the eigenvectors are normalized to length 1.
Step4: Hmm... |
7,748 | <ASSISTANT_TASK:>
Python Code:
# import os
# from scripts.hpc05 import HPC05Client
# os.environ['SSH_AUTH_SOCK'] = os.path.join(os.path.expanduser('~'), 'ssh-agent.socket')
# cluster = HPC05Client()
from ipyparallel import Client
cluster = Client()
v = cluster[:]
lview = cluster.load_balanced_view()
len(v)
%%px --loca... | <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 sure to add the correct path like
Step2: Uncomment the lines for the wire that you want to use.
Step3: You can specify the intervals of $... |
7,749 | <ASSISTANT_TASK:>
Python Code:
# Two general packages
import os
import sys
an_integer = 3
print(type(an_integer))
an_integer
# type casting: converting the integer to a float type
float(an_integer)
a_float = 0.2
type(a_float)
a_complex = 1.5 + 0.5j
# get the real or imaginary part of the complex number by using the fu... | <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 python datatypes
Step2: A Python shell can therefore replace your pocket calculator, with the basic arithmetic operations addition, subst... |
7,750 | <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: <table class="tfo-notebook-buttons" align="left">
Step2: Train a tf.keras model for MNIST to be pruned and clustered
Step3: Evaluate the basel... |
7,751 | <ASSISTANT_TASK:>
Python Code:
import os
from tinydb import TinyDB
import pandas as pd
import time
from DashPykpi.kpistats import KpiStats, GitURLs, GraphKPIs
# or... use a list of URLS fetched from the GitURLs class
url_fetch = GitURLs()
urls = url_fetch.urls
print("Retrieved {0} urls.".format(len(urls)))
# These pro... | <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 DB
Step2: Plotting section
Step3: Stacked area chart
|
7,752 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from io import StringIO
commits_raw = pd.read_csv(StringIO(log),
sep="#",
header=None,
names=['file_stats','sha', 'date', 'author'])
commits_raw.head()
commit_metadata = commits_raw[['sha', 'date', 'author']].fillna(method='ffill')
commit_metadata.hea... | <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: With this, we can focus on extracting the information of a commit info row. The next command could be looking a little fr... |
7,753 | <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: 使用分布策略保存和加载模型
Step2: 使用 tf.distribute.Strategy 准备数据和模型:
Step3: 训练模型:
Step4: 保存和加载模型
Step5: 恢复无 tf.distribute.Strategy 的模型:
Step6: 恢复模型后,您可以... |
7,754 | <ASSISTANT_TASK:>
Python Code:
from functools import reduce
find_my_sum = [5, 3, 19, 48, 2, 31, 29]
def sum_func(x, y):
return x + y
total = reduce(sum_func, find_my_sum)
print(total)
word_lst = ["hello", "there", "martha", "how", "are", "you", "doing"]
sentence = reduce(lambda x,y: x + " " + y, word_lst)
nums = ... | <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 look at how it worked. First, we made a list, and defined the function. After we supplied the arguments, the reduce function spreaded as d... |
7,755 | <ASSISTANT_TASK:>
Python Code:
# The keyword categories to help parse website text:
mission = ['mission',' vision ', 'vision:', 'mission:', 'our purpose', 'our ideals', 'ideals:', 'our cause', 'cause:', 'goals', 'objective']
curriculum = ['curriculum', 'curricular', 'program', 'method', 'pedagogy', 'pedagogical', 'appr... | <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: Initializing Python
Step2: Reading in preliminary data
Step3: Descriptive statistics
Step4: What these numbers say about the charter schools ... |
7,756 | <ASSISTANT_TASK:>
Python Code:
import torch
import torch.nn as nn
import torch.optim as optim
from torchtext.legacy.datasets import Multi30k
from torchtext.legacy.data import Field, BucketIterator
import spacy
import numpy as np
import random
import math
import time
SEED = 1234
random.seed(SEED)
np.random.seed(SEED)
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'll set the random seeds for deterministic results.
Step2: Next, we'll create the tokenizers. A tokenizer is used to turn a string containing... |
7,757 | <ASSISTANT_TASK:>
Python Code:
data = [i for i in range(10000)]
data[:10]
def binary_search(data, item):
takes in a sorted list of items, and item to find, and returns item number if item found, -1 if not found
low = 0
high = len(data) - 1
while low <= high:
mid = (low + high) // 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:
Step2: straight forward binary search
Step4: Recursive attempt at binary search
Step5: Comparing the two
Step6: So a straightforward algo is faster.... |
7,758 | <ASSISTANT_TASK:>
Python Code:
import exatomic
exatomic.__version__
exatomic.Universe?
uni = exatomic.Universe()
uni
atom = exatomic.Atom.from_dict({'x': [0.0, 0.0], 'y': [0.0, 0.0], 'z': [-0.34, 0.34],
'symbol': ["H", "H"], 'frame': [0, 0]})
uni = exatomic.Universe(atom=atom)
uni.ato... | <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 help in the Jupyter notebook is easy, just put a "?" after a class or function.
Step2: The Universe object contains all of the informat... |
7,759 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import math
import matplotlib.pyplot as plt
import scipy
from scipy import optimize, integrate
import pints
# Defining variables for use later
k = 1.5 # from equation 3
y0 = 1
times = np.linspace(0,10,50)
# A one-compartment PK model is basically an ODE for an exponent... | <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: Table of Contents
Step5: Now that we have a model and an initial value $y0$, we want to estimate, for any given parameter $k$, $y$ for all valu... |
7,760 | <ASSISTANT_TASK:>
Python Code:
#grade (enter your code in this cell - DO NOT DELETE THIS LINE)
labels = ['Lose', '$1', '$2', '$3 (Win)']
graph.draw_matrix(G, labels)
x0 = np.array([0.0, 1.0, 0.0, 0.0])
# define xstar1
# Print out the probability
print(np.round(xstar1 * 100,2))
#grade (enter your code in this cell ... | <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 can display your matrix as a graph to check your work.
Step2: Suppose the gambler starts with $\$1$ ($100\%$ probability of being in the $\... |
7,761 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import xarray as xr
import cartopy.crs as ccrs
from matplotlib import pyplot as plt
ds = xr.tutorial.open_dataset('rasm').load()
ds
print(ds.xc.attrs)
print(ds.yc.attrs)
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(14,4))
ds... | <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, consider this dataset from the xarray-data repository.
Step2: In this example, the logical coordinates are x and y, while the ph... |
7,762 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pygem as pg
params = pg.params.FFDParameters()
params.read_parameters(filename='../tests/test_datasets/parameters_test_ffd_sphere.prm')
stl_handler = pg.stlhandler.StlHandler()
mesh_points = stl_handler.parse('../tests/test_datasets/test_sphere.stl')
stl_handl... | <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 need to read a parameters file. If does not exist the FFDParameters() class creates a default prm file that you have to edit for your problem... |
7,763 | <ASSISTANT_TASK:>
Python Code:
df_N2 = pd.read_csv("N2.csv", skiprows=1)
N2_isotherm = pyiast.ModelIsotherm(df_N2, loading_key="Loading(mmol/g)",
pressure_key="P(bar)", model='Henry')
pyiast.plot_isotherm(N2_isotherm)
N2_isotherm.print_params()
df_CO2 = pd.read_csv("CO2.csv", 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: binary (CO$_2$/N$_2$ adsorption)
Step2: ternary (CO$_2$/N$_2$/H$_2$O adsorption)
Step3: compare to experiment
|
7,764 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from astropy.table import Table, join
from astropy import units as u
from astropy.coordinates import SkyCoord, search_around_sky
from IPython.display import clear_output
import pickle
import os
from mltier1 import (get_center, get_n_m, estimate_q_m, Field, MultiMLEstima... | <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: General configuration
Step2: Area limits
Step3: Load data
Step4: Filter catalogues
Step5: Additional data
Step6: Sky coordinates
Step7: Cl... |
7,765 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-mr', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <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... |
7,766 | <ASSISTANT_TASK:>
Python Code:
# remove comment to use latest development version
import sys; sys.path.insert(0, '../')
# import libraries
import raccoon as rc
# empty DataFrame
srs = rc.Series()
srs
# with indexes but no data
srs = rc.Series(index=[1, 2, 3])
srs
# with data
srs = rc.Series(data=[4, 5, 6], index=[10, ... | <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: Initialize
Step2: Print
Step3: Setters and Getters
Step4: Select Index
Step5: Set Values
Step6: Get Values
Step7: Set and Get by Location
... |
7,767 | <ASSISTANT_TASK:>
Python Code:
# import necessary packages
from dkrz_forms import form_handler, utils, wflow_handler, checks
from datetime import datetime
from pprint import pprint
# load workflow form object
info_file = "path_to_file.json"
my_form = utils.load_workflow_form(info_file)
# show the workflow steps for th... | <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: demo examples - step by step
Step2: Step 2
Step3: Step 3
Step4: interactive "help"
Step5: Display status of report
Step6: Display status of... |
7,768 | <ASSISTANT_TASK:>
Python Code:
import csv
import numpy as np
fichier_csv = csv.reader(open('train.csv', 'r'))
entetes = fichier_csv.__next__() # on récupère la première ligne qui contient les entetes
donnees = list() # on crée la liste qui va servir à récupérer les données
for ligne in fichier_csv: # ... | <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: Regardons comment sont stockées les données en mémoire
Step2: Regardons maintenant la colonne de l'âge, n'affichons que les 15 premières valeur... |
7,769 | <ASSISTANT_TASK:>
Python Code:
cluster = '<qumulo-cluster>' # Qumulo cluster hostname or IP where you're setting up users
api_user = '<qumulo-user>' # Qumulo api user name
api_password = '<qumulo-password>' # Qumulo api password
base_dir = 'users'
user_name = 'tommy' # the new "user" to set up.
import os
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: Create directory
Step2: Create 20GB Quota
Step3: Create NFS export
Step4: Create SMB share
Step5: Set up snapshot policy
Step6: Clean up ev... |
7,770 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-3', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("... | <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... |
7,771 | <ASSISTANT_TASK:>
Python Code:
# Run the datacleaning notebook to get all the variables
%run 'Teknisk Tirsdag - Data Cleaning.ipynb'
corr = overall_set.corr()
fig = plt.figure(figsize=(20, 16))
ax = sb.heatmap(corr, xticklabels=corr.columns.values,
yticklabels=corr.columns.values,
linew... | <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: Efter at have hentet vores rensede data, hvor vi minder os selv om at vi har
Step2: Hvad vi ser her, er en korrelationsmatrix. Jo mørkere farve... |
7,772 | <ASSISTANT_TASK:>
Python Code:
sns.displot(data=penguins, x="flipper_length_mm", kind="ecdf")
sns.displot(data=penguins, x="flipper_length_mm", kde=True)
sns.displot(data=penguins, x="flipper_length_mm", y="bill_length_mm")
sns.displot(data=penguins, x="flipper_length_mm", y="bill_length_mm", kind="kde")
g = sns.di... | <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: While in histogram mode, it is also possible to add a KDE curve
Step2: To draw a bivariate plot, assign both x and y
Step3: Currently, bivaria... |
7,773 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
n=np.random.standard_normal?
n=np.random.standard_normal
n=np.random.randn
n=np.random.randn
def random_line(m, b, sigma... | <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: Line with Gaussian noise
Step5: Write a function named plot_random_line that takes the same arguments as random_line and creates a random line ... |
7,774 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
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', validation_size=0)
img = mnist.train.images[2]
plt.imshow(img.reshape((28, 28)), cmap='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: Network Architecture
Step2: Training
Step3: Denoising
Step4: Checking out the performance
|
7,775 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
import matplotlib.pyplot as plt
import numpy as np
import os
import tarfile
import urllib
from IPython.display import display, Image
from scipy import ndimage
from sklearn.linear_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:
Step2: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab... |
7,776 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division, print_function
%matplotlib inline
path = "data/17flowers/"
import os, json
from glob import glob
import numpy as np
np.set_printoptions(precision=4, linewidth=100)
from matplotlib import pyplot as plt
# check that ~/.keras/keras.json is set for Theano and ... | <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: Use a pretrained VGG model with our Vgg16 class
Step2: The original pre-trained Vgg16 class classifies images into one of the 1000 categories. ... |
7,777 | <ASSISTANT_TASK:>
Python Code:
import sqlite3
import pandas as pd
from pprint import pprint
from pandas import DataFrame
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
import math
import numpy as np
conn = sqlite3.connect('bicycle.db')
c=conn.cursor(... | <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
Step1: Step2
Step2: Step3
|
7,778 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
# 使用风格seaborn白底
plt.style.use('seaborn-whitegrid')
import numpy as np
x = np.linspace(0, 10, 30)
y = np.sin(x)
plt.plot(x, y, 'o', color='black');
rng=np.random.RandomState(0)
for marker in ['o', '.', ',', 'x', '+', '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: plt.plot制作散点图
Step2: 函数调用中的第三个参数是一个字符,代表用于绘图的符号类型。正如可以指定诸如“-”,“-”之类的选项来控制线条样式一样,标记样式也具有自己的一组短字符串代码。可用符号的完整列表可以在plt.plot文档或Matplotlib的在线文档中找到。大多... |
7,779 | <ASSISTANT_TASK:>
Python Code:
import quantiacsToolbox
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn import svm
%matplotlib inline
%%html
<style>
table {float:left}
</style>
F_AD = pd.read_csv('./tickerData/F_AD.txt')
CLOSE = np.array(F_AD.loc[:252-1, [' CLOSE']])
plt.plot(CLOSE)
... | <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: For developing and testing a strategy, we will use the raw data in the tickerData folder that has been downloaded via the Toolbox's loadData() f... |
7,780 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'sandbox-2', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("na... | <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... |
7,781 | <ASSISTANT_TASK:>
Python Code:
# Tell ipython to load the matplotlib environment.
%matplotlib inline
import itertools
import pandas
import numpy
import seaborn
import matplotlib.pyplot
import tabulate
_DATA_FILEPATH = 'datagovdatasetsviewmetrics.csv'
_ROTATION_DEGREES = 90
_BOTTOM_MARGIN = 0.35
_COLOR_THEME = 'coolwar... | <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 configurables
Step2: We use pandas to read, group, and sort our data
Step3: Use the tabulate library to render a nice table. This is one o... |
7,782 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <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: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step10: Tokenize Punctuation
Step12: Preprocess all th... |
7,783 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division # Python 2 compatibility if needed
# Builtin implementation, as a reference
from itertools import permutations as itertools_permutations
itertools_permutations([1, 2])
for p in itertools_permutations([1, 2]):
print(p)
list(itertools_... | <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. Reference implementation
Step2: This will obviously be the quickest implementation, and there is no hope of beating it with pure Python (in ... |
7,784 | <ASSISTANT_TASK:>
Python Code:
# sklearn
# classes_ ; 타겟 Y 의 클래스(라벨)
# class_count_ ; 타켓 Y 의 값이 특정한 클래스인 표본 데이터의 수
# feature_count_ ; 1) 베르누이 분포 ;
# 2) 다항분포 ;
# class_prior_ (가우시안 정규분포) ; P(Y)
# class_log_prior_ (베르누이, 다항 분포) ; log P(Y)
# theta_, sigma_ (가우시안 정규분포)
# feature_log_prob_ (베르누이,... | <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) 베르누이 분포 나이브 베이즈 모형
Step2: 2) 다항 분포 나이브 베이즈 모형
Step3: 3) 가우시안 정규 분포 나이브 베이즈 모형
|
7,785 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a = np.array([[10,50,30],[60,20,40]])
result = np.unravel_index(a.argmax(), a.shape)
<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:
|
7,786 | <ASSISTANT_TASK:>
Python Code:
from theano.sandbox import cuda
%matplotlib inline
import utils; reload(utils)
from utils import *
from __future__ import division, print_function
#path = "data/fish/sample/"
path = "data/fish/"
batch_size=64
batches = get_batches(path+'train', batch_size=batch_size)
val_batches = get_bat... | <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: Sometimes it's helpful to have just the filenames, without the path.
Step2: Setup dirs
Step3: Basic VGG
Step4: Precompute convolutional outpu... |
7,787 | <ASSISTANT_TASK:>
Python Code:
from pyoptools.all import *
from numpy import pi
L1=SphericalLens(radius=25,curvature_s1=1./100.,curvature_s2=-1./100,
thickness=10,material=material.schott["N-BK7"])
S=System(complist=[(L1,(0,0,100),(0,0,0))],n=1)
R=[Ray(pos=(0,0,0),dir=(0,.2,1),wavelength=.650),
Ray(... | <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: Spherical lens
Step2: Besides the SphericalLens, pyOptools has classes to create the following lenses
Step3: After the rays propagation is fin... |
7,788 | <ASSISTANT_TASK:>
Python Code::
model = Net().to(device)
optimizer = optim.SGD(model.parameters(), lr=0.01, momentum=0.9)
EPOCHS = 15
train_max=0
test_max=0
for epoch in range(EPOCHS):
print("EPOCH:", epoch)
train(model, device, train_loader, optimizer, epoch)
test(model, device, test_loader)
print(f"\nMaxi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
7,789 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function # only necessary if using Python 2.x
import matplotlib.pyplot as plt
import numpy as np
from pyshtools.shclasses import SHCoeffs, SHGrid, SHWindow
# Spherical harmonic coefficients are stored as a numpy array of
# dimension (2, lma... | <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 a single spherical harmonic function
Step2: The coefficient class provides functions and methods that stay completely in coefficient space... |
7,790 | <ASSISTANT_TASK:>
Python Code:
!pip install google-cloud-bigquery
%load_ext google.cloud.bigquery
import os
PROJECT = 'data-science-on-gcp-180606' # REPLACE WITH YOUR PROJECT ID
BUCKET = 'data-science-on-gcp' # REPLACE WITH YOUR BUCKET NAME
REGION = 'us-central1' # REPLACE WITH YOUR BUCKET REGION e.g. us-central1
os.e... | <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: Setup
Step3: <h3> Exploration using BigQuery </h3>
Step4: <h3> Set up views in Spark SQL </h3>
Step5: Set up the schema to read in the CSV fi... |
7,791 | <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 раз. Оценим вероя... |
7,792 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.2,<2.3"
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
phoebe.devel_on() # CURRENTLY REQUIRED FOR WD-STYLE MESHING (WHICH IS EXPERIMENTAL)
logger = phoebe.logger()
b = phoebe.default_binary()
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: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details.
Step2: Changing Meshing Options
... |
7,793 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pylab as pl
def gcd(a,b):
if a<b:
a,b = b,a
while b>0:
a,b=b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
# amplitudes
A = np.array([1,1])
# frequencies
f = np.array([3,5])
# phased difference
delta = 0*np.pi/4
# time periods
T = 1/f
# the ti... | <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 need to calculate the LCM of the time periods for the two oscillators. Hence we define the LCM of two integers.
Step2: The parameters o... |
7,794 | <ASSISTANT_TASK:>
Python Code:
from openhunt.mordorutils import *
spark = get_spark()
mordor_file = "https://raw.githubusercontent.com/OTRF/mordor/master/datasets/small/windows/persistence/host/empire_wmi_local_event_subscriptions_elevated_user.zip"
registerMordorSQLTable(spark, mordor_file, "mordorTable")
df = spark... | <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 & Process Mordor Dataset
Step2: Analytic I
Step3: Analytic II
Step4: Analytic III
Step5: Analytic IV
|
7,795 | <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)
#target_text
#view_sentence_range = (0, 10)
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: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
7,796 | <ASSISTANT_TASK:>
Python Code:
ls data/arabian_nights
f = open('data/arabian_nights/848.txt', 'r')
text = f.read()
f.close()
print(text[:500])
with open('data/arabian_nights/848.txt', 'r') as f:
text = f.read()
print(text[:500])
import os
filenames = os.listdir('data/arabian_nights')
print(len(filenames))
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: As you can see, this folder holds a number of plain text files, ending in the .txt extension. Let us open a random file
Step2: Here, we use the... |
7,797 | <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 tarfile
cifar10_dataset_folder_path = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset if ... | <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... |
7,798 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.1,<2.2"
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_dataset('lc', times=np.linspace(0,1,101), dataset='lc01')
print(b['exptime'])
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: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details.
Step2: Relevant Parameters
Step3... |
7,799 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
# Add your filename and uncomment the following line:
Image(filename='MarijuanaUsage.png')
<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: Graphical excellence and integrity
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.