Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
10,900 | <ASSISTANT_TASK:>
Python Code:
a = 0
dx = 10**-9
for i in range(10**9):
a += dx
print(a)
a = 0
dx = 2**-30
for i in range(2**30):
a += dx
print(a)
a = 2*10**-16
a_ = (1+10**-16)-(1-10**-16)
(a_-a)/a
a = 2*10**-16
a_ = (1-1+10**-16+10**-16)
(a_-a)/a
s = 1
for i in range(10**7):
s+=10**-16
print(s)
s = 0
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: It is not! lets try another example,
Step2: This time the summation seems correct. That is the same as 2/3 = 0.6666...667
Step3: Small numbers... |
10,901 | <ASSISTANT_TASK:>
Python Code:
sum_of_squares = sum([i ** 2 for i in range(1,101)])
square_of_sum = (sum([i for i in range(1,101)])) ** 2
difference = square_of_sum - sum_of_squares
print(difference)
# This cell will be used for grading, leave it at the end of the notebook.
<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: Find the square of the sum of the first 100 natural numbers
Step2: Find and print the difference
Step3: Success!
|
10,902 | <ASSISTANT_TASK:>
Python Code:
# Importing the data
import pandas as pd
import numpy as np
header = ['user_id', 'item_id', 'rating', 'timestamp']
data_movie_raw = pd.read_csv('../data/ml-100k/u.data', sep='\t', names=header)
data_movie_raw.head()
from sklearn.model_selection import train_test_split
# First split into ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Before building any recommendation engines, we'll have to get the data into a useful form. Do this by first splitting the data into testing and... |
10,903 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import display
from distutils.version import LooseVersion as Version
from sklearn import __version__ as sklearn_version
import pandas as pd
# http://archive.ics.uci.edu/ml/datasets/Wine
df_wine = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databas... | <SYSTEM_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.1.2 特徴変換
Step2: 5.1.3 scikit-learn の主成分分析
Step3: 5.2 線形判別分析による教師ありデータ圧縮
Step4: 5.2.2 新しい特徴部分空間の線形判別を選択する
Step5: 5.3.2 新しい特徴空間にサンプルを射影する
St... |
10,904 | <ASSISTANT_TASK:>
Python Code:
import pints
import pints.toy as toy
import numpy as np
import matplotlib.pyplot as plt
# Create two models with a different initial population size
model_1 = toy.LogisticModel(initial_population_size=15)
model_2 = toy.LogisticModel(initial_population_size=2)
# Both models share a single ... | <SYSTEM_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 solve this, we now create two separate problems and define an error measure on each.
Step2: Next, we combine the two error functions in a Su... |
10,905 | <ASSISTANT_TASK:>
Python Code:
from ipyparallel import Client
import os
c = Client()
view = c[:]
print(c.ids)
%%px
def find(name, path):
for root, dirs, files in os.walk(path):
if name in files:
return root
path = find('02_LocalParallelization.ipynb', '/home/')
print(path)
os.chdir(path)
%%px
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: Now, to make the code run on all of our engines (and not just on one), the following cells have to start with the parallel magic command %%px
St... |
10,906 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import json
from pandas.io.json import json_normalize
# define json string
data = [{'state': 'Florida',
'shortname': 'FL',
'info': {'governor': 'Rick Scott'},
'counties': [{'name': 'Dade', 'population': 12345},
{'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: imports for Python, Pandas
Step2: JSON example, with string
Step3: JSON example, with file
Step4: JSON exercise
|
10,907 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
import seaborn as sns
from sklearn import linear_model
import matplotlib.pyplot as plt
import matplotlib as mpl
# read house_train.csv data in pandas dataframe df_train using pandas read_csv function
df_train = pd.read_csv('dataset... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <br>
Step4: Linear Regression with Gradient Descent code
Step5: Run Gradient Descent on training data
Step6: Plot trained line on data
Step7:... |
10,908 | <ASSISTANT_TASK:>
Python Code:
import requests
import base64
r = requests.get("https://api.github.com/repos/gkthiruvathukal/st-hec/contents/hydra/dataserver.py")
print(r.status_code)
r.json().keys()
b64data = r.json().get('content')
lines = base64.b64decode(b64data).decode("utf-8").split('\n')
selected_lines = lines[10... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This shows how to base64 encode text. b64encode() expects bytes and returns bytes (b).
Step2: To get the string representation of bytes, use de... |
10,909 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, OneHotEncoder, StandardScaler
from keras.layers import Input
from keras.layers.core import Dense,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Optimizing out model using Bayesian Optimization!
|
10,910 | <ASSISTANT_TASK:>
Python Code:
# Code Block 1
import numpy as np
from landlab.io import read_esri_ascii
from landlab.plot.imshow import imshow_grid
import matplotlib.pyplot as plt
#below is to make plots show up in the notebook
%matplotlib inline
# Code Block 2
# distance and elevation data along the survey line
fiel... | <SYSTEM_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 will use the survey data from the NC State students and compare it to model output. Below is the information from the survey. You should ... |
10,911 | <ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
from starthinker.util.configuration import Configuration
CONFIG = Configuration(
project="",
client={},
service={},
user="/content/user.json",
verbose=True
)
FIELDS = {
'auth_write':'service', # Credentials used for wri... | <SYSTEM_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. Set Configuration
Step2: 3. Enter Trends Places To Sheets Via Values Recipe Parameters
Step3: 4. Execute Trends Places To Sheets Via Values... |
10,912 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
from actuariat_python.data import wolf_xml
wolf_xml()
import os
if not os.path.exists("wolf-1.0b4.xml"):
raise FileNotFoundError("wolf-1.0b4.xml")
if os.stat("wolf-1.0b4.xml").st_size < 3000000:
raise FileNotFoundErr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Construction de la base de synonymes
Step2: On passe en revue toute la basse (il y a environ 120.000 lignes) et on s'arrête après 10000 synonym... |
10,913 | <ASSISTANT_TASK:>
Python Code:
def calculate_weight(feature):
weight = (1/(max(feature) - min(feature))) ** 2
return weight
price = calculate_weight(np.array([500000, 350000, 600000, 400000], dtype=float))
room = calculate_weight(np.array([3, 2, 4, 2], dtype=float))
lot = calculate_weight(np.array([1840, 1600... | <SYSTEM_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 2
Step2: Question 3
|
10,914 | <ASSISTANT_TASK:>
Python Code:
# Import Module
import numpy as np
import scipy as sp
import scipy.stats as stats
import matplotlib.pyplot as plt
%matplotlib inline
import pandas as pd
# Simulate $\theta$
sp.random.seed(42)
theta1 = sp.random.normal(loc=0.5, scale=0.1, size=1000)
theta2 = sp.random.normal(loc=0.2, scal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simulate data
Step2: Now lets look at the distribution of our coverage counts
Step3: Combine everything into a single dataset.
Step5: QC Time... |
10,915 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
# 导入IRIS数据集
iris = load_iris()
# 特征矩阵
iris.data
# 目标微量
iris.target
from sklearn.preprocessing import StandardScaler
# 标准化,返回值为标准化后的数据
StandardScaler().fit_transform(iris.data)
from sklearn.preprocessing import MinMaxScaler
# 区间缩放,返回值为缩放到[0, 1]区间的数据... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2 数据预处理
Step2: 2.1.2 区间缩放法
Step3: 2.1.3 标准化与归一化的区别
Step4: 2.2 对定量特征二值化
Step5: 2.3 对定性特征哑编码
Step6: 2.4 缺失值计算
Step7: 2.5 数据变换
Step8: 基于单变元函... |
10,916 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df0 = pd.read_csv("../data/interim/001_normalised_keyed_reviews.csv", sep="\t", low_memory=False)
df0.head()
# For monitoring duration of pandas processes
from tqdm import tqdm, tqdm_pandas
# To avoid RuntimeError: Set changed size during iteration
tqdm.monitor_interva... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Follow this link for more info on the tagger
Step2: <span style="color
Step3: Thankfully, nltk provides documentation for each tag, which can ... |
10,917 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import graphviz
import lingam
from lingam.utils import make_dot
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptions(precision=3, suppress=True)
np.random.seed(0)
x3 = np.random.uniform(size=10000)
x0... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test data
Step2: Causal Discovery
Step3: Total Effect
|
10,918 | <ASSISTANT_TASK:>
Python Code:
from azure.identity import AzureCliCredential
from azure.digitaltwins.core import DigitalTwinsClient
# using yaml instead of
import yaml
import uuid
# using altair instead of matplotlib for vizuals
import numpy as np
import pandas as pd
# you will get this from the ADT resource at portal... | <SYSTEM_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 the query object loves to drop values. To keep from making multiple queries, save the data somewhere.
Step3: and a df of the tickets
Step4... |
10,919 | <ASSISTANT_TASK:>
Python Code:
loans = pd.read_csv('lending-club-data.csv')
loans.head(2)
loans.columns
# safe_loans = 1 => safe
# safe_loans = -1 => risky
loans['safe_loans'] = loans['bad_loans'].apply(lambda x : +1 if x==0 else -1)
#loans = loans.remove_column('bad_loans')
loans = loans.drop('bad_loans', axis=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 some features
Step2: Exploring the target column
Step3: 4. Now, let us explore the distribution of the column safe_loans.
Step4: Fe... |
10,920 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.DataFrame({'name':['Jack Fine','Kim Q. Danger','Jane 114 514 Smith', 'Zhongli']})
def g(df):
df.loc[df['name'].str.split().str.len() >= 3, 'middle_name'] = df['name'].str.split().str[1:-1]
for i in range(len(df)):
if len(df.loc[i, 'name'].split(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
10,921 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
%matplotlib inline
import mdtraj as md
import numpy as np
import matplotlib.pyplot as plt
import scipy.cluster.hierarchy
traj = md.load('ala2.h5')
distances = np.empty((traj.n_frames, traj.n_frames))
for i in range(traj.n_frames):
distances[i] =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's load up our trajectory. This is the trajectory that we generated in the "Running a simulation in OpenMM and analyzing the results with mdt... |
10,922 | <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
|
10,923 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import kgof
import kgof.data as data
import kgof.density as density
import kgof.goftest as gof
import kgof.kernel as kernel
import kgof.plot as plot
import kgof.util as util
import matplotlib
import matplotlib.pyplot as plt
import auto... | <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: Define some convenient functions that we will use many times later.
Step8: Interactive 1D mixture model problem
Step10: Goodness-of-fit test
S... |
10,924 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(42)
import tensorflow as tf
tf.set_random_seed(42)
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
lr = 0.1
epochs = 10
batch_size = 128
weight_initializer = tf.contrib.layers.xav... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Set neural network hyperparameters (tidier at top of file!)
Step3: Set number of neurons for each layer
Step4: Define placeh... |
10,925 | <ASSISTANT_TASK:>
Python Code:
# our lib
from lib.resnet50 import ResNet50
from lib.imagenet_utils import preprocess_input, decode_predictions
#keras
from keras.preprocessing import image
from keras.models import Model
import glob
def preprocess_img(img_path):
img = image.load_img(img_path, target_size=(224, 224))... | <SYSTEM_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 Trajectories from User Profile Eval Dataset
Step2: Save
|
10,926 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#outdoor air temperature
oa = pd.read_csv("../data/oa_temp_utc_f.csv");
oa.columns = ['time', 'oa']
oa.set_index("time", drop = True, inplace = True);
oa.index = pd.to_datetime(oa.index)
oa = oa.replace('/', np.nan)
oa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Linear Regression
Step2: Train with separate month using all input
Step3: Train with separate month using outdoor temperature only
Step4: Tra... |
10,927 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import openpnm as op
pn = op.network.Cubic(shape=[3, 3, 3], spacing=1e-4)
print(pn)
oil = op.phases.GenericPhase(network=pn)
print(oil)
oil['pore.molecular_mass'] = 100.0 # g/mol
print(oil['pore.molecular_mass'])
oil['pore.molecular_mass'] = np.ones(shape=[pn.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: Now that a network is defined, we can create a GenericPhase object associated with it. For this demo we'll make an oil phase, so let's call it ... |
10,928 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets.base import Bunch
## The path to the test data sets
FIXTURES = os.path.join(os.getcwd(), "data")
## Dataset loading mechanisms
datasets = {
"reviews": os.path.join(FIXTURES, "reviews")
}
def load_data(name, download=True):
Loads and wrangles the passed ... | <SYSTEM_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 Yellowbrick to Explore Book Reviews
Step2: Visualizing Stopwords Removal
Step3: Visualizing tokens across corpora
Step4: t-SNE
|
10,929 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 기본 훈련 루프
Step2: 머신러닝 문제 해결하기
Step3: 텐서는 일반적으로 배치 또는 입력과 출력이 함께 쌓인 그룹의 형태로 수집됩니다. 일괄 처리는 몇 가지 훈련 이점을 제공할 수 있으며 가속기 및 벡터화된 계산에서 잘 동작합니다. 데이터세트가 ... |
10,930 | <ASSISTANT_TASK:>
Python Code:
# let's load MNIST data as we did in the exercise on MNIST with FC Nets
# %load ../solutions/sol_821.py
## try yourself
## `evaluate` the model on test data
from keras.layers import Input, Embedding, LSTM, Dense
from keras.models import Model
# Headline input: meant to receive sequences... | <SYSTEM_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 2
Step2: Keras supports different Merge strategies
Step3: Here we insert the auxiliary loss, allowing the LSTM and Embedding layer to be ... |
10,931 | <ASSISTANT_TASK:>
Python Code:
names = ['alice', 'jonathan', 'bobby']
ages = [24, 32, 45]
ranks = ['kinda cool', 'really cool', 'insanely cool']
for (name, age, rank) in zip(names, ages, ranks):
print(name, age, rank)
for index, (name, age, rank) in enumerate(zip(names, ages, ranks)):
print(index, name, age, ra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Magics!
Step3: Numpy
Step4: Matplotlib and Numpy
|
10,932 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pymc3 as pm
from pymc3.distributions.timeseries import GaussianRandomWalk
from scipy import optimize
%pylab inline
n = 400
returns = np.genfromtxt("../data/SP500.csv")[-n:]
returns[:5]
plt.plot(returns)
model = pm.Model()
with model:
sigma = pm.Exponential(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Asset prices have time-varying volatility (variance of day over day returns). In some periods, returns are highly variable, while in others very... |
10,933 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
DON'T MODIFY AN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Language Translation
Step3: Explore the Data
Step6: Implement Preprocessing Function
Step8: Preprocess all the data and save it
Step10: Chec... |
10,934 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import sklearn
import sklearn.datasets
from init_utils import sigmoid, relu, compute_loss, forward_propagation, backward_propagation
from init_utils import update_parameters, predict, load_dataset, plot_decision_boundary, predict_dec
%mat... | <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: You would like a classifier to separate the blue dots from the red dots.
Step4: 2 - Zero initialization
Step5: Expected Output
Step6: The per... |
10,935 | <ASSISTANT_TASK:>
Python Code:
!pip install tensorflow
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import tensorflow as tf
import math
!pip install -U okpy
from client.api.notebook import Notebook
ok = Notebook('lab12.ok')
from tensorflow.examples.tut... | <SYSTEM_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 today's lab, we're going to use logistic regression to classify handwritten digits. You'll learn about logistic / softmax regression and Tens... |
10,936 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
# Create dataframe
data = {'Company':['GOOG','GOOG','MSFT','MSFT','FB','FB'],
'Person':['Sam','Charlie','Amy','Vanessa','Carl','Sarah'],
'Sales':[200,120,340,124,243,350]}
df = pd.DataFrame(data)
df
df.groupby('Company')
by_comp = df.groupby("Company")
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <strong>Now you can use the .groupby() method to group rows together based off of a column name.<br>For instance let's group based off of Compan... |
10,937 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mri', 'sandbox-3', 'aerosol')
# 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: 1... |
10,938 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_boston
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import scale
from sklearn.neighbors import KNeighborsRegressor
from sklearn.metrics import mean_squared_error
from sklearn.cross_validation import KFold
import matplot... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
|
10,939 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
PI=np.pi
a=2
theta=np.linspace(3*PI/2, 8*PI, 400)
z=a*theta*np.exp(-1j*theta)
plt.figure(figsize=(6,6))
plt.plot(z.real, z.imag)
plt.axis('equal')
h=7.0
score={0: 0., 1:10./h, 2: 20/h, 3: 30/h, 4: 40/h, 5: 50/h, 6: 60/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Each ray (starting from origin O(0,0)) crosses successive turnings of the spiral at constant distance points, namely at distance=$2\pi a$.
Step... |
10,940 | <ASSISTANT_TASK:>
Python Code:
import gcp.bigquery as bq
%%sql
SELECT
SampleType,
SampleTypeLetterCode,
COUNT(*) AS n
FROM
[isb-cgc:tcga_201607_beta.Biospecimen_data]
GROUP BY
SampleType,
SampleTypeLetterCode,
ORDER BY
n DESC
%%sql
SELECT
SampleTypeLetterCode,
COUNT(*) AS n
FROM (
SELECT
Sampl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Many different types of samples were obtained from the TCGA participants, and details about these samples are available in the Biospecimen data ... |
10,941 | <ASSISTANT_TASK:>
Python Code:
!python --version
!pip install -U html
!pip install -U pyqrcode
!pip install -U config
!pip install -U backports.tempfile
!mv docs org_docs
!yes | pip uninstall itchat
!rm -rf ItChat
!git clone https://github.com/telescopeuser/ItChat.git
!cp -r ItChat/* .
!python setup.py install
!rm -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: Download and install WeChat API-2
Step2: Housekeeping after installation
Step3: If above importing has no error, then installation is successf... |
10,942 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
from __future__ import print_function
import time, os, json
import numpy as np
import matplotlib.pyplot as plt
from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array
from cs231n.rnn_layers import *
from cs231n.captioning_solver ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Captioning with RNNs
Step2: Install h5py
Step3: Microsoft COCO
Step4: Look at the data
Step5: Recurrent Neural Networks
Step6: Vanill... |
10,943 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
%matplotlib inline
pkg_path = '../../python-package/'
model_file = 's3://my-bucket/xgb-demo/model/0002.model'
sys.path.insert(0, pkg_path)
import xgboost as xgb
# plot the first two trees.
bst = xgb.Booster(model_file=model_file)
xgb.plot_importance(bst)
tree_id =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Please change the pkg_path and model_file to be correct path
Step2: Plot the Feature Importance
Step3: Plot the First Tree
|
10,944 | <ASSISTANT_TASK:>
Python Code:
x = list()
x.append(1)
print(x)
y = list()
y.append(1)
y.append(2)
y.append(3)
print(y)
y.append("this is perfectly legal")
y.append(4.2)
y.append(list()) # Inception BWAAAAAAAAAA
print(y)
first_element = y[1]
print(first_element)
print(y)
print(y[0])
print(y)
print(y[-1])
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: Here I've defined an empty list, called x. Like our previous variables, this has both a name (x) and a type (list). However, it doesn't have any... |
10,945 | <ASSISTANT_TASK:>
Python Code:
M = np.array(((2.0, 0.0), ( 0.0, 1.0)))
K = np.array(((3.0,-2.0), (-2.0, 2.0)))
p = np.array(( 0.0, 1.0))
w = 2.0
evals, Psi = eigh(K, M)
Mstar = Psi.T@M@Psi
Kstar = Psi.T@K@Psi
pstar = Psi.T@p
print(evals,end='\n\n')
print(Psi,end='\n\n')
print(Mstar,end='\n\n')
print(Kstar,end='\n\n')... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Computing the eigenvalues and the eigenvectors
Step2: The @ operator stands, in this context, for matrix multiplication.
Step3: Modal Response... |
10,946 | <ASSISTANT_TASK:>
Python Code:
import os
import cv2
import random
import numpy as np
from glob import glob
from PIL import Image, ImageOps
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
!gdown https://drive.google.com/uc?id=1DdGIJ4PZPlF2ikl8mNM9V... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Creating a TensorFlow Dataset
Step2: MIRNet Model
Step3: Dual Attention Unit
Step4: Multi-Scale Residual Block
Step5: MIRNet Model
Step6: T... |
10,947 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact
def char_probs(s):
Find the probabilities of the unique characters in the string s.
Parameters
----------
s : str
A string of characters.
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Character counting and entropy
Step5: The entropy is a quantiative measure of the disorder of a probability distribution. It is used extensivel... |
10,948 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import tweepy
import matplotlib.pyplot as plt
import pymongo
import ipywidgets as wgt
from IPython.display import display
from sklearn.feature_extraction.text import CountVectorizer
import re
from datetime import datetime
%matplotlib inline
api_key ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Authentication keys
Step2: MongoDB Collection
Step6: Starting a Stream
Step8: Connect to a streaming API
Step9: Data Access and Analysis
Ste... |
10,949 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from IPython.display import Image
from numpy import pi
import numpy as np
from qutip import *
from qutip.qip.operations import *
from qutip.qip.circuit import QubitCircuit, Gate
cphase(pi/2)
q = QubitCircuit(2, reverse_states=False)
q.add_gate("CSIGN", controls=[0], ta... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introduction
Step2: Rotation about X-axis
Step3: Rotation about Y-axis
Step4: Rotation about Z-axis
Step5: CNOT
Step6: CSIGN
Step7: Berkel... |
10,950 | <ASSISTANT_TASK:>
Python Code:
def decorator_wo_args(original_function):
def wrapped_function(*args, **kwargs):
print('args:', args, 'kwargs:', kwargs)
out = original_function(*args, **kwargs)
return out
return wrapped_function
@decorator_wo_args
def func_dec_wo_args(func_arg='!... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Decorator with arguments
Step2: Decorator with or without arguments
Step4: Example from NetworkUnit
|
10,951 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import LSTM
from keras.callbacks import ModelCheckpoint
from keras.utils import np_utils
import sys
import re
import pickle
pickle_file = '-basic_data.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, we will import the data we saved previously using the pickle library.
Step2: Now we need to define the Keras model. Since we will be load... |
10,952 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
optim = load_data()
for param_group in optim.param_groups:
param_group['lr'] = 0.0005
<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:
|
10,953 | <ASSISTANT_TASK:>
Python Code:
# Necessary import evil
import physt
from physt import h1, h2, histogramdd
import numpy as np
import matplotlib.pyplot as plt
# Create an empty histogram
h = h1(None, "fixed_width", bin_width=10, name="People height", axis_name="cm", adaptive=True)
h
# Add a first value
h.fill(157)
h.plo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Adding single values
Step2: Adding multiple values at once
Step3: Adding two adaptive histograms together
|
10,954 | <ASSISTANT_TASK:>
Python Code:
plt.figure(figsize(15,10))
sm.tsa.seasonal_decompose(wages.WAG_C_M).plot()
print("Критерий Дики-Фуллера: p=%f" % sm.tsa.stattools.adfuller(wages.WAG_C_M)[1])
wages['wages_box'], lmbda = stats.boxcox(wages.WAG_C_M)
plt.figure(figsize(15,7))
wages.wages_box.plot()
plt.ylabel('Transformed w... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: тренд имеет простую, легко объяснимую инфляцией, структуру
Step2: И визуально, и воспользовашись критерием Дики-Фуллера, мы можем понять, что р... |
10,955 | <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... |
10,956 | <ASSISTANT_TASK:>
Python Code:
import ipywidgets as widgets
# Show all available widgets!
widgets.Widget.widget_types.values()
widgets.FloatSlider(
value=7.5,
min=5.0,
max=10.0,
step=0.1,
description='Test:',
)
widgets.FloatSlider(
value=7.5,
min=5.0,
max=10.0,
step=0.1,
descri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Numeric widgets
Step2: Sliders can also be displayed vertically.
Step3: FloatProgress
Step4: BoundedFloatText
Step5: FloatText
Step6: Boole... |
10,957 | <ASSISTANT_TASK:>
Python Code:
#Importamos las librerías utilizadas
import numpy as np
import pandas as pd
import seaborn as sns
#Mostramos las versiones usadas de cada librerías
print ("Numpy v{}".format(np.__version__))
print ("Pandas v{}".format(pd.__version__))
print ("Seaborn v{}".format(sns.__version__))
#Abrimos... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Representamos ambos diámetros en la misma gráfica
Step2: Mostramos la representación gráfica de la media de las muestras
Step3: Comparativa de... |
10,958 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_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 simple classification model using Keras with Cloud TPUs
Step2: Resolve TPU Address
Step3: FLAGS used as model params
Step5: Download traini... |
10,959 | <ASSISTANT_TASK:>
Python Code:
#Omics Pipe Overview
from IPython.display import Image
Image(filename='/data/chip/2606129465-omics_pipe_overview.png', width=500, height=100)
#Import Omics pipe and module dependencies
import yaml
from omics_pipe.parameters.default_parameters import default_parameters
from ruffus import... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <a id = "config"></a>
Step2: <a id = "params"></a>
Step3: <a id = "pipeline"></a>
Step4: <a id = "results"></a>
Step5: <a id = "qc"></a>
Ste... |
10,960 | <ASSISTANT_TASK:>
Python Code:
song2TrackID = pkl.load(open(fmap, 'rb'))
{ k : song2TrackID[k] for k in sorted(song2TrackID.keys())[:10] }
trackIDs = sorted({trackID for value in song2TrackID.values() for trackID in value})
len(trackIDs)
trackIDs[:10]
%%script false
# TOO slow!
tar = None
flag = None
cnt = 0
for track... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Extract all related track files
|
10,961 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-1', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "e... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
10,962 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.io
import math
import sklearn
import sklearn.datasets
from opt_utils import load_params_and_grads, initialize_parameters, forward_propagation, backward_propagation
from opt_utils import compute_cost, predict, predict_dec, plo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: 1 - Gradient Descent
Step4: Expected Output
Step6: Expected Output
Step8: Expected Output
Step10: Expected Output
Step12: Expected Output
S... |
10,963 | <ASSISTANT_TASK:>
Python Code:
import datetime
import os
import shutil
import matplotlib.pyplot as plt
import tensorflow as tf
print(tf.__version__)
BUCKET = # REPLACE BY YOUR BUCKET
os.environ['BUCKET'] = BUCKET
TRAIN_DATA_PATH = "gs://{bucket}/babyweight/data/train*.csv".format(bucket=BUCKET)
EVAL_DATA_PATH = "gs:/... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set you bucket
Step2: Verify CSV files exist
Step3: Create Keras model
Step6: Lab Task #2
Step8: Lab Task #3
Step10: Lab Task #4
Step12: L... |
10,964 | <ASSISTANT_TASK:>
Python Code:
from dcprogs import read_idealized_bursts
from dcprogs.likelihood import QMatrix
name = "CH82.scn"
tau = 1e-4
tcrit = 4e-3
graph = [["V", "V", "V", 0, 0],
["V", "V", 0, "V", 0],
["V", 0, "V", "V", "V"],
[ 0, "V", "V", "V", 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: Creates the constraints, the likelihood function, as well as a function to create random Q-matrix.
Step2: Performs the minimization
|
10,965 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
matplotlib.rcParams['figure.figsize'] = (12,6)
matplotlib.rcParams['figure.dpi'] = 120
matplotlib.style.use('ggplot')
from biokit.stats import mixture
m = mixture.GaussianMixture(mu=[-2, 1], sigma=[0.5,0.5],
mixture=[.2,.8], N=60)
# data is stored in m.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: gaussian mixture model
Step2: Gaussian Mixture model Fitting (minimization)
Step3: Expectation Minimization
Step4: How EM and minimization co... |
10,966 | <ASSISTANT_TASK:>
Python Code:
import hashlib
import os
import pickle
from urllib.request import urlretrieve
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import resample
from tqdm import tqdm
from zipfil... | <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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this... |
10,967 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import pyedgar
from pyedgar.data_manipulation import tlist_to_flat, flat_to_tlist, delay_embed, lift_function
%matplotlib inline
ntraj = 700
trajectory_length = 40
lag_values = np.arange(1, 37, 2)
embedding_values = lag_values[1:] - 1
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: Load Data and set Hyperparameters
Step2: Load and format the data
Step3: We also convert the data into the flattened format. This converts th... |
10,968 | <ASSISTANT_TASK:>
Python Code:
# Import necessary packages
import tensorflow as tf
import tqdm
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Import MNIST data so we have something for our experiments
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step6: Neural network classes for testing
Step9: There are quite a few comments in the code, so those should answer most of your questions. However, l... |
10,969 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
customers = pd.read_csv("Ecommerce Customers")
customers.head()
customers.describe()
customers.info()
sns.set_palette("GnBu_d")
sns.set_style('whitegrid')
# More time on site... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Get the Data
Step2: Check the head of customers, and check out its info() and describe() methods.
Step3: Exploratory Data Analysis
Step4: Do ... |
10,970 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_regression
X0, y, coef = make_regression(n_samples=100, n_features=1, noise=20, coef=True, random_state=0)
dfX0 = pd.DataFrame(X0, columns=["X1"])
dfX = sm.add_constant(dfX0)
dfy = pd.DataFrame(y, columns=["y"])
model = sm.OLS(dfy, dfX)
result = model.fit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 다음으로 이 데이터에서 중복을 허락하여 N개의 데이터를 선택한 후 다시 회귀 분석을 한다. 이론적으로 $2^{100}$개의 경우가 있지만 1,000번만 반복해 본다. N은 임의로 정해둔 것이다.
Step2: 전체 가중치 집합을 히스토그램으로 나타내면 다음과... |
10,971 | <ASSISTANT_TASK:>
Python Code:
# Useful Functions
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
l = np.random.randint(1,100, size=1000)
s = pd.Series(l)
## Your code goes here
## Your code goes here
## Your code goes here
## Your code goes here
## Your code goes here
## Your code goes here
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise 1
Step2: b. Accessing Series Elements.
Step3: c. Boolean Indexing.
Step4: Exercise 2
Step5: b. Resampling
Step6: Exercise 3
Step... |
10,972 | <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... |
10,973 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import sympy as sym
import solowpy
solow.Model.output?
# define model variables
A, K, L = sym.symbols('A, K, L')
# define production parameters
alpha, sigma = sym.symbols('alpha, sigma')
# define a production function
cobb_douglas_output = K**alpha * (A * L)**(1 - alp... | <SYSTEM_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 Creating an instance of the solow.Model class
Step2: Examples
Step3: 1.2 Defining model parameters
Step4: In addition to the standard param... |
10,974 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import time
import numpy as np
import matplotlib.pyplot as plt
from cs231n.classifiers.fc_net import *
from cs231n.data_utils import get_CIFAR10_data
from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array
from cs231n.solver impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Batch Normalization
Step2: Batch normalization
Step3: Batch Normalization
Step4: Batch Normalization
Step5: Fully Connected Nets with Batch ... |
10,975 | <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'
path_A = datasets_dir + os.sep + 'dblp_demo.csv'
path_B = datasets_dir + os.sep + 'acm_demo.csv'
path_la... | <SYSTEM_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 matching purposes.
Step2: Then, split the labeled data into development set and evaluation set. Use th... |
10,976 | <ASSISTANT_TASK:>
Python Code:
fname = io.download_occultation_times(outdir='../data/')
print(fname)
tlefile = io.download_tle(outdir='../data')
print(tlefile)
times, line1, line2 = io.read_tle_file(tlefile)
tstart = '2021-04-29T14:20:00'
tend = '2021-04-29T23:00:00'
orbits = planning.sunlight_periods(fname, tstart, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download the NuSTAR TLE archive.
Step2: Here is where we define the observing window that we want to use.
|
10,977 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from IPython.display import FileLink
from exact_solvers import acoustics_demos
def make_bump_animation_html(numframes, file_name):
video_html = acoustics_demos.bump_animation(numframes)
f = open(file_name,'w')
f.write('<html>\n')
file_name = 'acoustics_... | <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: Acoustics
Step5: Burgers
|
10,978 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from sklearn.metrics import confusion_matrix
import math
tf.__version__
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('data/MNIST/', one_hot=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: This was developed using Python 3.6 (Anaconda) and TensorFlow version
Step2: Load Data
Step3: The MNIST data-set has now been loaded and consi... |
10,979 | <ASSISTANT_TASK:>
Python Code:
import pymysql
db = pymysql.connect(
"db.fastcamp.us",
"root",
"dkstncks",
"sakila",
charset='utf8',
)
rental_df = pd.read_sql("SELECT * FROM rental;", db)
inventory_df = pd.read_sql("SELECT * FROM inventory;", db)
film_df = pd.read_sql("SELECT * FROM film;", db)
film_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 5T_데이터 분석을 위한 SQL 실습 (4) - SQL Advanced
Step3: Store 1의 등급별 매출 중 "R", "PG-13"의 매출
Step6: 배우별 매출
|
10,980 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import pandas as pd
from cegads import ScenarioFactory
factory = ScenarioFactory()
wet_appliance_keys = ['Washing Machine', 'Dishwasher', 'Tumble Dryer', 'Washer-dryer']
df = factory._data.stack().unstack(level=0)
f, [ax1,ax2] = plt.subplots(1, 2, figsize=(12, 4))
for key ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: cegads.Scenario
Step2: The default ScenarioFactory inherits from the ECUK class which loads the full ECUK dataset. The ScenarioFactory loads da... |
10,981 | <ASSISTANT_TASK:>
Python Code:
import facebook
import simplejson as json
import requests
req = requests.get('http://python.org')
req.status_code # Se o código for 200, a requisição foi realizada.
#req.text
'Python' in req.text
req.close()
import facebook
access_token = 'EAACEdEose0cBAAFGsk2U0Jo1Kn9GZCWuXoMwflMusq2ajI... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: O módulo requests é utilizado para fazer requisições HTTP, ele será útil para que possamos requisitar novas páginas com conteúdo do Facebook.
St... |
10,982 | <ASSISTANT_TASK:>
Python Code:
from tinylearn import KnnDtwClassifier
from tinylearn import CommonClassifier
import pandas as pd
import numpy as np
import os
train_labels = []
test_labels = []
train_data_raw = []
train_data_hist = []
test_data_raw = []
test_data_hist = []
# Utility function for normalizing numpy arrays... | <SYSTEM_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 plot several selected histograms for the train data
Step2: Before we will explore the classification with histograms let's try the defaul... |
10,983 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
from scipy.spatial import Delaunay
from metpy.gridding.triangles import find_natural_neighbors
# Create test observations, test points, and plot the triangulation and points.
gx, gy = np.meshgrid(np.arange(0, 20, 4), np.arange(0, 20, 4))
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Since finding natural neighbors already calculates circumcenters and circumradii, return
Step2: We can then use the information in tri_info lat... |
10,984 | <ASSISTANT_TASK:>
Python Code:
import torch
import sys
import torch
from torch.utils.data.dataset import Dataset
from torch.utils.data import DataLoader
from torchvision import transforms
from torch import nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
from sklearn im... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: CUDA
Step2: Global params
Step3: Load a CSV file for Binary classification (numpy)
Step4: Feature enrichement
Step5: Train / Validation / Te... |
10,985 | <ASSISTANT_TASK:>
Python Code:
# numerical derivative at a point x
def f(x):
return x**2
def fin_dif(x,
f,
h = 0.00001):
'''
This method returns the derivative of f at x
by using the finite difference method
'''
return (f(x+h) - f(x))/h
x = 2.0
print "{:2.4f}".format(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: The limit as $h$ approaches zero, if it exists, should represent the slope of the tangent line to $(x, f(x))$.
Step2: It can be shown that the... |
10,986 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.random.seed(42)
import tensorflow as tf
tf.set_random_seed(42)
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
lr = 0.1
epochs = 10
batch_size = 128
weight_initializer = tf.contrib.layers.xav... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data
Step2: Set neural network hyperparameters (tidier at top of file!)
Step3: Set number of neurons for each layer
Step4: Define placeh... |
10,987 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import numpy as np
import matplotlib.pyplot as plot
from scipy.integrate import trapz,cumtrapz
from IPython.html.widgets import interact, interactive
def distribute1D(x,prob,N):
takes any distribution which is directly proportional
to the number of particles, and 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: Quantum Double-slit Experiment
Step2: Now define the double_slit function and make it interactive
|
10,988 | <ASSISTANT_TASK:>
Python Code:
Vx = V('V_x').Voc
I = (cct.V1.V - 4 * Vx) / (cct.R1.Z + cct.R2.Z)
I * cct.R1.Z
cct.V1.V - I * cct.R1.Z
cct.Ox.V
cct['x'].V
cct.R1.I
<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 given the current, we can use Ohm's law to determine the voltage drop across R1.
Step2: Thus we know that $V_x = 3 V_x + 2$ or $V_x = -1$. ... |
10,989 | <ASSISTANT_TASK:>
Python Code:
fname = io.download_occultation_times(outdir='../data/')
print(fname)
tlefile = io.download_tle(outdir='../data')
print(tlefile)
times, line1, line2 = io.read_tle_file(tlefile)
tstart = '2021-07-30T18:00:00'
tend = '2021-07-30T23:00:00'
orbits = planning.sunlight_periods(fname, tstart, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download the NuSTAR TLE archive.
Step2: Here is where we define the observing window that we want to use.
|
10,990 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib.pyplot import *
plot([1,2,3,4])
plot([1,2,3,4],[1,4,9,16])
plot([1,2,3,4],[1,4,9,16],'or') # 'o' for dots, 'r' for red
scatter([1,2,3,4],[1,4,9,16])
from numpy import *
x = linspace(-2,2)
y = x**3-x
plot(x,y)
x = linspace(-3,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: Here is about the simplest plot command you can get.
Step2: You can also plot y versus x values, as follows
Step3: You can use various modifie... |
10,991 | <ASSISTANT_TASK:>
Python Code:
# Define the p, d and q parameters to take any value between 0 and 2
p = d = q = range(0, 5)
# Generate all different combinations of p, q and q triplets
pdq = list(itertools.product(p, d, q))
# Generate all different combinations of seasonal p, q and q triplets
seasonal_pdq = [(x[0], x[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: We can now use the triplets of parameters defined above to automate the process of training and evaluating ARIMA models on different combination... |
10,992 | <ASSISTANT_TASK:>
Python Code:
import urllib.request as urllib, zipfile, os
url = 'http://download.maxmind.com/download/worldcities/'
filename = 'worldcitiespop.txt.gz'
datafolder = 'data/'
downloaded = urllib.urlopen(url + filename)
buf = downloaded.read()
try:
os.mkdir(datafolder)
except FileExistsError:
pass... | <SYSTEM_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 manipulation
Step2: By sorting the cities on population we immediately see the entries of a few of the largest cities in the world.
Step3:... |
10,993 | <ASSISTANT_TASK:>
Python Code:
# Installs fauxtograph, its dependencies, scipy, and h5py.
!pip install --upgrade fauxtograph; pip install h5py; pip install scipy
# Optionally uncomment the line below and run for GPU capabilities.
# !pip install chainer-cuda-deps
# Optionally uncomment the line below to use wget to down... | <SYSTEM_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'll import the VAE and GAN model classes from fauxtograph as well as the dependencies to read the dataset and display images in the notebo... |
10,994 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
# Plot a normal distribution with mean = 0 and standard deviation = 2
xs = np.linspace(-6,6, 300)
normal = stats.norm.pdf(xs)
plt.plot(xs, normal);
# Generate x-values for which we will plot the distribution
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sometimes mean and variance are not enough to describe a distribution. When we calculate variance, we square the deviations around the mean. In ... |
10,995 | <ASSISTANT_TASK:>
Python Code:
# sets the plots to be embedded in the notebook
%matplotlib inline
# Import useful python libraries
import numpy as np # library to work with arrays
import matplotlib.pyplot as plt # plotting library (all weird commands starting with plt., ax., fig. are 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: Define the $\frac{d\Gamma}{d\cos\theta}$ function, using the angle $\theta$ and the muon polarization $P_{\mu}$ as input variables
Step2: We ar... |
10,996 | <ASSISTANT_TASK:>
Python Code:
# setup
import numpy as np
import sympy as sp
import scipy
from scipy import linalg
from pprint import pprint
sp.init_printing(use_latex='mathjax')
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (12, 8) # (width, height)
plt.rcParams['font.size'] = 14
plt.rcParams['leg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Math with Python
Step2: Logical Indexing
Step3: numpy arrays as a matrix
Step4: $ 3 x_0 + x_1 = 9 $
Step5: Symbolic Math with Sympy
Step6: ... |
10,997 | <ASSISTANT_TASK:>
Python Code:
import os
import string
import random
import pickle
import nltk
from nltk.corpus import gutenberg
#nltk.download("gutenberg")
gutenberg.fileids()
corpus_path = os.path.join(os.getcwd(), 'guten_test')
corpus_path
%%time
decoded_gutencorpus = []
for document_name in gutenberg.fileids():... | <SYSTEM_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 nltk gutenberg corpus, if not downloaded already
Step2: files in test data
Step3: preparing input
Step4: the library takes as inp... |
10,998 | <ASSISTANT_TASK:>
Python Code:
from pyspark import SparkConf, SparkContext
import re
sc
partitions = 18
parlog = sc.textFile("/lustre/janus_scratch/dami9546/lustre_debug.out", partitions)
parlog.take(5)
words = parlog.map(lambda line: re.split('\W+', line.lower().strip()))
words.take(2)
mfds = words.filter(lambda ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This dataset is a debug dump from a Lustre filesystem. Typically these events occur due to code bugs (LBUG), heavy load, hardware problems, or ... |
10,999 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from stingray import Lightcurve
from stingray.crosscorrelation import CrossCorrelation
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
%matplotlib inline
font_prop = font_manager.FontProperties(size=16)
dt = 0.03125 # seconds
exposure = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: CrossCorrelation Example
Step2: Now let's turn noisy_1 and noisy_2 into Lightcurve objects. This way we have two Lightcurves to calculate Cross... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.