Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
7,200 | <ASSISTANT_TASK:>
Python Code:
%reset -sf
import logging
import os
import torch
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.optim as optim
pyro.set_rng_seed(1)
assert py... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bayesian Linear Regression
Step2: SVI
Step3: Let us observe the posterior distribution over the different latent variables in the model.
Step4... |
7,201 | <ASSISTANT_TASK:>
Python Code:
import openturns as ot
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
%load_ext autoreload
%autoreload 2
random_state = 123
np.random.seed(random_state)
from depimpact.tests import func_sum
help(func_sum)
dim = 2
margins = [ot.Normal()]*dim
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Additive model
Step2: Dimension 2
Step3: Copula families
Step4: Estimations
Step5: First, we compute the quantile at independence
Step6: We... |
7,202 | <ASSISTANT_TASK:>
Python Code:
%%%timeit
maths = list()
for x in range(10):
maths.append(x**x)
%%%timeit
maths = [x**x for x in range(10)]
# maths
import matplotlib.pyplot as plt
import math
import numpy as np
%matplotlib inline
t = np.arange(0., 5., 0.2)
plt.plot(t, t, 'r--', t, t**2, 'bs')
<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: We can make pretty graphs
|
7,203 | <ASSISTANT_TASK:>
Python Code:
# Import spaCy and load the language library
import spacy
nlp = spacy.load('en_core_web_sm')
# Create a string that includes opening and closing quotation marks
mystring = '"We\'re moving to L.A.!"'
print(mystring)
# Create a Doc object and explore tokens
doc = nlp(mystring)
for token 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: <img src="../tokenization.png" width="600">
Step2: <font color=green>Note that the exclamation points, comma, and the hyphen in 'snail-mail' ar... |
7,204 | <ASSISTANT_TASK:>
Python Code:
# 1 Read dataset
cols = [
'clump thickness',
'uniformity of cell size',
'uniformity of cell shape',
'marginal adhesion',
'single epithelial cell size',
'bare nuclei',
'bland chromatin',
'normal nucleoli',
'mitoses',
'cl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Clean data
Step2: There is no missing data in the dataset.
Step3: Warning.
Step4: Note that 402 rows have the mode value of '1'.
Step5: Mode... |
7,205 | <ASSISTANT_TASK:>
Python Code:
import osmdigest.digest as digest
import os
#filename = os.path.join("//media", "disk", "OSM_Data", "isle-of-wight-latest.osm.xz")
filename = os.path.join("..", "..", "..", "Data", "isle-of-wight-latest.osm.xz")
building_node_ids = []
addr_node_ids = []
for x in digest.parse(filename):
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Nodes tagged as buildings / with addresses
Step2: Same for ways
Step3: Finally for relations
Step4: Process to a pandas dataframe
Step5: Do ... |
7,206 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, alpha
from commons import *
from matrix_functions import *
from sequences import *
import functions_catalog
init_printing()
m=8
C = define(let=Symbol(r'\mathcal{{C}}_{{ {} }}'.format(m)),
be=Matr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Catalan array $\mathcal{C}$
Step2: power function
Step3: inverse function
Step4: sqrt function
Step5: expt function
Step6: log function
Ste... |
7,207 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from prophet import Prophet
df = pd.read_csv('../examples/example_wp_log_peyton_manning.csv')
df.head()
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=365)
future.tail()
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper... | <SYSTEM_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 fit the model by instantiating a new Prophet object. Any settings to the forecasting procedure are passed into the constructor. Then you ca... |
7,208 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy.random as rng
import pylab as pl
import autograd.numpy as np
from autograd import grad
def sigmoid(phi):
return 1.0/(1.0 + np.exp(-phi))
def calc_outputs(params):
# Sigmoid perceptron ('logistic regression')
XX = X - params['m']
phi = np.dot... | <SYSTEM_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 up an 'on-model' dataset
Step2: Learning, starting from random weights and bias.
|
7,209 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os, subprocess, mplleaflet, re, json
import xml.etree.ElementTree as ET
import pandas as pd
import geopandas as gpd
import seaborn as sns
from pymongo import MongoClient
from pprint import pprint
from collections import defaultdict
from shapely.geometry import sh... | <SYSTEM_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, Let's check the size of our data file.
Step2: I will convert the XML file into GeoJSON format then import it to a mongo database. It's s... |
7,210 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import fetch_mldata
from sklearn.utils import shuffle
mnist = fetch_mldata('MNIST original', data_home='./mnist_data')
X, y = shuffle(mnist.data[:60000], mnist.target[:60000])
X_small = X[:100]
y_small = y[:100]
# Note: using only 10% of the training data
X_large = 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: Instantiate the estimator and the SearchCV objects
Step2: Fit the GridSearchCV object locally
Step3: Everything up to this point is what you w... |
7,211 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from numpy import genfromtxt
from matplotlib.font_manager import FontProperties
from pylab import rcParams
fontP = FontProperties()
fontP.set_size('small')
def loadData(filename):
return genfromtxt(filename, delimit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: G-force Control
Step2: Pretty cool! Once it passes 100m altitude the controller starts, the throttle controls for gforce, bringing it oscillati... |
7,212 | <ASSISTANT_TASK:>
Python Code:
# 数値計算やデータフレーム操作に関するライブラリをインポートする
import numpy as np
import pandas as pd
# URL によるリソースへのアクセスを提供するライブラリをインポートする。
# import urllib # Python 2 の場合
import urllib.request # Python 3 の場合
# 図やグラフを図示するためのライブラリをインポートする。
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.ticker as ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h3 STYLE="background
Step2: <h3 STYLE="background
Step3: <h3 STYLE="background
Step4: matplotlib で定義済みのカラーマップで彩色できます。次の例では、quality に応じて cool... |
7,213 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
from pprint import pprint
import shutil
import subprocess
import urllib.request
import h5py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm
from matplotlib.patches import Rectangle
import openmc.data
openmc.data.atomic_mass('Fe54')
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:
Step1: Physical Data
Step2: The IncidentNeutron class
Step3: Cross sections
Step4: Cross sections for each reaction can be stored at multiple temper... |
7,214 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'inpe', 'sandbox-2', 'ocean')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_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,215 | <ASSISTANT_TASK:>
Python Code::
from sklearn.cluster import KMeans
# Step 1: Initalise kmeans clustering model for 5 clusters and
# fit on training data
k_means = KMeans(n_clusters=5,
random_state=101)
k_means.fit(X_train)
# Step 2: Predict cluster for training and test data and add results
# as a col... | <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,216 | <ASSISTANT_TASK:>
Python Code:
# Import py_entitymatching package
import py_entitymatching as em
import os
import pandas as pd
# Get the datasets directory
datasets_dir = em.get_install_path() + os.sep + 'datasets'
# Get the paths of the input tables
path_A = datasets_dir + os.sep + 'person_table_A.csv'
path_B = datas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then, read the (sample) input tables for blocking purposes
Step2: Removing Features from Feature Table
|
7,217 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'snu', 'sandbox-1', '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,218 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pydotplus
import numpy as np
import pprint
from sklearn import metrics
from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn import tree
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: Check out the data
Step3: Step 2
Step4: Design the single function to get the key tree information
Step5: Decision Tree 0 (Fir... |
7,219 | <ASSISTANT_TASK:>
Python Code:
from pd_grid import PD_Model
import random
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec
%matplotlib inline
bwr = plt.get_cmap("bwr")
def draw_grid(model, ax=None):
'''
Draw the current state of the grid, with Defecting agents in red
and Cooper... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Helper functions
Step2: Sequential Activation
Step3: Random Activation
Step4: Simultaneous Activation
|
7,220 | <ASSISTANT_TASK:>
Python Code:
import IPython
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import os
import sys
import pickle
import scipy as sp
from scipy import stats
from pandas import Series, DataFrame
from datetime import datetime, timedelta
%matplotlib inline
matplotlib... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import modules containing own functions
Step2: List and set the working directory and the directories to write out data
Step3: List of the re... |
7,221 | <ASSISTANT_TASK:>
Python Code:
replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
field_name ::= arg_name ("." attribute_name | "[" element_index "]")*
arg_name ::= [identifier | integer]
attribute_name ::= identifier
element_index ::= integer | index_string
index_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Python 字符串的格式化
Step2: 我将其准换成铁路图的形式,(可能)更直观一些:
Step3: 除此之外,就像在0x05 函数参数与解包中提到的一样,format() 中也可以直接使用解包操作:
Step4: 在模板中还可以通过 .identifier 和 [key] 的... |
7,222 | <ASSISTANT_TASK:>
Python Code:
import os
# The Google Cloud Notebook product has specific requirements
IS_GOOGLE_CLOUD_NOTEBOOK = os.path.exists("/opt/deeplearning/metadata/env_version")
# Google Cloud Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_GOOGLE_CLOUD_NOTEBOOK:
USER_FLAG... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restart the kernel
Step2: Before you begin
Step3: Otherwise, set your project ID here.
Step4: Timestamp
Step5: Authenticate your Google Clou... |
7,223 | <ASSISTANT_TASK:>
Python Code:
separate_sf(b.gsw.cat['logMstar'],b.gsw.cat['logSFR'],m1=9.,m2=11,ms_slope=0.592,ms_intercept=-6.05,dm=.2)
logmass = 10.8
yms = -.1968999*logmass**2+4.4186588*logmass-24.607396
print("offset b/w MS and sSFR=-11.5 = {:.3f} ".format(yms- (logmass-11.5)))
print("offset relative to MS 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:
Step1: Using sample from the paper, with B/T cut
Step2: Using GSWLC, cut in redshift only
Step3: how to pick the mass where we define the offset rela... |
7,224 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
example = pd.DataFrame(data=np.array([['George', 'Male', '14','Novice', 'Pristina'],
['Mary', 'Female', '14', 'Intermediate', 'Gjilan'],
['Jimmy','Male', '15', 'Novice', 'Kameni... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Alright so lets load up our actual data. First input the filepath for the formated and complete CSV file after filepath = ' '
Step2: Lets take... |
7,225 | <ASSISTANT_TASK:>
Python Code:
print("Hello World!")
str01 = "Hello World!"
str02 = "22"
str03 = "This is so c00l!"
print(str01, str02, str03)
print(type(str02))
children = 5
type(children)
new_children = float(children)
type(new_children)
stringy_kids = str(children)
type(stringy_kids)
text01 = "The name's Bond, J... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: "Hello World!" was the string. Absolutely any character can be a string, including numbers, as long as they are within single, double, or triple... |
7,226 | <ASSISTANT_TASK:>
Python Code:
from ROP import *
#Takes a little bit, wait a while.
#ROP Number syntax: ###
#Eye Drop syntax: HH MM HH MM HH MM
#Exam Syntax: HH MM HH MM
print 'Baseline Averages\n', 'NIRS :\t', avg0NIRS, '\nPI :\t',avg0PI, '\nSpO2 :\t',avg0O2,'\nPR :\t',avg0PR,
print resultdrops1
print resultdrops2
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Baseline Average Calculation
Step2: First Eye Drop Avg Every 10 Sec For 5 Minutes
Step3: Second Eye Drop Avg Every 10 Sec For 5 Minutes
Step4:... |
7,227 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os, sys
sys.path.append(os.path.abspath('../../main/python'))
import numpy as np
import matplotlib.pyplot as plt
import thalesians.tsa.numpyutils as npu
import thalesians.tsa.processes as proc
import thalesians.tsa.randomness as rnd
import thalesians.tsa.simulat... | <SYSTEM_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 some Python modules
Step2: Ito processes
Step3: It can then be approximated with a stochastic time discrete approximation, such ... |
7,228 | <ASSISTANT_TASK:>
Python Code:
# Use the chown command to change the ownership of the repository.
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
# Ensure the right version of Tensorflow is installed.
!pip freeze | grep tensorflow==2.3.0 || pip install tensorflow==2.3.0
# Install the required numpy ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kindly ignore the deprecation warnings and incompatibility errors.
Step2: Kindly ignore the deprecation warnings and incompatibility errors.
St... |
7,229 | <ASSISTANT_TASK:>
Python Code:
#imports
from __future__ import division
import pandas as pd
import numpy as np
from scipy import stats
import statsmodels.api as sm
import matplotlib.pyplot as plt
import pylab as pl
%matplotlib inline
import seaborn as sns
#Read in data from source
df_raw = pd.read_csv("../assets/admi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step 1
Step1: Step 2
Step2: Questions
Step3: Answer
Step4: Question 3. Why would GRE have a larger STD than GPA?
Step5: Answer
Step6: Question 5. ... |
7,230 | <ASSISTANT_TASK:>
Python Code:
import openpnm as op
%config InlineBackend.figure_formats = ['svg']
import matplotlib.pyplot as plt
pn = op.network.Cubic(shape=[20, 20, 20], spacing=100)
geo = op.geometry.SpheresAndCylinders(network=pn, pores=pn.Ps, throats=pn.Ts)
print(geo)
fig = plt.hist(geo['pore.diameter'], bins=... | <SYSTEM_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 spacing of the above network is in um for this example to make values easier to read, but in general you should always use SI
Step2: As can... |
7,231 | <ASSISTANT_TASK:>
Python Code:
# The main function
import karps as ks
# The standard library
import karps.functions as f
# Some tools to display the computation process:
from karps.display import show_phase
def harmonic_mean(col):
count = f.as_double(f.count(col))
inv_sum = 1.0/f.sum(1.0/col)
return inv_su... | <SYSTEM_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 is the definition of the harmonic mean, which is a simple function. Given a column containing floating point values, it is defined as such
... |
7,232 | <ASSISTANT_TASK:>
Python Code:
# Basic imports
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import scipy.optimize as spo
import sys
from time import time
from sklearn.metrics import r2_score, median_absolute_error
%matplotlib inline
%pylab inline
pylab.rcParams[... | <SYSTEM_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 use the market simulator with the q-learning agent it must be possible to call it with custom data, stored in RAM. Let's try that.
Step2: Th... |
7,233 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
plt.scatter(np.random.randn(100), np.random.randn(100), c='g', s=50, marker='+', alpha=0.7)
plt.xlabel('Random x values')
plt.ylabel('Random y values')
plt.title('Randomness Fun!')
plt.hist(np.random.randn(100), bins=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Scatter plots
Step2: Histogram
|
7,234 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
import cv2 # for grayscale and normalize
# TODO: Fill this in based on where you saved the training and testing data
training_file ='traffic-signs-data/train.p'
validation_file='traffic-signs-data/valid.p'
testing_file = 'traffic-signs-data/test.p'
with o... | <SYSTEM_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: Model Architecture
Step5: A validation set can be use... |
7,235 | <ASSISTANT_TASK:>
Python Code:
!pipeline --help
!pipeline init --ip 127.0.0.1 --port 9380
from pipeline.backend.pipeline import PipeLine
pipeline_upload = PipeLine().set_initiator(role='guest', party_id=9999).set_roles(guest=9999)
partition = 4
dense_data_guest = {"name": "breast_hetero_guest", "namespace": f"expe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Assume we have a FATE Flow Service in 127.0.0.1
Step2: upload data
Step3: Make a pipeline instance
Step4: Define partitions for data storage
... |
7,236 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import antipackage
import github.ellisonbg.misc.vizarray as va
def checkerboard(size):
Return a 2d checkboard of 0.0 and 1.0 as a NumPy array
the_checkerboard=np.zeros((size,size), dt... | <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: Checkerboard
Step3: Use vizarray to visualize a checkerboard of size=20 with a block size of 10px.
Step4: Use vizarray to visualize a checkerb... |
7,237 | <ASSISTANT_TASK:>
Python Code:
arr = io.imread('0mm_cam0.tif')
print 'Image has been loaded as a 2d numpy array with ', arr.shape, 'rows and columns. Datatype =', arr.dtype
io.implot('0mm_cam0.tif')
cd ../particle_images/
io.implot('TomoImg_cam0_a00001.tif', cmap='jet')
io.imsave('raw_image_data.txt', arr)
import 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: Plotting images
Step2: One can also use different matplotlib colormaps while plotting the images as demonstrated below.
Step3: Saving arrays a... |
7,238 | <ASSISTANT_TASK:>
Python Code:
#Importamos las librerías utilizadas
import numpy as np
import pandas as pd
import seaborn as sns
#Mostramos las versiones usadas de cada librerías
print ("Numpy v{}".format(np.__version__))
print ("Pandas v{}".format(pd.__version__))
print ("Seaborn v{}".format(sns.__version__))
#Mostram... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Respuesta del sistema
Step2: Cálculo del polinomio
Step3: El polinomio caracteristico de nuestro sistema es
Step4: En este caso hemos estable... |
7,239 | <ASSISTANT_TASK:>
Python Code:
datafolder = "data"
import os
has_soi = sum([name.endswith("soi.dat") for name in os.listdir(datafolder)])
has_recruit = sum([name.endswith("recruit.dat") for name in os.listdir(datafolder)])
if (has_soi and has_recruit):
print 'You are ready to go'
else:
print 'Your current dir... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Determining wether the folder holds the expected data files
Step2: And telling you if the folder is correct
Step3: Imports
Step4: 2 - Data lo... |
7,240 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from numpy import *
from scipy.integrate import odeint
from matplotlib.pyplot import *
ion()
def RM(y, t, r, K, a, h, e, d):
return array([ y[0] * ( r*(1-y[0]/K) - a*y[1]/(1+a*h*y[0]) ),
y[1] * (e*a*y[0]/(1+a*h*y[0]) - d) ])
t = arange(0, 1000, .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: For the parameters chosen above, the long-term (asymptotic) solution is a fixed point. Let's see this in the phase space, that is, the space of ... |
7,241 | <ASSISTANT_TASK:>
Python Code:
%reload_ext autoreload
%autoreload 2
import numpy as np
import os
import pandas as pd
import random
import scipy
from scipy.stats import zscore
# interactive
from ipywidgets.widgets import interact, IntSlider, FloatSlider
from IPython.display import display
from sklearn.discriminant_analy... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Laden der Merkmalsmatrix
Step2: Produktweise Sortierung der Daten
Step3: Auswahl des Produtes durch Schieberegler implementieren
Step4: Auswa... |
7,242 | <ASSISTANT_TASK:>
Python Code:
def swap(A, i, j):
A[i], A[j] = A[j], A[i]
def sink(A, k, n):
while 2 * k + 1 <= n:
j = 2 * k + 1
if j + 1 <= n and A[j] > A[j + 1]:
j += 1
if A[k] < A[j]:
return
swap(A, k, j)
k = j
def heap_sort(A):
n = len(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 procedure sink takes three arguments.
Step2: The function call heapSort(A) has the task to sort the array A and proceeds in two phases.
Ste... |
7,243 | <ASSISTANT_TASK:>
Python Code:
# Authors: Marijn van Vliet <w.m.vanvliet@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
from matplotlib import pyplot as plt
print(__doc__)
# Setup for reading the raw data
data_pat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Apply different EEG referencing schemes and plot the resulting evokeds.
|
7,244 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
from sympy import init_printing
from sympy import S
from sympy import sin, cos, tanh, exp, pi, sqrt, log
from boutdata.mms import x, y, z, t
from boutdata.mms import DDX
import os, sys
# If we add to sys.path, then it must be an absolute path
common_dir = os.path.absp... | <SYSTEM_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: Define the variables
Step3: Plot
Step4: Print the variables in BOUT++ format
|
7,245 | <ASSISTANT_TASK:>
Python Code:
import bifacial_radiance
import os
from pathlib import Path
testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP'/ 'Tutorial_08')
if not os.path.exists(testfolder):
os.makedirs(testfolder)
simulationName = 'tutorial_8'
moduletype = "test-module"
albedo = 0.25... | <SYSTEM_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='step2'></a>
|
7,246 | <ASSISTANT_TASK:>
Python Code:
from sklearn.feature_selection import VarianceThreshold
X = [[0, 2, 0, 3],
[0, 1, 4, 3],
[0, 1, 1, 3]]
selector = VarianceThreshold()
selector.fit_transform(X)
import pandas as pd
import seaborn as sns
%matplotlib inline
from sklearn.datasets import load_iris
X, y = load_iris(re... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question
|
7,247 | <ASSISTANT_TASK:>
Python Code:
%%bash
git clone https://github.com/amueller/introduction_to_ml_with_python.git
from scipy.misc import imread
<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: Now go back to your Jupyter Hub file list, to access the code examples.
|
7,248 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from gprMax.waveforms import Waveform
from tools.plot_source_wave import check_timewindow, mpl_plot
w = Waveform()
w.type = 'ricker'
w.amp = 1
w.freq = 25e6
timewindow = 300e-9
dt = 8.019e-11
timewindow, iterations = check_timewindow(timewindow, dt)
plt = mpl_plot(w, 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: Plotting a user-defined waveform
Step2: Determining a spatial resolution
|
7,249 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import scipy.io
import scipy.misc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from PIL import Image
from nst_utils import *
import numpy as np
import tensorflow as tf
%matplotlib inline
model = load_vgg_model("pretrained-model/imagenet-vgg-ve... | <SYSTEM_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 - Problem Statement
Step2: The model is stored in a python dictionary where each variable name is the key and the corresponding value is a te... |
7,250 | <ASSISTANT_TASK:>
Python Code:
%%HTML
<img src="https://imgs.xkcd.com/comics/bun_alert.png" width=500></img>
%%HTML
<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Pay no mind.... <a href="https://t.co/mnIPHJXE1h">pic.twitter.com/mnIPHJXE1h</a></p>— David Beazley (@dabeaz) <a href="https:... | <SYSTEM_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 Problem
Step2: Our path...
Step3: Takeaways
Step4: Takeaways
Step5: Takeaways
Step6: Conclusion
Step7: NOTE
Step8: Take-aways
Step9: ... |
7,251 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# importing Qiskit
from qiskit import Aer, IBMQ
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import available_backends, execute, register, get_backend, compile
from qiskit.tools impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: In the sub-circuit above, the three ccx gates on the right are used to compute $( q_1 \wedge \neg q_2 \wedge q_3)$ and write the result to $q_5$... |
7,252 | <ASSISTANT_TASK:>
Python Code:
string_number = "1066"
integer = int(string_number)
print(int(integer))
print(type(integer)) # <-- the type function returns the type of the object passed in eg 1 is an integer, "hi" is a string, etc.
int("1111", base = 2)
int(6.99999999999999)
a = 10
b = 5
print(a + b) # addition
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: The int() function also takes an optional argument base as well. So for example “1111”, base=2 will treat “1111” as a binary number and will re... |
7,253 | <ASSISTANT_TASK:>
Python Code:
import femagtools.machine
p = 4
r1 = 0.0806
ls = 0.0
ld = [0.0014522728, 0.0014522728]
lq = [0.0038278836, 0.0032154]
psim = [0.11171972, 0.11171972]
i1 = [80.0]
beta = [-41.1, 0]
pm = femagtools.machine.PmRelMachineLdq(3, p, psim, ld, lq, r1, beta, i1, ls)
pm.iqd_torque(170)
pm.torque_... | <SYSTEM_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 example we can calculate the iq and id current for a given torque of 170 Nm
Step2: Or reversely
Step3: For the transformation of i1-beta a... |
7,254 | <ASSISTANT_TASK:>
Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
with open('anna.txt', 'r') as f:
text=f.read()
vocab = sorted(set(text))
vocab_to_int = {c: i for i, c in enumerate(vocab)}
int_to_vocab = dict(enumerate(vocab))
encoded = np.array([vocab_to_int... | <SYSTEM_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'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the chara... |
7,255 | <ASSISTANT_TASK:>
Python Code:
def sparsity_to_x_intercept(d, p):
sign = 1
if p > 0.5:
p = 1.0 - p
sign = -1
return sign * np.sqrt(1-scipy.special.betaincinv((d-1)/2.0, 0.5, 2*p))
D = 32
N = 1000000
sparsity = 0.1
intercept = sparsity_to_x_intercept(D, sparsity)
model = nengo.Network()
with... | <SYSTEM_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 thing to note is that if we want the same thing but for volume (i.e. for representing points that are inside the hypersphere), then we can d... |
7,256 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
%pylab inline
import matplotlib.pylab as plt
import numpy as np
from distutils.version import StrictVersion
import sklearn
print(sklearn.__version__)
assert StrictVersion(sklearn.__version__ ) >= StrictVersion('0.18.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: Solving Iris with Neural Networks
Step2: The artificial Neuron
Step3: This is the output of all 3 hidden neurons, but what we really want is a... |
7,257 | <ASSISTANT_TASK:>
Python Code:
x_train,y_train,x_valid,y_valid = get_data()
x_train,x_valid = normalize_to(x_train,x_valid)
train_ds,valid_ds = Dataset(x_train, y_train),Dataset(x_valid, y_valid)
nh,bs = 50,512
c = y_train.max().item()+1
loss_func = F.cross_entropy
data = DataBunch(*get_dls(train_ds, valid_ds, bs), c)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Batchnorm
Step2: We can then use it in training and see how it helps keep the activations means to 0 and the std to 1.
Step3: Builtin batchnor... |
7,258 | <ASSISTANT_TASK:>
Python Code:
from collections import OrderedDict
d = OrderedDict()
d['foo'] = 1
d['bar'] = 2
d['spam'] = 3
d['grok'] = 4
# Outputs "foo 1", "bar 2", "spam 3", "grok 4"
for key in d:
print(key, d[key])
import json
json.dumps(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: An OrderedDict can be particularly useful when you want to build a mapping that you may want to later serialize or encode into a different forma... |
7,259 | <ASSISTANT_TASK:>
Python Code:
pickle_dir = '../pickle_files/'
odds_file = 'odds.pkl'
matches_file = 'matches.pkl'
import numpy as np # numerical libraries
import scipy as sp
import pandas as pd # for data analysis
import pandas.io.sql as sql # for interfacing with MySQL database
from scipy import linalg # linear alge... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I. <a name="logisticregression_1d"> One-dimensional Logistic regression
Step2: Load the data.
Step3: Separate data into training, validation,... |
7,260 | <ASSISTANT_TASK:>
Python Code:
import networkx as nx
# Kode Anda di sini
# Kode Anda di sini
import numpy as np
class ExplodingGame(object):
def __init__(self, N):
self.N = N
# state = (player, number)
def start(self):
return (+1, 1)
def actions(self, state):
player, number = 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: Soal 1.2.a (2 poin)
Step2: Soal 1.3 (2 poin)
Step3: Soal 2.1 (2 poin)
Step4: Soal 2.2 (3 poin)
Step5: Soal 2.3 (2 poin)
Step6: Soal 2.4 (3 ... |
7,261 | <ASSISTANT_TASK:>
Python Code:
from logbook import INFO, WARNING, DEBUG
import warnings
warnings.filterwarnings("ignore") # suppress h5py deprecation warning
import numpy as np
import os
import backtrader as bt
from btgym.research.casual_conv.strategy import CasualConvStrategyMulti
from btgym.research.casual_conv.netwo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Problem formulation
Step2: First, one can manually play with environment
Step3: Run training (do not expect it to converge though)
|
7,262 | <ASSISTANT_TASK:>
Python Code:
import numpy
n = 10
A = numpy.random.random(n)
print(A)
s = 0
for i in range(n):
s += A[i]
print(s)
s = numpy.sum(A)
print(s)
n = 1000000
A = numpy.random.random(n)
def explicit_sum(seq):
s = 0
for elem in seq:
s += elem ** 2
return s
%timeit explicit_sum(A)
%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: Fortran style
Step2: APL style
Step3: Une préférence ?
Step4: We don't need your loops!
Step5: Les scientifiquent codent en Numpy de haut ni... |
7,263 | <ASSISTANT_TASK:>
Python Code::
import numpy as np
from pyspark.ml.recommendation import ALS
<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,264 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'awi', 'sandbox-2', '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... |
7,265 | <ASSISTANT_TASK:>
Python Code:
# for testing if module is not in python-path
# import sys
# sys.path.append('/home/stephan/Repos/ENES-EUDAT/submission_forms')
# sys.path.append('C:\\Users\\Stephan Kindermann\\Documents\\GitHub\\submission_forms')
%load_ext autoreload
%autoreload 2
from IPython.display import 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: Model is along the concept described in https
Step2: Example name spaces
|
7,266 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
directory = '/input/'
with open(directory + 'reviews.txt', 'r') as f:
reviews = f.read()
with open(directory + 'labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
from string import punctuation
all_text = ''.join([c for c in review... | <SYSTEM_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 preprocessing
Step2: Encoding the words
Step3: Encoding the labels
Step4: Okay, a couple issues here. We seem to have one review with ze... |
7,267 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
from exact_solvers import euler
from exact_solvers import euler_demos
from ipywidgets import widgets
from ipywidgets import interact
State = euler.Primitive_State
gamma = 1.4
interact(euler.plot_integral_curves,
gamm... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If you wish to examine the Python code for this chapter, see
Step2: Rankine-Hugoniot jump conditions
Step3: Entropy condition
Step4: Here is ... |
7,268 | <ASSISTANT_TASK:>
Python Code:
primes = []
i = 2
while len(primes) < 25:
for p in primes:
if i % p == 0:
break
else:
primes.append(i)
i += 1
print(primes)
def square(val):
print(val)
return val ** 2
squared_numbers = [square(i) for i in range(5)]
print('Squared from 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: Functional
Step2: Object oriented
Step3: Exercise 2
Step6: Building Skills in Object Oriented Design is a good resource to learn more about t... |
7,269 | <ASSISTANT_TASK:>
Python Code:
from dolfin import *
from rbnics import *
@EIM("online")
@ExactParametrizedFunctions("offline")
class NonlinearElliptic(NonlinearEllipticProblem):
# Default initialization of members
def __init__(self, V, **kwargs):
# Call the standard initialization
NonlinearElli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 3. Affine Decomposition
Step2: 4. Main program
Step3: 4.2. Create Finite Element space (Lagrange P1)
Step4: 4.3. Allocate an object of the No... |
7,270 | <ASSISTANT_TASK:>
Python Code:
from fastai.tabular import *
path = untar_data(URLs.ADULT_SAMPLE)
df = pd.read_csv(path/'adult.csv')
dep_var = 'salary'
cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race']
cont_names = ['age', 'fnlwgt', 'education-num']
procs = [FillMissing, Cat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tabular data should be in a Pandas DataFrame.
Step2: Inference 预测
|
7,271 | <ASSISTANT_TASK:>
Python Code:
def isProduct(arr , n , x ) :
if n < 2 :
return False
s = set()
for i in range(0 , n ) :
if arr[i ] == 0 :
if x == 0 :
return True
else :
continue
if x % arr[i ] == 0 :
if x // arr[i ] in s :
return True
s . add(arr[i ] )
return False
... | <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,272 | <ASSISTANT_TASK:>
Python Code:
import copy
import glob
import os
import subprocess
import cdpybio as cpb
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
pd.options.mode.chained_assignment = None # default='warn'
import pybedtools as pbt
import seaborn as sns
import socket
import statsmodels.stat... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Summary
Step2: Comparison to GTEx Multi-Tissue eQTLs
Step3: The black line shows the $p$-value for the GTEx SNV. The red line shows the smalle... |
7,273 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import PyDealII.Debug as dealii
triangulation = dealii.Triangulation('2D')
triangulation.generate_hyper_cube()
triangulation.refine_global(2)
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We start by creating a 2D Triangulation of an hyper cube and we globally refine it twice. You can read the documention of Triangulation by typin... |
7,274 | <ASSISTANT_TASK:>
Python Code:
import numpy as np # we'll be using this shorthand for the NumPy library throughout
dataset = np.load("../data/images/project_data.npy")
n_samples = dataset.shape[0]
print("Data shape: ", dataset.shape)
import matplotlib.pyplot as plt
rows = 2
cols = 2
n_plots = rows*cols
fig, axs = plt.... | <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: Task 1b
Step3: Task 1c
Step5: We also want to plot up the data again to confirm that our scaling is sensible, you should reuse your code from ... |
7,275 | <ASSISTANT_TASK:>
Python Code:
# Setting extend, grid and compile
# Setting the extent
sandstone = GeMpy_core.GeMpy()
# Create Data class with raw data
sandstone.import_data( 696000,747000,6863000,6950000,-20000, 2000,
path_f = os.pardir+"/input_data/a_Foliations.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: All input data is stored in pandas dataframes under, self.Data.Interances and self.Data.Foliations
Step2: Plotting raw data
Step3: Class Inter... |
7,276 | <ASSISTANT_TASK:>
Python Code:
# Specifically for the iPython Notebook environment for clearing output.
from IPython.display import clear_output
# Global variables
board = [' '] * 10
game_state = True
announce = ''
# Note: Game will ignore the 0 index
def reset_board():
global board,game_state
board = [' '] * ... | <SYSTEM_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 make a function that will reset the board, in this case we'll store values as a list.
Step2: Now create a function to display the board, I... |
7,277 | <ASSISTANT_TASK:>
Python Code:
import graphlab
image_train = graphlab.SFrame('image_train_data/')
# deep_learning_model = graphlab.load_model('http://s3.amazonaws.com/GraphLab-Datasets/deeplearning/imagenet_model_iter45')
# image_train['deep_features'] = deep_learning_model.extract_features(image_train)
image_train.h... | <SYSTEM_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 CIFAR-10 dataset
Step2: Computing deep features for our images
Step3: Train a nearest-neighbors model for retrieving images using dee... |
7,278 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import emcee
import triangle
import numpy as np
import scipy.optimize as op
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
# Reproducible results!
np.random.seed(123)
# Choose the "true" parameters.
m_true... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: It is this sampler which has all the methods and functionality that we want. For example let's run it and see the size of the out output chains
... |
7,279 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
pickle_file = 'notMNIST.pickle'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reformat into a TensorFlow-friendly shape
Step2: Let's build a small network with two convolutional layers, followed by one fully connected lay... |
7,280 | <ASSISTANT_TASK:>
Python Code:
# Get http://geneontology.org/ontology/go-basic.obo
from goatools.base import download_go_basic_obo
obo_fname = download_go_basic_obo()
# Get ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene2go.gz
from goatools.base import download_ncbi_associations
gene2go = download_ncbi_associations()
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Download Associations, if necessary
Step2: 3. Initialize GODag object
Step3: 4. Initialize Reporter class
Step4: 5. Generate depth/level r... |
7,281 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
from IPython.html.widgets import interact, interactive, fixed
Image('fermidist.png')
def fermidist(energy, mu, kT):
Compute the Fermi distribution at energy, mu and kT.
F = 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: Exploring the Fermi distribution
Step3: In this equation
Step4: Write a function plot_fermidist(mu, kT) that plots the Fermi distribution $F(\... |
7,282 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
Isess = tf.InteractiveSession()
m1 = [[1.0, 2.0], [3.0, 4.0]] #list
m2 = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) #numpy ndarray
m3 = tf.constant([[1.0, 2.0], [3.0, 4.0]]) #Tensor cons... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Representing Tensors
Step2: Tensorflow Operators
Step3: Sessions can take placeholders, variables, and constants as input
Step4: saver.save()... |
7,283 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import sys
sys.path.append("/home/darlan/cvs_files/pyphysim/")
# xxxxxxxxxx Import Statements xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
from pyphysim.simulations.runner import SimulationRunner
from pyphysim.simulations.parameters import SimulationParameters
from pyphysim... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now we import some modules we use and add the PyPhysim to the python path.
Step2: Load the results from disk
Step3: Results for external inter... |
7,284 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from collections import defaultdict
import json
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib import rcParams
import matplotlib.cm as cm
import matplotlib as mpl
#colorbrewer2 Dark2 qualitative color table
dark2_colors = [(0.1058... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Homework 2
Step4: Here is some code to plot State Chloropleth maps in matplotlib. make_map is the function you will use.
Step5: Today
Step6: ... |
7,285 | <ASSISTANT_TASK:>
Python Code:
import itertools as it
def lexicographicPermutations():
l=list(range(10))
r=[''.join(map(str,x)) for x in list(it.permutations(l))]
#print(len(r))
print("Millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9: "+r[999999])
lexicographicPermutations()
def 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: Problem 25
Step2: Problem 26
|
7,286 | <ASSISTANT_TASK:>
Python Code:
class Soldier:
Clase que representa a un soldado
def __init__(self, name):
self.name = name
def get_name(self):
Devuelve el nombre del soldado
return self.name
def __eq__(self,another):
return self.name == another.name
alicia = Soldier("Ali... | <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: Clases de objetos 19 y 22 Octubre
Step3: Pruebas
Step9: Clase Escuadron
Step10: Pruebas
Step13: Nota de clase
Step18: Clase Arma
Step19: P... |
7,287 | <ASSISTANT_TASK:>
Python Code:
import gym
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import interactive
interactive(True)
env = gym.make('trading-v0')
#env.time_cost_bps = 0 #
observation = env.reset()
done = False
navs = []
while not done:
act... | <SYSTEM_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 the environment
Step2: the trading model
Step3: Note that you are charged just for playing - to the tune of 1 basis point per day!
Step... |
7,288 | <ASSISTANT_TASK:>
Python Code:
import cPickle
import os
import re
import shutil
import tarfile
import tensorflow as tf
print(tf.__version__)
CIFAR_FILENAME = 'cifar-10-python.tar.gz'
CIFAR_DOWNLOAD_URL = 'http://www.cs.toronto.edu/~kriz/' + CIFAR_FILENAME
CIFAR_LOCAL_FOLDER = 'cifar-10-batches-py'
def _download_and_ext... | <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: This notebook describes how to implement distributed tensorflow code.
Step3: 2. Define parameters
Step5: 3. Define data input pipeline
Step6: ... |
7,289 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
#Description from Prestashop
df_description = pd.read_csv('sql_prestashop/ps_product_lang.csv', index_col=False)
#wp_posts from Woocommerce
wp_posts = pd.read_csv('sql_prestashop/wp_posts.csv', index_col=False)
#Use only English "Description" & "Sh... | <SYSTEM_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 load the data. There are
Step2: We select only the English description from Prestashop database.
Step3: Next step, we fill the "Descriptio... |
7,290 | <ASSISTANT_TASK:>
Python Code:
# Used for card shuffle
import random
# Boolean used to know if hand is in play
playing = False
chip_pool = 100 # Could also make this a raw input.
bet = 1
restart_phrase = "Press 'd' to deal the cards again, or press 'q' to quit"
# Hearts, Diamonds,Clubs,Spades
suits = ('H','D','C','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: Now I'll make a card class, it will have some basic ID functions, and then some functions to grab the suit and rank of the card.
Step2: Now I'l... |
7,291 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from matplotlib import pyplot as plt
import pickle
import os
%pylab inline
clmax=5
spc=5e2
theta_range=2
#samples is list of labels
samples=np.zeros(spc*clmax,dtype=np.uint32)
#I is fessture vector
I=np.zeros((spc*clmax,theta_range),dtype=np.float32)
marker=['bo','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: Generating datasets
Step2: Visualization of the dataset
Step3: Training
Step4: Write and read the tree
Step5: Check the file size
Step6: Th... |
7,292 | <ASSISTANT_TASK:>
Python Code:
# import
import pandas as pd
import numpy as np
import seaborn as sns
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
%matplotlib inline
np.random.seed(42)
random_numbers = np.empty(100000)
for i in range(100000):
random_numbers[i] = np.random.random()
plt.hist... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generating Random numbers
Step3: perform_bernoulli_trials - check the probability of Success
Step4: In baseball, a no-hitter is a game in whi... |
7,293 | <ASSISTANT_TASK:>
Python Code:
import csv
id=[]
with open('../data/'+datafiles['mRNA']) as f:
my_csv = csv.reader(f,delimiter='\t')
id = my_csv.next()
stat={}
with open('../data/TCGA_Data/data_bcr_clinical_data_patient.csv') as f:
reader = csv.reader(f, delimiter='\t')
for row in reader:
patient... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Comparison with MATLAB results
Step2: The class ids obtained from MATLAB and from Theano are not the same, the formula below happens to convert... |
7,294 | <ASSISTANT_TASK:>
Python Code:
import pymrio
from pathlib import Path
oecd_storage = Path('/tmp/mrios/OECD')
meta_2018_download = pymrio.download_oecd(storage_folder=oecd_storage, years=[2011])
oecd_path_year = pymrio.parse_oecd(path=oecd_storage, year=2011)
oecd_file = pymrio.parse_oecd(path=oecd_storage / 'ICIO2018... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: OECD provides the data compressed in zip files. The pymrio oecd parser works with both, the compressed and unpacked version.
Step2: Or directly... |
7,295 | <ASSISTANT_TASK:>
Python Code:
import phidl.geometry as pg
from phidl import Device, Layer, LayerSet
from phidl import quickplot as qp
D = Device()
# Specify layer with a single integer 0-255 (gds datatype will be set to 0)
layer1 = 1
# Specify layer as 1, equivalent to layer = 2, datatype = 6
layer2 = (2,6)
# Specify ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Multiple layers
Step2: Note that although we specified four different layers, it did not produce four separate ellipse Devices--instead, it pro... |
7,296 | <ASSISTANT_TASK:>
Python Code:
[1,2,3,4,5,6,7,8,9,10]
a = [1,2,3,4,5,6,7,8,9,10]
a
list(range(100))
b = list(range(100))
b
a.append('ich bin keine Zahl')
a
b.append("ich bin keine Zahl")
b
a.pop()
a
b.pop()
b
str(a)
str(b)
b = list(range(100))
b[89:]
dct_lst = [{'Stadt': 'Zürich', 'Bevölkerung': 402651, 'Kanton':... | <SYSTEM_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.Mache dasselbe mit einer Liste aus 100 Elementen und ordne sie der Variabel b zu.
Step2: 3.Füge beiden Listen folgenden String an
Step3: 4.L... |
7,297 | <ASSISTANT_TASK:>
Python Code:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline
# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'
# import functions from the modsim.py module
from modsim import *
radian = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Teapots and Turntables
Step2: And store the parameters in a Params object.
Step4: make_system creates the initial state, init, and computes th... |
7,298 | <ASSISTANT_TASK:>
Python Code:
df_train = pd.DataFrame()
# MNCHN
df_train['body'] = df_mnchn['body'].append(df_mnchn['Final Keywords'])
df_train['label'] = 1
# Adolescent
df_train = df_train.append(pd.DataFrame({
'body': df_adolescent['body'].append(df_adolescent['Final Keywords']),
'label': 2
}))
# Geriatrics
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Classification Pipeline
|
7,299 | <ASSISTANT_TASK:>
Python Code:
from pyspark.mllib.recommendation import Rating
ratingsRDD = sc.textFile('ratings.dat') \
.map(lambda l: l.split("::")) \
.map(lambda p: Rating(
user = int(p[0]),
product = int(p[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: Split into training and testing
Step2: Build the recommendation model using ALS on the training data
Step3: Extract the product (movie) featur... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.