Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
5,700 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
A=np.asarray([[1,1,1], [1,1,2], [1,1,3], [1,1,4]])
B=np.asarray([[0,0,0], [1,0,2], [1,0,3], [1,0,4], [1,1,0], [1,1,1], [1,1,4]])
dims = np.maximum(B.max(0),A.max(0))+1
result = A[~np.in1d(np.ravel_multi_index(A.T,dims),np.ravel_multi_index(B.T,dims))]
output = np.append... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
5,701 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.version
import warnings
warnings.simplefilter('ignore', FutureWarning)
from pandas import *
show_versions()
delhi = read_csv('Delhi_DEL_2014.csv', skipinitialspace=True)
delhi.head()
delhi = delhi.rename(columns={'WindDirDegrees<br />' : 'WindDirDegrees'})
delhi['WindDir... | <SYSTEM_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 the data
Step2: Cleaning the data
Step3: remove the < br /> html line breaks from the values in the 'WindDirDegrees' column.
S... |
5,702 | <ASSISTANT_TASK:>
Python Code:
#!/usr/bin/env python
#
# This project will collect temperature and humidity information using a DHT22 sensor
# and send this information to a MySQL database.
#
import Adafruit_DHT
import time
import RPi.GPIO as GPIO
import datetime
import MySQLdb
# General settings
prog_name = "pilogger2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <b>Exercise 2
|
5,703 | <ASSISTANT_TASK:>
Python Code:
!pip install hanlp -U
import hanlp
hanlp.pretrained.sts.ALL # 语种见名称最后一个字段或相应语料库
sts = hanlp.load(hanlp.pretrained.sts.STS_ELECTRA_BASE_ZH)
sts([
('看图猜一电影名', '看图猜电影'),
('无线路由器怎么无线上网', '无线上网卡和无线路由器怎么用'),
('北京到上海的动车票', '上海到北京的动车票'),
])
<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: 加载模型
Step2: 调用hanlp.load进行加载,模型会自动下载到本地缓存:
Step3: 语义文本相似度
|
5,704 | <ASSISTANT_TASK:>
Python Code:
import pyspark as ps
from sentimentAnalysis import dataProcessing as dp
# create spark session
spark = ps.sql.SparkSession(sc)
# get dataframes
# specify s3 as sourc with s3a://
#df = spark.read.json("s3a://amazon-review-data/user_dedup.json.gz")
#df_meta = spark.read.json("s3a://amazon-r... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <hr>
Step2: Add Pos Tags
Step3: data frame
Step4: Tri Gram POS Tags
Step5: Function
Step6: <hr>
Step7: Test on Row
Step8: <hr>
|
5,705 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from scipy import stats
import statsmodels.api as sm
import matplotlib.pyplot as plt
import seaborn
import warnings
from itertools import product
import numpy as np
def invboxcox(y,lmbda):
if lmbda == 0:
return(np.exp(y))
else:
return(np.exp(np.log(l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: В рамках первичной визуалиции можно сразу отметить восходящий общий тренд. Сезонность с пиками в декабре и падением в январе(годовые премии). Ро... |
5,706 | <ASSISTANT_TASK:>
Python Code:
print('abc')
print(1, 2, 3)
print(1, 2, 3, sep='--')
def fibonacci(N):
L = []
a, b = 0, 1
while len(L) < N:
a, b = b, a + b
L.append(a)
return L
fibonacci(10)
def real_imag_conj(val):
return val.real, val.imag, val.conjugate()
r, i, c = real_imag_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: Here print is the function name, and 'abc' is the function's argument.
Step2: When non-keyword arguments are used together with keyword argumen... |
5,707 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
def print_sum(a, b):
Print the sum of the arguments a and b.
# YOUR CODE HERE
c = a+b
print(c)
# Y... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Interact basics
Step3: Use the interact function to interact with the print_sum function.
Step5: Write a function named print_string that prin... |
5,708 | <ASSISTANT_TASK:>
Python Code:
import cvxpy as cp
import numpy as np
import matplotlib.pyplot as plt
# check if channel is weakly symmetric
def is_weakly_symmetric(P):
V = P.shape[1]
W = P.shape[0]
# check if matrix P is weakly symmetric
col1 = np.sort(P[:,0])
permutation_test = [np.array_equal(np.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Helper function to check if a channel is weakly symmetric and hence also symmetric)
Step2: Compute the capacity of the channel. If the channel ... |
5,709 | <ASSISTANT_TASK:>
Python Code:
jsonString = '{"key": "value"}'
# Parse the JSON string
dictFromJson = json.loads(jsonString)
# Python now has a dictionary representing this data
print ("Resulting dictionary object:\n", dictFromJson)
# Will print the value
print ("Data stored in \"key\":\n", dictFromJson["key"])
# This ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Multile Keys and Values
Step2: JSON and Arrays
Step3: More JSON + Arrays
Step4: Nested JSON Objects
Step5: From Python Dictionaries to JSON
... |
5,710 | <ASSISTANT_TASK:>
Python Code:
# %load startup.ipy
#! /usr/bin/env python3
import sys
sys.path.append('./python')
import logging.config
import os
import xbx.database as xbxdb
import xbx.util as xbxu
import xbx.config as xbxc
import xbx.build as xbxb
import xbx.run as xbxr
logging.config.fileConfig("logging.ini", disabl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: List RunSessions, ordered by descending timestamp
Step2: Print latest RunSession
Step3: We have overridden the __repr__ function in the base c... |
5,711 | <ASSISTANT_TASK:>
Python Code:
# read the frequency and get a pandas serie
frequency = pd.read_csv('data/freq.csv')['freqs']
# read all data for training
filenames = ['data/spectra_{}.csv'.format(i)
for i in range(4)]
spectra, concentration, molecule = [], [], []
for filename in filenames:
spectra_file... | <SYSTEM_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 helper functions
Step2: Reusability for new data
Step3: Training and testing a machine learning model for classification
Step4: Training... |
5,712 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import logging
import itertools
from scipy.sparse import csr_matrix
import rescal
from almc.bayesian_rescal import BayesianRescal
%matplotlib inline
logger = logging.getLogger()
logger.setLevel(logging.INFO)
max_iter = 20
n_entity = 10
n_dim = 5
n_relation = 20
var_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: Split data into training/test data
Step2: Fit
Step3: Control variance of observed/unobserved data
|
5,713 | <ASSISTANT_TASK:>
Python Code:
#!pip install google-cloud-bigquery
%load_ext google.cloud.bigquery
import matplotlib.pyplot as plt
import pandas as pd
def plot_historical_and_forecast(input_timeseries, timestamp_col_name, data_col_name, forecast_output=None, actual=None):
input_timeseries = input_timeseries.sort_val... | <SYSTEM_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 plot functions
Step2: Plot the time series
Step3: Train ARIMA model
Step4: We can get the forecast data using
Step5: Forecasting a bu... |
5,714 | <ASSISTANT_TASK:>
Python Code:
import numpy
import theano
from theano import tensor
# Set lower precision float, otherwise the notebook will take too long to run
theano.config.floatX = 'float32'
class HiddenLayer(object):
def __init__(self, rng, input, n_in, n_out, W=None, b=None,
activation=tensor... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Multilayer Perceptron in Theano
Step6: A softmax class for the output
Step9: The MLP class
Step10: Training Procedure
Step11: Testing functi... |
5,715 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
data = pd.read_csv("./data/bryant et al 2010 data.csv", index_col=False)
x = data.iloc[:, 2:11]
y = data.iloc[:, 15].values
from ema_workbench.analysis import prim
from ema_workbench.util import ema_logging
ema_logging.log_to_stderr(ema_logging.INFO);
prim_alg = prim... | <SYSTEM_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 exploratory modeling workbench comes with a seperate analysis package. This analysis package contains prim. So let's import prim. The workbe... |
5,716 | <ASSISTANT_TASK:>
Python Code:
# modules we'll use
import pandas as pd
import numpy as np
# helpful modules
import fuzzywuzzy
from fuzzywuzzy import process
import chardet
# read in all our data
professors = pd.read_csv("../input/pakistan-intellectual-capital/pakistan_intellectual_capital.csv")
# set seed for reproduci... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Do some preliminary text pre-processing
Step2: Say we're interested in cleaning up the "Country" column to make sure there's no data entry inco... |
5,717 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from sympy import *
init_printing()
Ex, Ey, Ez = symbols("E_x, E_y, E_z")
x, y, z = symbols("x, y, z")
vx, vy, vz, v = symbols("v_x, v_y, v_z, v")
t = symbols("t")
q, m = symbols("q, m")
c, eps0 = symbols("c, epsilon_0")
eq_x = Eq( diff(... | <SYSTEM_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 equation of motion
Step2: Assuming $E_z = 0$ and $E_y = 0$
Step3: Motion is uniform along the $z$-axis
Step4: The constants of integratio... |
5,718 | <ASSISTANT_TASK:>
Python Code:
data = {
'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada', 'Nevada'],
'year': [2000, 2001, 2002, 2001, 2002],
'pop': [1.5, 2.5, 3.0, 2.5, 3.5]
}
df = pd.DataFrame(data, columns=["state", "year", "pop"])
df
df.pivot("state", "year", "pop")
df.pivot("year", "pop", "state")
df.set_ind... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 행 인덱스와, 열 인덱스가 될 자료는 키(key)의 역할을 해야 한다. 즉, 이 값으로 데이터가 유일하게(unique) 결정되어야 한다.
Step2: 그룹 연산
Step3: 문제
Step4: 문제
Step5: groupby 명령의 인수
Step6: ... |
5,719 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccma', 'sandbox-2', 'land')
# 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... |
5,720 | <ASSISTANT_TASK:>
Python Code:
# import isotherms
%run import.ipynb
# import the characterisation module
import pygaps.characterisation as pgc
isotherm = next(i for i in isotherms_n2_77k if i.material == 'MCM-41')
print(isotherm.material)
results = pgc.area_BET(isotherm, verbose=True)
results = pgc.area_BET(isotherm,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: pyGAPS attempts to calculate the applicable BET region on its own by using the
Step2: It looks that the correlation is reasonably good. A warni... |
5,721 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set_style('white')
from scipy.interpolate import griddata
x=np.linspace(-5,5)
y=x
listf=[0,1,0]
f=np.array(listf)
f
plt.scatter(x, y);
assert x.shape==(41,)
assert y.shape==(41,)
assert f.sha... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sparse 2d interpolation
Step2: The following plot should show the points on the boundary and the single point in the interior
Step3: Use meshg... |
5,722 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
from string import punctuation
import urllib.request
url='http://www.unc.edu/~ncaren/haphazard/negative.txt'
file_name='negative.txt'
urllib.request.urlretrieve(url, file_name)
urllib.request.urlretrieve('http://www.unc.edu/~ncaren/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: Downloading
Step2: Like many commands, Python won’t return anything unless something went wrong. In this case, the In [*] should change to a nu... |
5,723 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import urllib2
from sklearn.cluster import AgglomerativeClustering
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import FunctionTransformer
urls = {
'The Iliad -... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: In this lab, we're going to cluster documents by the similarity of their text content. For this, we'll need to download some documents to cluste... |
5,724 | <ASSISTANT_TASK:>
Python Code:
categories = ['alt.atheism', 'soc.religion.christian','comp.graphics', 'sci.med']
from sklearn.datasets import fetch_20newsgroups
twenty_train = fetch_20newsgroups(subset='train',categories=categories, shuffle=True, random_state=42)
twenty_train.target_names
len(twenty_train.data)
prin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in the training set of data
Step2: Note target names not in same order as in the categories array
Step3: Show the first 8 lines of text f... |
5,725 | <ASSISTANT_TASK:>
Python Code:
# Load PredicSis.ai SDK
from predicsis import PredicSis
pj = PredicSis.project('Outbound Mail Campaign')
dflt_schm = pj.default_schema()
dflt_schm.describe()
master_frame=dflt_schm.frame('Customers')
master_frame.describe()
master_frame.set_categorical('region_code')
master_frame.desc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Choose your project
Step2: Retrieve and describe the frame
Step3: Change type of a native feature (from the central table)
Step4: Change the ... |
5,726 | <ASSISTANT_TASK:>
Python Code:
# Our first function
def my_first_function():
pass
def my_first_function():
print("Hello world!")
my_first_function
my_first_function()
def my_first_function(name):
print("Hello %s" % (name))
return None
my_first_function("Tang U-Liang")
# Passing two arguments
def spe... | <SYSTEM_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 our first function, we see above that my_first_function does not take in any input and does nothing. The pass keyword is a kind of temporary... |
5,727 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[0,0],[0,0,0],[0,0,0,0]])
def sigmoid(x):
return np.matrix(1.0 / (1.0 + np.exp(-x)))
def relu(x):
alpha = 0.01
return np.maximum(x, (alpha * x))
#initialize random weights
numIn, numHid, numOut = 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: The neural network accepts an input vector of length 2. It has 2 output nodes. One node is used to control whether or not to recursively run its... |
5,728 | <ASSISTANT_TASK:>
Python Code:
# Change below if necessary
PROJECT = !gcloud config get-value project # noqa: E999
PROJECT = PROJECT[0]
BUCKET = PROJECT
REGION = "us-central1"
%env PROJECT=$PROJECT
%env BUCKET=$BUCKET
%env REGION=$REGION
%env TFVERSION=2.5
%%bash
gcloud config set project $PROJECT
gcloud config set ai... | <SYSTEM_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 code compatible with AI Platform Training Service
Step2: Move code into python package
Step4: To use hyperparameter tuning in your traini... |
5,729 | <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: Keras でマスキングとパディングをする
Step2: はじめに
Step3: マスキング
Step4: 出力された結果から分かるように、マスクは形状が(batch_size, sequence_length)の 2 次元ブールテンソルであり、そこでは個々の False エントリ... |
5,730 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display, HTML
from ipywidgets import widgets, interactive, IntSlider
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
import qgrid # https://github.com/quantopian/qgrid
# import statsmodels.api as sm
import textwrap
import traceback
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step4: Summarized data functions
Step7: DataAnalysisWidget
Step8: Interactive Data Analysis
|
5,731 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.style.use('classic')
%matplotlib inline
import numpy as np
x = np.linspace(0, 10, 100)
fig = plt.figure()
plt.plot(x, np.sin(x), '-')
plt.plot(x, np.cos(x), '--');
fig.savefig('my_figure.png')
!ls -lh my_figure.png
from IP... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The plt interface is what we will use most often, as we shall see throughout this chapter.
Step2: Throughout this section, we will adjust this ... |
5,732 | <ASSISTANT_TASK:>
Python Code:
import logging
from conf import LisaLogging
LisaLogging.setup()
# Generate plots inline
%matplotlib inline
import json
import os
# Support to access the remote target
import devlib
from env import TestEnv
# Support for workload generation
from wlgen import RTA, Ramp
# Support for trace an... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Target Configuration
Step2: Workload Configuration and Execution
Step3: Parse Trace and Profiling Data
Step4: Trace visualization
Step5: Lat... |
5,733 | <ASSISTANT_TASK:>
Python Code:
from numpy import array, dot, outer, sqrt, matrix
from numpy.linalg import eig, eigvals
from matplotlib.pyplot import hist
%matplotlib inline
rv = array([1,2]) # a row vector
rv
cv = array([[3],[4]]) # a column vector
cv
dot(rv,cv)
dot(cv,rv)
outer(rv,cv)
outer(cv,rv)
# Complex numbe... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Two kinds of vector products we'll see
Step2: 2) Use the function outer(vector1, vector2) to find the outer product of rv and cv. Does the orde... |
5,734 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
sys.path.append(os.getcwd().replace("notebooks", "cfncluster"))
## S3 input and output address.
s3_input_files_address = "s3://path/to/input folder"
s3_output_files_address = "s3://path/to/output folder"
## CFNCluster name
your_cluster_name = "testonco"
## The private... | <SYSTEM_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. Create CFNCluster
Step2: After you verified the project information, you can execute the pipeline. When the job is done, you will see the lo... |
5,735 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
# tutoriel_graphe
noeuds = {0: 'le', 1: 'silences', 2: 'quelques', 3: '\xe9crit', 4: 'non-dits.', 5: 'Et', 6: 'risque', 7: '\xe0', 8: "qu'elle,", 9: 'parfois', 10: 'aim\xe9', 11: 'lorsque', 12: 'que', 13: 'plus', 14: 'les', ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Un graphe
|
5,736 | <ASSISTANT_TASK:>
Python Code:
import espressomd
required_features = ["LENNARD_JONES"]
espressomd.assert_features(required_features)
from espressomd import observables, accumulators, analyze
# Importing other relevant python modules
import numpy as np
import matplotlib.pyplot as plt
from scipy import optimize
np.random... | <SYSTEM_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 next step would be to create an instance of the System class. This instance is used as a handle to the simulation system. At any time, only ... |
5,737 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-esm4', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
5,738 | <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
|
5,739 | <ASSISTANT_TASK:>
Python Code:
import numpy
T = numpy.array([10, 13, 17, 20, 19, 21, 14, 8, 5, 10])
wT = T * [0, 0, 0, 0, 0, 1, 1, 0, 0, 0]
X = numpy.zeros((10, 3))
X[:, 0] = numpy.ones(10).T
X[:, 1] = T.T
X[:, 2] = (wT ** 2).T
Y = numpy.array([1, 1.2, 1.5, 1.4, 1.6, 2.1, 1.7, 0.9, 0.7, 1.1]).T
Theta = numpy.linalg.inv... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Вычисление RSS
Step2: Вычисление отклика
|
5,740 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from traitlets import Unicode, Bool, validate, TraitError
from ipywidgets import DOMWidget, register
@register
class Email(DOMWidget):
_view_name = Unicode('EmailView').tag(sync=True)
_view_module = Unicode('email_widget').tag(sync=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: Building a Custom Widget - Email widget
Step2: sync=True traitlets
Step3: Define the view
Step4: Render method
Step5: Test
Step6: Making th... |
5,741 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
digits = datasets.load_digits()
%matplotlib inline
from matplotlib import pyplot
# Show first 10 images
for i in xrange(10):
pyplot.figure(i+1)
ax = pyplot.gca() # gca = get current axis
ax.imshow(digits.images[i],cmap=pyplot.cm.binary)
digits.da... | <SYSTEM_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 investigate the data that we just loaded. A dataset contains the original data (digits.images), a 2 dimensional data array and some metada... |
5,742 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-dark')
import openmoc
import openmc
import openmc.mgxs as mgxs
import openmc.data
from openmc.openmoc_compatible import get_openmoc_geometry
%matplotlib inline
# 1.6% enriched fuel
fuel = openmc.Material(name='1.6%... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we need to define materials that will be used in the problem. We'll create three distinct materials for water, clad and fuel.
Step2: With... |
5,743 | <ASSISTANT_TASK:>
Python Code:
name = input("Wie heisst du? ")
name_in_grossbuchstaben = name.upper()
print(name_in_grossbuchstaben)
name = input("Wie heisst du? ")
anzahl_buchstaben = len(name)
print(anzahl_buchstaben)
zahl_1 = input("Bitte gib eine Zahl ein: ")
zahl_2 = input("Bitte gib noch eine Zahl ein: ")
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Daten verarbeiten
Step2: Eine zusätzliche Variable namens name_in_grossbuchstaben enthält nun den eingegebenen Namen, jedoch komplett in Grossb... |
5,744 | <ASSISTANT_TASK:>
Python Code:
import pgradd
print(pgradd.__file__)
from pgradd.GroupAdd import GroupLibrary
import pgradd.ThermoChem
lib = GroupLibrary.Load('GRWSurface2018')
groups = lib.GetDescriptors('C(CC([Pt])([Pt])[Pt])([Pt])([Pt])[Pt]')
print('Group Frequency')
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: Find the groups in a molecule
Step2: Calculate thermodynamic properties of the molecule
Step3: Find the groups in a molecule
Step4: Calculate... |
5,745 | <ASSISTANT_TASK:>
Python Code:
!python3 -m pip freeze | grep tensorflow==2 || \
python3 -m pip --install tensorflow
import tensorflow as tf
users = ["Ryan", "Danielle", "Vijay", "Chris"]
movies = [
"Star Wars",
"The Dark Knight",
"Shrek",
"The Incredibles",
"Bleu",
"Memento",
]
features = ... | <SYSTEM_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 restart your kernel to ensure this change has taken place.
Step2: To start, we'll create our list of users, movies and features. W... |
5,746 | <ASSISTANT_TASK:>
Python Code:
# Load in the functions
from databaker.framework import *
# Load the spreadsheet
tabs = loadxlstabs("example1.xls")
# Select the first table
tab = tabs[0]
print("The unordered bag of cells for this table looks like:")
print(tab)
# Preview the table as a table inline
savepreviewhtml(tab)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Selecting cell bags
Step2: Note
Step3: Observations and dimensions
Step4: Note the value of h1.cellvalobs(ob) is actually a pair composed of ... |
5,747 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
import pandas as pd
from tensorflow import keras
from tensorflow.keras import layers
import math
CSV_HEADER = [
"age",
"workclass",
"fnlwgt",
"education",
"education_num",
"marital_status",
"occupation",
"relation... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepare the data
Step2: Remove the first record (because it is not a valid data example) and a trailing
Step3: We store the training and test ... |
5,748 | <ASSISTANT_TASK:>
Python Code:
import numpy
y = numpy.linspace(0, 1, 20) ** 2
import toyplot
toyplot.plot(y, width=300);
canvas = toyplot.Canvas(width=600, height=300)
axes1 = canvas.axes(bounds=(20, 280, 20, 280))
axes1.plot(y)
axes2 = canvas.axes(bounds=(320, 580, 20, 280))
axes2.plot(1 - y);
canvas = toyplot.Canva... | <SYSTEM_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 need greater control over the positioning of the axes within the canvas, or want to add multiple axes to one canvas, it's necessary to cr... |
5,749 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10, 6)
from sklearn.datasets import load_boston
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.model_selection import cross_val_score
boston = load_boston()
X, y =... | <SYSTEM_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 statement
Step2: Next, we need to define the bounds of the dimensions of the search space we want to explore, and (optionally) the star... |
5,750 | <ASSISTANT_TASK:>
Python Code:
sc = SparkContext.getOrCreate()
# carregar base de dados
from test_helper import Test
import os.path
baseDir = os.path.join('Data')
inputPath = os.path.join('millionsong.txt')
fileName = os.path.join(baseDir, inputPath)
numPartitions = 2
rawData = sc.textFile(fileName, numPartitions)
# EX... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: (1b) Usando LabeledPoint
Step4: Visualização 1
Step5: (1c) Deslocando os rótulos
Step6: (1d) Conjuntos de treino, validação e teste
Step7:... |
5,751 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
import random, operator
import time
import itertools
import numpy
import math
%matplotlib inline
random.seed(time.time()) # planting a random seed
def exact_TSP(cities):
"Generate all poss... | <SYSTEM_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 algorithm
Step2: Note 1
Step3: Representing Cities and Distance
Step4: Distance between cities
Step5: A cool thing is to be able to pl... |
5,752 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Gaussian Process Regression in TensorFlow Probability
Step3: Example
Step5: We'll put priors on the kernel hyperparameters, and write the join... |
5,753 | <ASSISTANT_TASK:>
Python Code:
%%HTML
<style>
.container { width:100% !important; }
.input{ width:60% !important;
align: center;
}
.text_cell{ width:70% !important;
font-size: 16px;}
.title {align:center !important;}
</style>
from IPython.display import Image #this is for displaying the widget... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Shaolin Dashboard Introduction
Step2: Dashboard containing a single widget.
Step3: Dashboard containing three components in a row
Step4: A co... |
5,754 | <ASSISTANT_TASK:>
Python Code:
a = 1
b = 2
def my_simple_sum(a, b):
Simple addition
:param a: fist number
:param b: second number
print "Sum is:", a+b
my_simple_sum(a,b)
# Further down in the code we do some changes
a = 100
# than we can go back and re-execute just the previous cell
# Use TAB to 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: Command mode vs Edit mode
Step2: Access to documentation and Code completion
Step3: Local shell commands execution
Step4: We can also use var... |
5,755 | <ASSISTANT_TASK:>
Python Code:
import json
import requests
import os
import time
import networkx as nx
import pybel
from pybel.constants import *
import pybel_tools
from pybel_tools.visualization import to_jupyter
pybel.__version__
pybel_tools.__version__
time.asctime()
res = requests.get("http://causalbionet.com/Netw... | <SYSTEM_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 Acquisition
Step2: Parsing
Step3: Visualization
Step4: Using PyBEL Functions
|
5,756 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from bokeh.charts import Donut, HeatMap, Histogram, Line, Scatter, show, output_notebook, output_file
from bokeh.plotting import figure
output_notebook()
album_list = pd.read_excel('albumlist.xls')
album_list.dtypes
album_list.head()
#efficent method to do the same 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: Getting the data and structuring it
Step2: The Genre and Subgenre categories have multiple comma separated values. I'm going to keep just the f... |
5,757 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
from sklearn.datasets import load_iris as load_data
from pandas import DataFrame
data = load_data()
df = DataFrame(data.data, columns=data.feature_names)
df['fleur'] = [data.target_names[t] for t in data.target]
df.tail()
f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Enoncé
Step2: Q1
Step3: Q2
Step4: Q3
Step5: La question sous-jacente est
Step6: Q2
Step7: Q3
Step8: Q4
Step9: Q5
Step10: Q6
|
5,758 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import openpnm as op
import matplotlib.pyplot as plt
ws = op.Workspace()
ws.settings['loglevel'] = 50 # Supress warnings, but see error messages
np.random.seed(0)
pn = op.network.Delaunay(shape=[1, 1, 0], points=100)
op.topotools.trim(network=pn, pores=pn.pores('boun... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's start by generating a random network using the Delaunay class. This will repreent an imported network
Step2: This network generator adds... |
5,759 | <ASSISTANT_TASK:>
Python Code:
from pyDrivers import dotstar
ds = dotstar.Dotstar(led_count=72*3,init_brightness=0)
while True:
for current_led in range (4, ds.led_count-4):
ds.set(current_led-4, 0, 0, 0, 0)
ds.set(current_led-2, 10, 100, 0, 0)
ds.set(current_led-1, 50, 200, 0, 0)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create Dotstar object
Step2: Class Methods
|
5,760 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
import csv
downloaded_file = "banklist.csv"
urlretrieve("https://s3.amazonaws.com/datanicar/banklist.csv", downloaded_file)
filtered_file = open('california_banks.csv', 'w', newline='')
# create our output
output = csv.writer(filtered_file, delim... | <SYSTEM_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're going to download a csv file. What should we name it?
Step2: Now we need a URL to a CSV file out on the Internet.
Step3: The output show... |
5,761 | <ASSISTANT_TASK:>
Python Code:
# Number of posts / tweets to retrieve.
# Small value for development, then increase to collect final data.
n = 4000 # 20
import configparser
# Read the confidential token.
credentials = configparser.ConfigParser()
credentials.read('credentials.ini')
token = credentials.get('facebook', ... | <SYSTEM_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.1 Facebook
Step2: 3.1.1 Scrap with HTTP requests
Step3: 3.1.1.2 Get posts
Step4: 3.1.2 Scrap with Facebook SDK
Step5: 3.2 Twitter
Step6: ... |
5,762 | <ASSISTANT_TASK:>
Python Code:
# Se importan widgets de IPython para interactuar con la funcion
from ipywidgets import interact, fixed
# Si la linea anterior no funciona, se puede quitar el comentario a la siguiente linea
#from IPython.html.widgets import interact, fixed
# Se define la constante τ, la cual representa l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Vamos a definir una función como ejemplo, si la definimos y la usamos, obtendremos el resultado esperado
Step2: Sin embargo es muy aburrido ¿Qu... |
5,763 | <ASSISTANT_TASK:>
Python Code:
class Ball(object):
pass
b = Ball()
b.__repr__()
print(b)
class Ball(object):
def __repr__(self):
return 'TEST'
b = Ball()
print(b)
from IPython.display import display
from IPython.display import (
display_pretty, display_html, display_jpeg,
display_png, 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: Overriding the __repr__ method
Step2: IPython expands on this idea and allows objects to declare other, rich representations including
Step3: ... |
5,764 | <ASSISTANT_TASK:>
Python Code:
import random
print(random.random())
print(random.random())
print(random.random())
a = 16807
m = pow(2,31)-1
DFLT_SEED = 666
x_i = DFLT_SEED # this is our x_i that changes each runif01() call
def runif01():
"Return a random value in U(0,1)"
global x_i
x_i = a * x_i % m
# 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: Uniform random variables are super important because they are the basis from which we generate other random variables, such as binomial, normal,... |
5,765 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
from __future__ import division
import copy
import json
import re
import string
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import seaborn # To improve the chart styling.
import wordtree
from IPython.display import display
f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the data from disk and set up the dataframes
Step3: Use fully_merged_messages_df and address_book_df for analysis, they contain all messag... |
5,766 | <ASSISTANT_TASK:>
Python Code:
# Author: Denis Engemann <denis.engemann@gmail.com>
# Jean-Remi King <jeanremi.king@gmail.com>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import io, EvokedArray
from mne.datasets import sample
from mne.decoding import EMS, comp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Note that a similar transformation can be applied with compute_ems
|
5,767 | <ASSISTANT_TASK:>
Python Code:
# Funcion para quitar todo el texto que este entre parentesis,
# lo que no sea letras y sustituir series de espacios en blanco por uno solo
def cleanup_str(raw):
rs = re.sub("\\(.*?\\)|[^a-zA-Z\\s]"," ",raw)
rs = re.sub("\\s+"," ",rs).strip().lower()
return rs
my_str =
Some ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mineria de Texto
Step2: Visite https
Step3: Conceptos Fundamentales de Mineria de Texto
Step4: Conceptos Fundamentales de Mineria de Texto
|
5,768 | <ASSISTANT_TASK:>
Python Code:
import json
import numpy as np
import sympy as sym
from scipy2017codegen.odesys import ODEsys
from scipy2017codegen.chem import mk_rsys
watrad_data = json.load(open('../scipy2017codegen/data/radiolysis_300_Gy_s.json'))
watrad = mk_rsys(ODEsys, **watrad_data)
tout = np.logspace(-6, 3, 200... | <SYSTEM_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 ODEsys class and convenience functions from previous notebook (35) has been put in two modules for easy importing. Recapping what we did las... |
5,769 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'cnrm-esm2-1-hr', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributo... | <SYSTEM_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... |
5,770 | <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 matplotlib.pyplot as plt
import numpy as np
import os
import sys
import tarfile
from IPython.display import display, Image
from scipy i... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: 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... |
5,771 | <ASSISTANT_TASK:>
Python Code:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
def build_graph():
build the same graph as previous dumped model
Args:
Non... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step7: Just import the code
Step8: Here we randomly select 10 images from mnist.test as input
Step9: Call the function to get result
Step10: Let 's ... |
5,772 | <ASSISTANT_TASK:>
Python Code:
# Set up code checking
from learntools.core import binder
binder.bind(globals())
from learntools.ml_intermediate.ex7 import *
print("Setup Complete")
# Check your answer (Run this code cell to receive credit!)
q_1.check()
# Check your answer (Run this code cell to receive credit!)
q_2.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: Step 1
Step2: Step 2
Step3: Step 3
Step4: Step 4
Step5: Step 5
|
5,773 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as opt
from IPython.html.widgets import interact
a_true = 0.5
b_true = 2.0
c_true = -4.0
# YOUR CODE HERE
xdata=np.linspace(-5,5,30)
N=30
dy=2.0
def ymodel(a,b,c):
return a*x**2+b*x+c
ydata =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fitting a quadratic curve
Step2: First, generate a dataset using this model using these parameters and the following characteristics
Step3: No... |
5,774 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
from scipy import signal
data1 = np.genfromtxt(os.path.join('..', 'tests', 'data', 'raman-785nm.txt'))
x = data1[:, 0]
y = data1[:, 1]
plt.plot(x, y)
widths = np.ar... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Find Peaks
Step2: Find ridge lines
Step3: For now use scipy.signal.find_peaks_cwt(), compare with my own implementation
Step6: Estimate Peak ... |
5,775 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(url='http://python.org/images/python-logo.gif')
# Code cell, then we are using python
print('Hello DS')
DS = 10
print(DS + 5) # Yes, we advise to use Python 3 (!)
import os
os.mkdir
my_very_long_variable_name = 3
round(3.2)
import os
os.mkdir
# 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: <big><center>To run a cell
Step2: Writing code is what you will do most during this course!
Step3: Help
Step4: <div class="alert alert-succes... |
5,776 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
%pylab inline
N=100
x = np.random.rand(N) *6
y = x + np.random.rand(N)*1
plt.scatter(x,y)
plt.plot([0,6],[0.5,6.2])
def se_line(n,m,b, y_2_hat, x_y_2_hat, y_hat, x_2_hat, x_hat):
val = n*y_2_hat - 2*m*(n*x_y_2_hat... | <SYSTEM_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, consider the plot below, the scatter points are random, but for this example, lets imagine we are analzing the prices of homes. In ... |
5,777 | <ASSISTANT_TASK:>
Python Code:
#general imports
import matplotlib.pyplot as plt
import pygslib
from matplotlib.patches import Ellipse
import numpy as np
import pandas as pd
#make the plots inline
%matplotlib inline
#get the data in gslib format into a pandas Dataframe
mydata= pygslib.gslib.read_gslib_file('../... | <SYSTEM_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 the data ready for work
Step2: The nscore transformation table function
Step3: Note that the input can be data or a reference distribu... |
5,778 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import skrf as rf
rf.stylely()
from skrf import Frequency
from skrf.media import CPW
freq = Frequency(75,110,101,'ghz')
cpw = CPW(freq, w=10e-6, s=5e-6, ep_r=10.6)
cpw
cpw.line(100*1e-6, name = '100um line')
freq = Frequency(75,110,101,'ghz')
cpw = CPW(freq, w=10e-6,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To create a transmission line of 100um
Step2: More detailed examples illustrating how to create various kinds of Media
Step3: For the purpose... |
5,779 | <ASSISTANT_TASK:>
Python Code:
#!pip install --user miepython
import numpy as np
import matplotlib.pyplot as plt
try:
import miepython
except ModuleNotFoundError:
print('miepython not installed. To install, uncomment and run the cell above.')
print('Once installation is successful, rerun this cell again.')
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mie scattering describes the special case of the interaction of light passing through a non-absorbing medium with a single embedded spherical ob... |
5,780 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
5,781 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
%matplotlib inline
# we create 40 separable points in R^2 around 2 centers (random_state=6 is a seed so that the set is separable)
X, y = make_blobs(n_samples=40, n_features=2, centers=2 , random_st... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Support Vector Machines (SVM) are based on learning a vector $w$ and an intercept $b$ such that the hyperplane $w^T x - b = 0$ separates the dat... |
5,782 | <ASSISTANT_TASK:>
Python Code:
dfc = pd.read_csv('./DATA/caracteristiques_2016.csv')
dfu = pd.read_csv('./DATA/usagers_2016.csv')
dfl = pd.read_csv('./DATA/lieux_2016.csv')
df = pd.concat([dfu, dfc, dfl], axis=1)
dfc.tail()
dfu.head()
dfl.tail()
df.head()
df = pd.concat([df, dfl], axis=1)
df.head()
# methode pas prop... | <SYSTEM_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 - Quelle est la poportion Homme/Femme impliquée dans les accidents ? Représenter le résultat sous forme graphique.
Step2: 2 - Quelle est la p... |
5,783 | <ASSISTANT_TASK:>
Python Code:
from google.colab import auth
auth.authenticate_user()
credentials = auth._check_adc()
print(credentials)
from google.cloud import bigquery
from google.cloud import storage
project = "" #@param {type:"string"}
if not project:
raise Exception("Project is empty.")
!gcloud config set 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: Library Imports
Step2: Setup
Step3: Generate the Synthea data
Step4: Generate the data
Step5: Export the data to BigQuery
Step6: Run the fo... |
5,784 | <ASSISTANT_TASK:>
Python Code:
from agents import *
class BlindDog(Agent):
def eat(self, thing):
print("Dog: Ate food at {}.".format(self.location))
def drink(self, thing):
print("Dog: Drank water at {}.".format( self.location))
dog = BlindDog()
print(dog.alive)
class Food(Thing):... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What we have just done is create a dog who can only feel what's in his location (since he's blind), and can eat or drink. Let's see if he's aliv... |
5,785 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from numpy.random import randn
np.random.seed(101)
df = pd.DataFrame(randn(5,4),index='A B C D E'.split(),columns='W X Y Z'.split())
df
df['W']
# Pass a list of column names
df[['W','Z']]
# SQL Syntax (NOT RECOMMENDED!)
df.W
type(df['W'])
df['new'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Selection and Indexing
Step2: DataFrame Columns are just Series
Step3: Creating a new column
Step4: Removing Columns
Step5: Can also drop ro... |
5,786 | <ASSISTANT_TASK:>
Python Code:
%%capture --no-stderr
!pip3 install kfp --upgrade
import kfp.components as comp
dataflow_python_op = comp.load_component_from_url(
'https://raw.githubusercontent.com/kubeflow/pipelines/1.7.0-rc.3/components/gcp/dataflow/launch_python/component.yaml')
help(dataflow_python_op)
!gsutil... | <SYSTEM_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... |
5,787 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-3', 'seaice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_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... |
5,788 | <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: Artistic Style Transfer with TensorFlow Lite
Step2: Download the content and style images, and the pre-trained TensorFlow Lite models.
Step3: ... |
5,789 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tensorflow as tf
#Basic interactive session
# Enter an interactive TensorFlow Session.
sess = tf.InteractiveSession()
# Define a var and a constant
x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])
# Initialize the var 'x' using the run()... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple linear model in a interactive session
Step2: Load and save models
Step3: Save model as pb file
|
5,790 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
slim = tf.contrib.slim
# Import data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
def encoder(x):
Network q(z|x)
with slim.arg_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:
Step2: Encoder
Step4: Note that we use a couple features of TF-Slim here
Step6: Loss
Step8: Visualization
Step9: Define the graph and train
Step10:... |
5,791 | <ASSISTANT_TASK:>
Python Code:
# !pip install ray[tune]
!pip install dragonfly-opt==0.1.6
import numpy as np
import time
import ray
from ray import tune
from ray.tune.suggest import ConcurrencyLimiter
from ray.tune.suggest.dragonfly import DragonflySearch
def objective(config):
Simplistic model of electrical... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Click below to see all the imports we need for this example.
Step3: Let's start by defining a optimization problem.
Step4: Next we define a se... |
5,792 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-1', 'atmos')
# 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... |
5,793 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import os
import openmc
%matplotlib inline
# 1.6% enriched fuel
fuel = openmc.Material(name='1.6% Fuel')
fuel.set_density('g/cm3', 10.31341)
fuel.add_element('U', 1., enrichment=1.6)
fuel.add_element('O', 2.)
# zircaloy
zircaloy = 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: We will begin by creating three materials for the fuel, water, and cladding of the fuel pins.
Step2: With our three materials, we can now creat... |
5,794 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from costcla import datasets
from costcla.datasets.base import Bunch
def load_fraud(cost_mat_parameters=dict(Ca=10)):
# data_ = pd.read_pickle("trx_fraud_data.pk")
data_ = pd.read_pickle("/home/al/DriveAl/EasySol/Projects/DetectTA/Tests/trx_f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data file
Step2: Class Label
Step3: Features
Step4: Features
Step5: Aggregated Features
Step6: Fraud Detection as a classification problem... |
5,795 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import sys
sys.version
import tempfile
import zipfile
import os.path
zipFile = "./openSubtitles-5000.json.zip"
print( "Unarchiving ...")
temp_dir = tempfile.mkdtemp()
zip_ref = zipfile.ZipFile(zipFile, 'r')
zip_ref.extractall(temp_dir)
zip_ref.close()
openSubtitlesF... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unarchive
Step2: Tokenizing and Filtering a Vocabulary
Step3: Feature Vocabulary
Step4: TFIDF Weighting
Step5: K-Means
|
5,796 | <ASSISTANT_TASK:>
Python Code:
# Run some setup code
import numpy as np
import matplotlib.pyplot as plt
# This is a bit of magic to make matplotlib figures appear inline in the notebook
# rather than in a new window.
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParam... | <SYSTEM_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 use the class TwoLayerNet in the file nnet.py to represent instances of our network. The network parameters are stored in the instance v... |
5,797 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import division
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy import signal
import sigutils
sigutils.bode_sys(signal.butter(4, [100*2*np.pi, 200*2*np.pi], analog=True, btype='bandpass'), xlim=(10, 1000), gain_poi... | <SYSTEM_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 a basic Bode plot using scipy.signal to generate the transfer function.
Step2: Here is a plot using bode_syss to plot multiple transfer... |
5,798 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
import pandas as pd
import scipy
from scipy.linalg import norm
from sklearn.base import BaseEstimator, ClassifierMixin
%matplotlib inline
import matplotlib.pyplot as plt
# Ensure consistency across runs.
np.random.seed(1337)
Xtrain = np.genfromtxt('data/Xtra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: Series 3, Online Convex Programming
Step5: Online Support Vector Machine
Step7: Online Logistic Regression
Step8: Analysis of algorithms
Step... |
5,799 | <ASSISTANT_TASK:>
Python Code:
def pconv(f,h):
import numpy as np
h_ind=np.nonzero(h)
f_ind=np.nonzero(f)
if len(h_ind[0])>len(f_ind[0]):
h, f = f, h
h_ind,f_ind= f_ind,h_ind
gs = np.maximum(np.array(f.shape),np.array(h.shape))
if (f.dtype == 'complex') or (h.dtype == '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: Examples
Step2: Numerical Example 1D
Step3: Numerical Example 2D
Step4: Numerical Example 3D
Step5: Example with Image 2D
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.