Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
10,100 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
%matplotlib inline
import numpy as np
from sklearn.linear_model import LogisticRegression
df = pd.read_csv('../data/hanford.csv')
df.corr()
df.describe()
Q1 = df['Exposure'].quantile(q=0.25)
Q1
Q2 = df['Exposure'].quantile(q=0.5)
Q2
Q3 = df['Exposure'].quantile(q=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: 2. Read in the hanford.csv file in the data/ folder
Step2: <img src="../../images/hanford_variables.png"></img>
Step3: 4. Find a reasonable th... |
10,101 | <ASSISTANT_TASK:>
Python Code:
import nbtlib
nbt_file = nbtlib.load('nbt_files/bigtest.nbt')
nbt_file['stringTest']
uncompressed_file = nbtlib.load('nbt_files/hello_world.nbt', gzipped=False)
uncompressed_file.gzipped
little_endian_file = nbtlib.load('nbt_files/hello_world_little.nbt', byteorder='little')
little_endi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: By default nbtlib.load will figure out by itself if the specified file is gzipped, but you can also use the gzipped= keyword only argument if yo... |
10,102 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from matplotlib import pyplot, cm
%matplotlib inline
nx = 41
ny = 41
nt = 1000
nit = 50
c = 1
dx = 1. / (nx - 1)
dy = 1. / (ny - 1)
x = np.linspace(0, 1, nx)
y = np.linspace(0, 1, ny)
Y, X = np.meshgrid(x, y)
rho = 1
nu = .1
dt = .001
u = np.zeros((nx, ny))
v = np.zero... | <SYSTEM_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 pressure Poisson equation that's written above can be hard to write out without typos. The function build_up_b below represents the contents... |
10,103 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
vgg_dir = 'tensorflow_vgg/'
# Make sure vgg exists
if not isdir(vgg_dir):
raise Exception("VGG directory doesn't exist!")
class DLProgress(tqdm):
last_block = 0
def hook(self, block_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Flower power
Step2: ConvNet Codes
Step3: Below I'm running images through the VGG network in batches.
Step4: Building the Classifier
Step5: ... |
10,104 | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
Vp = 600 # [V]
Vl = 120 # [V] which is also the load voltage
Vh = 480 # [V]
Sw = 10e3 # [VA]
n = Vh/Vl # = Nse/Nc
Sio = (n + 1)/n * Sw
print('''
Sio = {:.1f} kVA
==============
'''.format(Sio/1000))
Ip = Sio/Vp
print('''
Ip = {:.2f} A
============
'''.format(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: Description
Step2: (a)
Step3: (c)
Step4: and the maximum secondary current is
|
10,105 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
import socnet as sn
sn.graph_width = 360
sn.graph_height = 360
sn.node_size = 25
def load_graph(path):
g = sn.load_graph(path, has_pos=True)
for n, m in g.edges():
g.edge[n][m]['strong'] = bool(g.edge[n][m]['strong'])
return g
def set_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Configurando a biblioteca
Step2: O objetivo desta atividade é escrever uma simulação animada de negociações e executá-la sobre seis grafos dife... |
10,106 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
%%bash
# Check your project name
export PROJECT=$(gcloud config list project --format "value(core.project)")
echo "Your current GCP Project Name is: "$PROJECT
import os
os.environ["BUCKET"] = "your-bucket-id-here" # Recomm... | <SYSTEM_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 3
Step2: Run the below cell, and copy the output into the Google Cloud Shell
|
10,107 | <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: Autoencoder 소개
Step2: 데이터세트 로드하기
Step3: 첫 번째 예
Step4: x_train을 입력과 대상으로 사용하여 모델을 훈련합니다. encoder는 데이터세트를 784차원에서 잠재 공간으로 압축하는 방법을 배우고, decoder... |
10,108 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from mpl_toolkits.mplot3d import * #3D-s ábrák alcsomagja
from ipywidgets import * #interaktivitáshoz szükséges függvények
t=linspace(0,2*pi,100) # 100 pont 0 és 2*pi között
ax=subplot(1,1,1,projection='3d') #térbeli koordináta tengely létrehozása
ax.plot(cos(3*t),si... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Térbeli görbék, adathalmazok
Step2: A következő kódcellában két dolog fog történni. Előszöris létrehozzuk az ax nevű axes objektumot, amelynek... |
10,109 | <ASSISTANT_TASK:>
Python Code:
base_url = "https://pydata.org"
r = rq.get(base_url + "/berlin2017/schedule/")
bs = bs4.BeautifulSoup(r.text, "html.parser")
data = {}
for ahref in tqdm_notebook(bs.find_all("a")):
if 'schedule/presentation' in ahref.get("href"):
url = ahref.get("href")
else:
cont... | <SYSTEM_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 query every talk description
Step2: Okay, make a dataframe and add some helpful columns
Step3: Show Profile Report of Pandas DF
Step4: ... |
10,110 | <ASSISTANT_TASK:>
Python Code:
# This makes plots appear in the notebook
%matplotlib inline
import numpy as np # numpy is the major library in which siamxt was built upon
# we like the array programming style =)
# We are using PIL to read images
from PIL import Image
# and matplotlib to 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: Area-open filter
Step2: Extinction filter
Step3: Bounding-box filter
Step4: Max-tree area signature analysis
|
10,111 | <ASSISTANT_TASK:>
Python Code:
x = 1
y = 2
y != x
if temperature < 20 and minutes > 12:
print("The temperature is in the danger zone.")
if temperature < 20 or temperature > 100:
print("The temperature is too extreme.")
if not(temperature > 100):
print("This is below the maximum temperature.")
x = 5
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: Logical Operators
Step2: or
Step3: Short Circuit Evaluation
Step4: Let's try
Step5: Checking Numerical Ranges
Step7: Repetition Structures
... |
10,112 | <ASSISTANT_TASK:>
Python Code:
# 检查你的Python版本
from sys import version_info
if version_info.major != 3:
raise Exception('请使用Python 3.x 来完成此项目')
# 引入这个项目需要的库
import numpy as np
import pandas as pd
import visuals as vs
from IPython.display import display # 使得我们可以对DataFrame使用display()函数
# 设置以内联的形式显示matplotlib绘制的图片(在not... | <SYSTEM_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: 问题 1
Step4: 问题 2
Step5: 问题 3
Step6: 观察
Step7: 练习
Step8: 问题 4
Step9: 问题 5
Step10: 练习:降维
Step11: 观察
Step12: 可视化一个... |
10,113 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import localgroup
import triangle
import sklearn
from sklearn import mixture
import numpy as np
import pickle
import matplotlib.patches as mpatches
L = localgroup.Likelihood(isPair=True)
L.generate(Nsamples=200000)
L.set_PDF(mixture.GMM(n_components=10, covariance_type... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Inside the Likelihood object is a "triplet" object called T, which contains an array of sample local groups, each with kinematic parameters cons... |
10,114 | <ASSISTANT_TASK:>
Python Code:
! arena data list
KFP_SERVICE="ml-pipeline.kubeflow.svc.cluster.local:8888"
KFP_PACKAGE = 'http://kubeflow.oss-cn-beijing.aliyuncs.com/kfp/0.1.14/kfp.tar.gz'
KFP_ARENA_PACKAGE = 'http://kubeflow.oss-cn-beijing.aliyuncs.com/kfp-arena/kfp-arena-0.3.tar.gz'
KUBEFLOW_PIPELINE_LINK = ''
MOUNT... | <SYSTEM_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 necessary environment variables and install the KubeFlow Pipeline SDK
Step2: Install the necessary python packages
Step3: Note
Step... |
10,115 | <ASSISTANT_TASK:>
Python Code:
from sklearn import tree
import pandas as pd
import pandas_datareader as web
import numpy as np
df = web.DataReader('goog', 'yahoo', start='2012-5-1', end='2016-5-20')
df['B/S'] = (df['Close'].diff() < 0).astype(int)
closing = (df.loc['2013-02-15':'2016-05-21'])
ma_50 = (df.loc['2013-02-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:
|
10,116 | <ASSISTANT_TASK:>
Python Code:
from pyspark.mllib.recommendation import Rating
new_user_ID = 0
new_user_ratings = [
Rating(0,260,9), # Star Wars (1977)
Rating(0,1,8), # Toy Story (1995)
Rating(0,16,7), # Casino (1995)
Rating(0,25,8), # Leaving Las Vegas (1995)
Rating(0,32,9), # 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 the original rating dataset
Step2: Join the new user ratings with the orginal dataset
Step3: Re-train the model
Step4: Save the model
St... |
10,117 | <ASSISTANT_TASK:>
Python Code:
# Install the specified package
!pip install tensorflow_decision_forests
# Install the specified package
!pip install wurlitzer
# Import necessary libraries
import tensorflow_decision_forests as tfdf
import os
import numpy as np
import pandas as pd
import tensorflow as tf
import math
tr... | <SYSTEM_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 ignore incompatible errors.
Step2: Importing libraries
Step3: The hidden code cell limits the output height in colab.
Step4: Training ... |
10,118 | <ASSISTANT_TASK:>
Python Code:
#Imports
from math import *
import numpy as np
import scipy as sp
import scipy.special
import scipy.interpolate as interpolate
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import seaborn as sns
import sys
import os
#Import custom modules
from p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: Espec functions
Step11: Data read functions
Step12: Load data and subtract background
Step13: Mesh plot all unsaturated data
Step14: Plot av... |
10,119 | <ASSISTANT_TASK:>
Python Code:
# Packages
import numpy as np
from testCases import *
from gc_utils import sigmoid, relu, dictionary_to_vector, vector_to_dictionary, gradients_to_vector
# GRADED FUNCTION: forward_propagation
def forward_propagation(x, theta):
Implement the linear forward propagation (compute J... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: 1) How does gradient checking work?
Step4: Expected Output
Step6: Expected Output
Step8: Expected Output
Step10: Now, run backward propagati... |
10,120 | <ASSISTANT_TASK:>
Python Code:
# To use interactive plots (mouse clicks, zooming, panning) we use the notebook back end. We want our graphs
# to be embedded in the notebook, inline mode, this combination is defined by the magic "%matplotlib notebook".
%matplotlib notebook
import numpy as np
import SimpleITK as sitk
imp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load Data
Step2: Manual Landmark Localization
Step3: Registration (manual landmark localization)
Step4: We can also evaluate the registration... |
10,121 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -u -v -d -p matplotlib,numpy
%matplotlib inline
import matplotlib.pyplot as plt
# input data
mean_values = [1, 2, 3]
variance = [0.2, 0.4, 0.5]
bar_labels = ['bar 1', 'bar 2', 'bar 3']
# plot bars
x_pos = list(range(len(bar_labels)))
plt.bar(x_pos, mean_va... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font size="1.5em">More info about the %watermark extension</font>
Step2: <br>
Step3: <br>
Step4: <br>
Step5: <br>
Step6: <br>
Step7: <br>... |
10,122 | <ASSISTANT_TASK:>
Python Code:
from typing import List
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import sklearn
% matplotlib inline
sample = [1, 3, 5, 6]
np.mean(sample)
pd.DataFrame(sample).mean()
np.var(sample)
# Warning! Pandas variance by default is normalized ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Chapter 01
Step2: Variance
Step3: Standard Deviation
Step4: Effect size - Cohen'd
Step5: It is calculated with delta degree of freedom = 1!
... |
10,123 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import networkx as nx
# A SIMPLE EXAMPLE
G=nx.Graph()
G.add_node("a")
G.add_node("b")
G.add_node("c")
G.add_node("d")
G.add_node("e")
G.add_node("f")
G.add_edge('a', 'c')
G.add_edge('b', 'c')
G.add_edge('e', 'd')
G.add_edge('c', 'e')
G.ad... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implicit node creation on edge add
Step2: Just a touch of computational theory
|
10,124 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import tensorflow as tf
from os import path, remove
import numpy as np
import pandas as pd
import csv
from sklearn.model_selection import StratifiedShuffleSplit
from time import time
from matplotlib import pyplot as plt
import seaborn as sns
from mylibs.jup... | <SYSTEM_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 0 - hyperparams
Step2: Once generate data
Step3: Step 1 - collect data
Step4: Step 2 - Build model
Step5: Step 3 training the network
S... |
10,125 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import csv
import io
import urllib.request
import matplotlib.pyplot as plt
from datetime import datetime
import numpy as np
url = 'https://radwatch.berkeley.edu/sites/default/files/pictures/rooftop_tmp/weather.csv'
response = urllib.request.urlopen(url)
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: The following module creates a pi chart that illustrates the breakdown of which isotope is measured to have the highest concentration during the... |
10,126 | <ASSISTANT_TASK:>
Python Code:
# data analysis and manipulation
import numpy as np
import pandas as pd
np.set_printoptions(threshold=1000)
# visualization
import seaborn as sns
import matplotlib.pyplot as plt
#machine learning
import tensorflow as tf
#Regular expression
import re
all_data = pd.read_csv('datasets/Colle... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Acqure Data
Step2: Analyze Data
Step3: Find information about the features
Step4: There are 7703 examples and 1743 features.
Step5: There ar... |
10,127 | <ASSISTANT_TASK:>
Python Code:
!wget -O - "https://archive.ics.uci.edu/ml/machine-learning-databases/00217/C50.zip" > /tmp/C50.zip
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', level=logging.DEBUG, datefmt='%I:%M:%S')
import zipfile
filename = '/tmp/C50.zip'
zip_ref = zipfile.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:
Step1: We wrap all the preprocessing steps, that you can find more about in the author-topic notebook , in one fucntion so that we are able to iterate ... |
10,128 | <ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import scipy as sp
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Note: statsmodels requires scipy 1.2
import statsmodels.formula.api as sm
from sklearn.datasets import make_regression
from sklearn.linear_model import LinearRegression
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Random Test Data
Step2: Statsmodels Results
Step3: Scikit-Learn Cook's Distance
|
10,129 | <ASSISTANT_TASK:>
Python Code:
# Author: Denis A. Engemann <denis.engemann@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
import os
import numpy as np
from mne import io
from mne.datasets import sample
from mne.minimum_norm import apply_inverse_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: Set parameters
Step2: Decoding in sensor space using a linear SVM
|
10,130 | <ASSISTANT_TASK:>
Python Code:
X = np.zeros(10)
for i in range(len(X)):
X[i] = np.random.normal(5,1)
X
class RWMH:
def __init__(self, X):
self.mu = 2
self.freedom = 5.0
self.x_var = np.mean(X)
def prior_dist(self, t):
ft = math.gamma((self.freedom+1.0)/2.0)/(math.sq... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: [ベイズ推論]</P>
Step2: $\mu$の事前分布に無情報事前分布を仮定する。
|
10,131 | <ASSISTANT_TASK:>
Python Code:
from pynq import Overlay
Overlay("base.bit").download()
from pynq.drivers.video import HDMI
hdmi_out = HDMI('out')
hdmi_out.start()
# monitor configuration: 640*480 @ 60Hz
hdmi_out.mode(HDMI.VMODE_640x480)
hdmi_out.start()
# monitor (output) frame buffer size
frame_out_w = 1920
frame_ou... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step 1
Step1: Step 2
Step2: 2. Applying OpenCV filters on Webcam input
Step 1
Step3: Step 2
Step4: Step 3
Step5: Step 4
Step6: Step 5
Step7: Step... |
10,132 | <ASSISTANT_TASK:>
Python Code:
import os
import csv
import time, random
import re
lang_from, lang_to = 'en', 'ko'
data_path = './data'
stub_from, stub_to = set(),set()
stub_matcher = re.compile(r"(.*)\-(\w+)\.csv")
for fname in os.listdir(data_path):
#print(fname)
m = stub_matcher.match(fname)
if 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: Go through all the files in the directory, and find the source prefixes that have both lang_from and lang_to CSVs available.
Step2: Now, go thr... |
10,133 | <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: Post-training integer quantization with int16 activations
Step2: Check that the 16x8 quantization mode is available
Step3: Train and export th... |
10,134 | <ASSISTANT_TASK:>
Python Code:
# Make sure division of integers does not round to the nearest integer
from __future__ import division
import sys
sys.path.insert(0, '..') # Look for modules in directory above this one
# Make everything in python's symbolic math package available
from sympy import * # Make sure sympy fun... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Fundamental variables
Step2: Derived variables
Step3: The system's vector basis is given by $(\hat{\ell}, \hat{n}, \hat{\lambda})$, and will b... |
10,135 | <ASSISTANT_TASK:>
Python Code:
tmp = train.isnull().sum()
# get top 10 results
tmp.sort_values(ascending=False).head(10).plot(kind='bar', figsize=(8,8))
drop_cols = ['PoolQC','MiscFeature','Alley','Fence']
# write custom transformer to drop these 4 cols for use in Pipeline later
from sklearn.base import BaseEstimator,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: One way to handle this is to drop the first 4, given that almost all observations are missing.
Step2: Many features (e.g. LotArea, GarageCars) ... |
10,136 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
from tsfresh import extract_features, select_features
from tsfresh.utilities.dataframe_functions import roll_time_series, make_forecasting_frame
from tsfresh.utilities.dataframe_functions import imput... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading the data
Step2: We want to make the time dependency a bit clearer and add an identifier to each of the stock values (in this notebook w... |
10,137 | <ASSISTANT_TASK:>
Python Code:
crcom = pd.read_csv('/home/wcmckee/Downloads/List of CC schools - Sheet1.csv', skiprows=5, index_col=0, usecols=[0,1,2])
#crcom
aqcom = pd.read_csv('/home/wcmckee/Downloads/List of CC schools - Sheet1.csv', skiprows=6, usecols=[0])
aqjsz = aqcom.to_json()
dicthol = json.loads(aqjsz)
dsch... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compare the schools on List of CC schools with list of all public/private schools.
Step2: Cycle through only first 89 values - stop when reach... |
10,138 | <ASSISTANT_TASK:>
Python Code:
# Create a sample of Gaussian draws
np.random.seed(0)
x_data = np.random.randn(1000)
fig = plt.figure(padding_y=0)
hist = plt.bin(x_data, padding=0)
fig
hist.x, hist.y
fig = plt.figure(padding_y=0)
hist = plt.bin(x_data, padding=0)
fig
# Changing the number of bins
hist.bins = "sqrt"
#... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Give the Hist mark the data you want to perform as the sample argument, and also give 'x' and 'y' scales.
Step2: The midpoints of the resulting... |
10,139 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import pyplot
%matplotlib inline
from matplotlib.patches import Rectangle
from matplotlib.lines import Line2D
import numpy
from scipy.io import wavfile
from os import path
from datetime import timedelta
from django.db import connection
from database.models import Sound
fro... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: variable definitions
Step2: example recording 1
Step3: example recording 2
Step4: formating
Step5: remove noise
Step6: plot
Step7: save fi... |
10,140 | <ASSISTANT_TASK:>
Python Code:
# 定义字典
# 访问字典中的 key-value
d = {'Tom': 95, 'Mary': 90, 'Tracy': 92}
print(d)
print(d['Tom'])
# 字典增加元素,直接定义值即可
d['Hugo'] = 85
print(d)
# 修改字典元素的值
d['Tom'] = 97
print(d)
# 字典是否存在某个 key
print('Tom' in d)
# 如果要获得不存在的 key 的 value,可以设置默认值
print(d.get('Tommy',80))
# 去获得不存在的 key 的 value,会报错
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: 元组Tuple 用法
Step2: 思考
Step3: 词性
|
10,141 | <ASSISTANT_TASK:>
Python Code:
import ants
image = ants.image_read(ants.get_ants_data('r16'))
image2 = ants.image_read(ants.get_ants_data('r64'))
aff = ants.registration( image, image2, "Affine" )
g1 = ants.iMath_grad( image )
g2 = ants.iMath_grad( image2 )
reg1 = ants.registration( image, image2, 'SyNOnly', initial_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: Perform a baseline registration with a single feature and create a couple of new metrics. Each metric is defined by a name ("CC"), the input fi... |
10,142 | <ASSISTANT_TASK:>
Python Code:
import graphlab
graphlab.product_key.set_product_key("C0C2-04B4-D94B-70F6-8771-86F9-C6E1-E122")
sales = graphlab.SFrame('kc_house_data_small.gl/kc_house_data_small.gl')
import numpy as np # note this allows us to refer to numpy as np instead
def get_numpy_data(data_sframe, features, out... | <SYSTEM_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 house sales data
Step2: Import useful functions from previous notebooks
Step3: We will also need the normalize_features() function fro... |
10,143 | <ASSISTANT_TASK:>
Python Code:
import pymysql
db = pymysql.connect(
"db.fastcamp.us",
"root",
"dkstncks",
"sakila",
charset='utf8',
)
customer_df = pd.read_sql("SELECT * FROM customer;", db)
payment_df = pd.read_sql("SELECT * FROM payment;", db)
customer_df.head(1)
payment_df.head(1)
SQL_QUERY =
... | <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: 3T_데이터 분석을 위한 SQL 실습 (2) - SUB QUERY, HAVING
Step3: JOIN은 조금 어렵지만 속도가 WHERE보다 빠르다.
Step8: 서브쿼리랑 HAVING 다시 천천히 해보자
Step9: pandas
|
10,144 | <ASSISTANT_TASK:>
Python Code:
import scipy.integrate
import numpy as np
N0 = 1
time_span = [0, 10]
def dN1_dt(t, N1):
input = 1-np.cos(t) if 0<t<2*np.pi else 0
return -100*N1 + input
sol = scipy.integrate.solve_ivp(fun=dN1_dt, t_span=time_span, y0=[N0,])
<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,145 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis A. Engemann <denis.engemann@gmail.com>
# Mainak Jas <mainak.jas@telecom-paristech.fr>
#
# License: BSD-3-Clause
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis-ave.fif'
evoked... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Compute interpolation (also works with Raw and Epochs objects)
Step2: You can also use minimum-norm for EEG as well as MEG
|
10,146 | <ASSISTANT_TASK:>
Python Code:
%%bash
mkdir trainer
touch trainer/__init__.py
%%writefile trainer/task.py
import argparse
import pandas as pd
import tensorflow as tf
import os #NEW
import json #NEW
from tensorflow.contrib.learn.python.learn import learn_runner
from tensorflow.contrib.learn.python.learn.utils import sav... | <SYSTEM_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) Define Hyperparameter Configuration File
Step2: 3) Train
Step3: Run local
Step4: Run on cloud (1 cloud ML unit)
|
10,147 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from IPython.core.debugger import Tracer # debugging
from IPython.display import clear_output, display
import time
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
import matplotlib.pyplot as plt
import seaborn as sns; sns.set() # prettify... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Function to optimize
Step2: To illustrate the problem
Step3: Now with a Logarithmic latent space mapping
|
10,148 | <ASSISTANT_TASK:>
Python Code:
# Create the training data
np.random.seed(2)
X, y = make_blobs(n_samples=300,cluster_std=.25, centers=np.array([(-3,1),(0,2),(3,1)]))
plt.scatter(X[:, 0], X[:, 1], c=y, s=50)
from sklearn.base import BaseEstimator, ClassifierMixin, clone
from numpy import linalg as L
class OneVsAllCl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step5: Order of models
Step6: Notice the margin vs classification accuracy trade-off by tuning parameter C
Step7: By normalizing the three boundary v... |
10,149 | <ASSISTANT_TASK:>
Python Code:
from dkrz_forms import form_widgets
form_widgets.show_status('form-submission')
# initialize your CORDEX submission form template
from dkrz_forms import form_handler
from dkrz_forms import checks
my_email = "..." # example: sf.email = "Mr.Mitty@yahoo.com"
my_first_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: Start submission procedure
Step2: please provide information on the contact person for this CORDEX data submission request
Step3: Type of subm... |
10,150 | <ASSISTANT_TASK:>
Python Code:
# Imports the functionality that we need to display YouTube videos in a Jupyter Notebook.
# You need to run this cell before you run ANY of the YouTube videos.
from IPython.display import YouTubeVideo
# Display a specific YouTube video, with a given width and height.
# WE STRONGLY 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: Question 1
Step2: Question 2
Step3: Question 3
Step5: Question 4
|
10,151 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing(use_unicode=True)
# SymPy works better if you specify what letters are symbols:
x, y, z = symbols('x y z', real=True)
# notice we can also put some restrictions on the symbols:
a, c = symbols('a c', nonzero=True, real=True)
integrate?
integrate(x,(x,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: There are two ways to use the integrate function. In one line, like integrate(x,(x,0,1)) or by naming an expression and then integrating it over... |
10,152 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
def get_features_values_combinations(list_a, list_b):
Returns a list of combinations of the values of
e.g. from the lists
list_a = ['L', 'M', 'W']
list_b = ['F', 'I', 'S']
we get the combinations:
[('L', 'F'), ('L', '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:
Step4: ```
Step5: a) Example with All probabilities 50 - 50 (input signal = noise)
Step6: b) Example with some clear input singnal
Step7: Example w... |
10,153 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
assert os.path.isfile('yearssn.dat')
data=np.loadtxt('yearssn.dat')
ssc=data[:,1]
year=data[:,0]
assert len(year)==315
assert year.dtype==np.dtype(float)
assert len(ssc)==315
assert ssc.dtype==np.dtype(float... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Line plot of sunspot data
Step2: Use np.loadtxt to read the data into a NumPy array called data. Then create two new 1d NumPy arrays named year... |
10,154 | <ASSISTANT_TASK:>
Python Code:
import h5py
f = h5py.File('../data/mc.hdf5', mode='r')
list(f.keys())
d = f['samples']
list(d.attrs)
d.attrs['acceptance']
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
%config InlineBackend.figure_format = 'svg'
import emcee
ac = emcee.autocorr
x = d[:,0]
x.sh... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: So the acceptance fraction is about 84%, which seems too high. It should be closer to 23%. So we should increase the typical step size.
|
10,155 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-3', 'toplevel')
# 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: 2... |
10,156 | <ASSISTANT_TASK:>
Python Code:
data_dir = './data'
# FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe"
#data_dir = '/input'
DON'T MODIFY ANYTHING IN THIS CELL
import helper
helper.download_extract('mnist', data_dir)
helper.download_extract('celeba', data_dir)
show_n_images = 25
DON'T MODIFY ANYTHING IN THIS CELL
%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: 人脸生成(Face Generation)
Step3: 探索数据(Explore the Data)
Step5: CelebA
Step7: 预处理数据(Preprocess the Data)
Step10: 输入(Input)
Step13: 辨别器(Discrimin... |
10,157 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display, Image, HTML
from talktools import website, nbviewer
2+2
import math
math.atan?
%pylab inline
plot(rand(50))
!ls -al
from IPython.display import display
from IPython.display import Image
i = Image("images/jupyter_logo.png")
print(i)
i
display(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: The Jupyter Notebook is a web-based application that enables users to create documents that combine live code wth narrative next, equations, ima... |
10,158 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
file_name_string = 'C:/Users/Charles Kelly/Desktop/Exercise Files/02_07/Begin/EmployeesWithGrades.xlsx'
employees_df = pd.read_excel(file_name_string, 'Sheet1', index_col=None, na_values=['NA'])
employees_df
employees_df["Grade"] = employees_df["Gra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Change data type
Step2: Rename the categories
Step3: Values in data frame have not changed
Step4: tabulate Department, Name, and YearsOfServi... |
10,159 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
import random
import numpy as np
def combinaison():
x = random.gauss(0,1) # génère un nombre aléatoire
y = random.gauss(0,1) # selon une loi normale
z = random.gauss(0,1) # de moyenne null et de variance 1
x2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Création d'un jeu de données
Step2: Q2
Step3: a est la matrice de covariance.
Step4: Q4
Step5: Calcul de la racine carrée
Step6: C'est pres... |
10,160 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.version.full_version
P = [ 1, 0, 1, 1]
n = len(P) - 1
P, n
Q = [1, 0, 0, 1, 0, 0]
m = len(Q) - 1
Q, m
PQ = polymul(P, Q)
d = len(PQ) - 1
PQ, d
assert d == n + m
lambdas = np.arange(0, d + 1)
lambdas
values_P = np.polyval(P, lambdas)
values_P
values_Q = np.po... | <SYSTEM_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: Their product is $(PQ)(X)$, of degree $n+m=8$
Step3: If we evaluate both $P(X)$ and $Q(X)$, on $n+m$ different points, $\lambd... |
10,161 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import skrf
from skrf.media import MLine, DefinedAEpTandZ0
import numpy as np
from numpy import real, log, log10, sum, absolute, pi, sqrt
from scipy.optimize import minimize
import matplotlib.pyplot as plt
from IPython.display import *
skrf.stylely()
#load all measurem... | <SYSTEM_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 into skrf
Step2: DC point extrapolation
Step3: Microstripline
Step4: Measurement vs simulation comparison
Step5: Surprisingly, the... |
10,162 | <ASSISTANT_TASK:>
Python Code:
x = np.arange(9).reshape((3,3))
x
np.diag(x)
np.diag(x, k=1)
np.diag(x, k=-1)
np.diag(np.diag(x))
np.diag(np.diag(x, k=-1), k=1)
np.diag(np.arange(2, 7), k=-1)
<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: 연습문제
|
10,163 | <ASSISTANT_TASK:>
Python Code::
def extract_features(filename):
# load the model
model = VGG16()
# re-structure the model
model = Model(inputs=model.inputs, outputs=model.layers[-2].output)
# load the photo
image = load_img(filename, target_size=(224, 224))
# convert the image pixels to a numpy array
image = 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:
|
10,164 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-esm2m', 'atmoschem')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("na... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
10,165 | <ASSISTANT_TASK:>
Python Code:
text_root = '../data/EmbryoProjectTexts/files'
zotero_export_path = '../data/EmbryoProjectTexts'
documents = nltk.corpus.PlaintextCorpusReader(text_root, 'https.+')
metadata = zotero.read(zotero_export_path, index_by='link', follow_links=False)
word_counts = nltk.FreqDist([normalize_toke... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Has the prevalence of a token increased or decreased over time?
Step2: $N_{embryo}$
Step3: $f("embryo") = \frac{N_{embryo}}{N}$
Step4: ...and... |
10,166 | <ASSISTANT_TASK:>
Python Code:
! pwd
names = !ls *.py
names[:3]
%pycat?
%%writefile pythoncode.py
import numpy
def append_if_not_exists(arr, x):
if x not in arr:
arr.append(x)
def some_useless_slow_function():
arr = list()
for i in range(10000):
x = numpy.random.randint(0, 10000)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: See the source of python functions/classes with question marks (? or ??)
Step2: %load
Step3: %run
Step4: %load code
Step5: You absolutel... |
10,167 | <ASSISTANT_TASK:>
Python Code:
# 基础库导入
from __future__ import print_function
from __future__ import division
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import ipywidgets
%matplotlib inline
import os
import sys
# 使用insert 0即只使用github,避免交叉使用了pip安装的abupy,导致的版本不一致问题
sys.path.insert(0, os.path.ab... | <SYSTEM_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: 如果不想通过直接下载数据文件的方式,也可运行下面的cell点击按钮后进行美股数据全市场更新,如... |
10,168 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import networkx as nx
K_5=nx.complete_graph(5)
nx.draw(K_5)
def complete_deg(n):
Return the integer valued degree matrix D for the complete graph K_n.
a = np.ones((n,n), dtype=np.int)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Complete graph Laplacian
Step3: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi... |
10,169 | <ASSISTANT_TASK:>
Python Code:
# Set up code checking
import os
if not os.path.exists("../input/train.csv"):
os.symlink("../input/home-data-for-ml-course/train.csv", "../input/train.csv")
os.symlink("../input/home-data-for-ml-course/test.csv", "../input/test.csv")
from learntools.core import binder
binder.b... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You will work with data from the Housing Prices Competition for Kaggle Learn Users to predict home prices in Iowa using 79 explanatory variables... |
10,170 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import io
data = io.StringIO("""
rs alleles chrom pos strand assembly# center protLSID assayLSID
TP3 A/C 0 3 + NaN NaN NaN NaN
TP7 A/T 0 7 + NaN NaN NaN NaN
TP12 T/A 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:
|
10,171 | <ASSISTANT_TASK:>
Python Code:
!pip -q install torch==1.7
!pip -q install transformers
!pip -q install datasets
!pip -q install tqdm
# Automatically restart kernel after installs
import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
import numpy as np
from datasets import load_dataset
from ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restart the Kernel
Step2: Python imports
Step3: Loading the dataset
Step4: The datasets object itself is DatasetDict, which contains one key ... |
10,172 | <ASSISTANT_TASK:>
Python Code:
from ipysankeywidget import SankeyWidget
from ipywidgets import Layout
links = [
{'source': 'start', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'B', 'value': 2},
{'source': 'C', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'C', 'value': 2},
]
layout = 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: You can use IPython.display classes to ensure embedded versions of your diagram will persist in your notebook, even without JavaScript!
Step2: ... |
10,173 | <ASSISTANT_TASK:>
Python Code:
import os.path, gitpath #pip install git+'https://github.com/ruxi/python-gitpath.git'
os.chdir(gitpath.root()) # changes path to .git root
#os.getcwd() #check current work directory
py_commit_msg =
templating py_commit_msg
%%bash -s "$py_commit_msg"
echo $1
git add --all :/
git commit -... | <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: TODO
|
10,174 | <ASSISTANT_TASK:>
Python Code:
import matplotlib as mpl
from matplotlib import cm
import matplotlib.pyplot as plt
from qutip import *
from piqs import *
#TLS parameters
N = 6
ntls = N
nds = num_dicke_states(ntls)
[jx, jy, jz, jp, jm] = jspin(N)
w0 = 1
gE = 0.1
gD = 0.01
h = w0 * jz
#photonic parameters
nphot = 20
wc = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Wigner Function
Step2: Time Evolution
Step3: Plots
Step4: References
|
10,175 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
k = 2 # slope
c = 5 # bias
s = 2 # noise standard deviation
# This cell content is hidden from Sphinx-generated documentation
%matplotlib inline
np.random.seed(42)
x = np.arange(10)
y = k*x + c + s*np.random.randn(10)
X = np.vstack([x, np.ones(len(x))]).T
from bayesp... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate data
Step2: Model
Step3: Note that we added a column of ones to the regressor matrix for the bias term. We model the slope and the bi... |
10,176 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot
import numpy
def linear_interpolation(f, x_points):
Return the function that linearly interpolates f at the two x_points, and its derivative.
xi, xip = x_points
g = lambda x : (x - xip) / (xi - xip) * f(xi) +... | <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: Numerical Methods
Step5: Finite differencing formulas
Step6: Convergence
|
10,177 | <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: 设置输入管道(pipeline)
Step5: 0-255 的像素值, 必须标准化到 0-1 范围。在函数中定义标准化。
Step6: 将此功能应用于训练和测试数据,随机打乱训练数据,... |
10,178 | <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,179 | <ASSISTANT_TASK:>
Python Code:
import numpy
X = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[1, 1, 0, 0],
[0, -1, -1, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
[0, 0, 1, 1],
[-1, 0, 0, -1]
])
Y = numpy.array([50.78, 30.25, 78.29, 99.57 - 180, 50.42, 40.59, 88.87, 89.86 - 180]).T
Beta = numpy.linalg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Заметим, что $ABD = \beta_1$, $DBC = \beta_2$, $ABC = \beta_1 + \beta_2$, $BCD = 180 - \beta_2 - \beta_3$, $CDB = \beta_3$, $BDA= \beta_4$, $CDA... |
10,180 | <ASSISTANT_TASK:>
Python Code:
# CSVファイルからデータを読み込みましょう。 Read the data from CSV file.
df = pd.read_csv('data/16-July-2019-Tokyo-hourly.csv')
print("行数は %d です" % len(df))
print(df.dtypes)
df.head()
px.line(df, y='Temperature_degC')
px.line(df, x='Time_Hour', y='Temperature_degC')
df.dtypes
px.line(df, y='Pressure_hPa'... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Visualization with plotly_express
Step2: lang
Step3: lang
Step4: lang
Step5: lang
Step6: lang
Step7: lang
Step9: 予習課題. データフレームの可視化 (Visua... |
10,181 | <ASSISTANT_TASK:>
Python Code:
import geopandas
import rasterio
import matplotlib.pyplot as plt
from shapely.geometry import Point
# Create sampling points
points = [Point(625466, 5621289), Point(626082, 5621627), Point(627116, 5621680), Point(625095, 5622358)]
gdf = geopandas.GeoDataFrame([1, 2, 3, 4], geometry=point... | <SYSTEM_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 example vector data
Step2: The GeoDataFrame looks like this
Step3: Open the raster data
Step4: Let's see the raster data with the poin... |
10,182 | <ASSISTANT_TASK:>
Python Code:
print('Hello, world!')
# Dies ist ein Kommentar :)
x = 1 # x ist ein int
print(x)
x = 'Hallo, Welt!' # x ist jetzt ein string
print(x)
y = 3.1415 # y is ein float
print(y)
z = [1, 'a', 2.7182] # z ist eine (heterogene) Liste mit drei Einträgen
# Auch wenn es vom... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Variablen, Datentypen, Operatoren
Step2: Jeder dieser Typen lässt sich in einem wahrheitswertigen Kontext verwenden. In einem solchen ist beisp... |
10,183 | <ASSISTANT_TASK:>
Python Code:
import sklearn
from sklearn.model_selection import train_test_split
import numpy as np
import shap
import time
X_train,X_test,Y_train,Y_test = train_test_split(*shap.datasets.iris(), test_size=0.2, random_state=0)
# rather than use the whole training set to estimate expected values, we 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: K-nearest neighbors
Step2: Explain a single prediction from the test set
Step3: Explain all the predictions in the test set
Step4: Support ve... |
10,184 | <ASSISTANT_TASK:>
Python Code:
# Author: Denis A. Engemann <denis.engemann@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
import os
import numpy as np
from mne import io
from mne.datasets import sample
from mne.minimum_norm import apply_inverse_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: Set parameters
Step2: Decoding in sensor space using a linear SVM
|
10,185 | <ASSISTANT_TASK:>
Python Code:
import ibeis
ibs = ibeis.opendb(db=db)
ibeis.other.dbinfo.show_image_time_distributions(ibs, ibs.get_valid_gids())
_ = ibeis.other.dbinfo.get_dbinfo(ibs)
# Get a sample of images
gids = ibs.get_valid_gids()
aids = ibs.get_image_aids(gids)
nAids_list = list(map(len, aids))
gids_sorted = u... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Detection Summary
Step2: Identification Summary
Step3: Distribution of Correct Matches (True Positives) over timedelta categories
Step4: Dist... |
10,186 | <ASSISTANT_TASK:>
Python Code:
from pydna.dseqrecord import Dseqrecord
mysequence = Dseqrecord("GGATCCAAA")
mysequence
mysequence.seq
from pydna.readers import read
read_from_fasta = read("fastaseq.fasta")
read_from_gb = read("gbseq.gb")
read_from_embl = read("emblseq.emb")
print(read_from_fasta.seq)
print(read_fr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A small Dseqrecord object can be created directly. The Dseqrecord class is a double stranded version of the Biopython SeqRecord class.
Step2: T... |
10,187 | <ASSISTANT_TASK:>
Python Code:
bf.set_network('generate_questions')
bf.set_snapshot('generate_questions')
result = bf.q.bgpSessionCompatibility().answer().frame()
result.head(5)
result.iloc[0]
bf.set_network('generate_questions')
bf.set_snapshot('generate_questions')
result = bf.q.bgpSessionStatus().answer().frame(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: BGP Session Compatibility
Step2: Return Value
Step3: Print the first row of the returned Dataframe
Step4: BGP Session Status
Step5: Return V... |
10,188 | <ASSISTANT_TASK:>
Python Code:
try:
import torchvision
except ModuleNotFoundError:
%pip install -qq torchvision
import torchvision
from torchvision import datasets
from torchvision import transforms
import numpy as np
import jax
import jax.numpy as jnp
import itertools
try:
from bokeh.io import output_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: This is required for Bokeh to work in notebooks.
Step2: According to NIST,
Step3: Here are some examples from the dataset
|
10,189 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt # plotting
import seaborn as sns # nicer plots
sns.set_style('whitegrid') # plot styling
import bayesloop as bl
S = bl.Study()
import numpy as np
data = np.array([5, 4, 1, 0, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 3, 3, 5, 4, 5,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This object is central to an analysis conducted with bayesloop. It stores the data and further provides the methods to perform probabilistic inf... |
10,190 | <ASSISTANT_TASK:>
Python Code:
#@title Copyright 2020 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/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: <table class="tfo-notebook-buttons" align="left">
Step3: ユーティリティ
Step4: 視覚化ツール
Step5: Object Detection API をインストールします。
Step6: これで、後で必要になる依存関... |
10,191 | <ASSISTANT_TASK:>
Python Code:
n = 1000000
x = np.random.rand(n)
y = np.random.rand(n)
%time z = x + y
def sum_vec(x, y):
"Sum two vectors entry by entry"
z = np.zeros(n)
for i in range(n):
z[i] = x[i] + y[i]
return z
%time w = sum_vec(x, y)
# Test scores
scores = np.array([58.0, 35.0, 24.0, 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: Timing 1 million elements arrays addition using an entry-by-entry function
Step2: Exercise 07.2 (member functions and slicing)
Step3: Function... |
10,192 | <ASSISTANT_TASK:>
Python Code:
import pandas
file = open("./data.html")
data = pandas.io.html.read_html(file, encoding='utf-8')[0]
data.drop(["Class.", "By", "TA", "JL", "PW"], axis=1, inplace=True)
import re
def cleanEntry(str):
match = re.search(r"(-?(?:\d*\.)?\d+)(?:-(-?(?:\d*\.)?\d+))?", str)
if match is ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Code to remove the columns “Class”, “By”, “TA”, “JL”, “PW” (i.e. irrelevant and less relevant data to do with the project)
Step2: Code to clean... |
10,193 | <ASSISTANT_TASK:>
Python Code:
# import the make_blobs function from the sklearn module/package
from sklearn.datasets.samples_generator import make_blobs
# use the function we imported to generate a matrix with 100 rows and 2 columns
# n_samples=100 specifies the number of rows in the returned matrix
# n_features=2 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: To get some intuitions about the data, let's plot the 100 labelled books, using the counts of the words "laser" and "love" as the x and y axes
S... |
10,194 | <ASSISTANT_TASK:>
Python Code:
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import numpy as np
from matplotlib import pyplot as plt
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print("We are using the following device for learning:",device)
batch_size_train = 60000 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import and load MNIST dataset (Preprocessing)
Step2: Plot 8 random images
Step3: Specify Autoencoder
Step4: Helper function to get a random m... |
10,195 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'csiro-bom', 'access-1-0', 'ocean')
# 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... |
10,196 | <ASSISTANT_TASK:>
Python Code:
cd ..
import NotebookImport
from Setup.Imports import *
import os as os
import pandas as pd
from pandas.rpy.common import convert_to_r_dataframe, convert_robj
import rpy2.robjects as robjects
from IPython.display import clear_output
robjects.r.library('WGCNA');
robjects.r.source("/cellar... | <SYSTEM_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 Horvath normalization source into R namespace.
Step2: Read in Betas
Step3: Normalization Step
Step4: Now we need to fix the labels a lit... |
10,197 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-1', '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... |
10,198 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import emcee
import triangle
import pandas as pd
import seaborn as sns
from astroML.decorators import pickle_results
sns.set_context("paper", font_scale=2.0, rc={"lines.linewidth": 2.5})
sns.set(style="ticks")
df = pd.read_csv('../data/cln_20130916_cary5000.csv', index_col=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read in the data. We want "VG12"
Step2: Import all the local models, saved locally as etalon.py. See the paper for derivations of these equat... |
10,199 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
fig = plt.figure()
plt.show()
ax = plt.axes()
plt.show()
ax = plt.axes()
line1, = ax.plot([0, 1, 2, 1.5], [3, 1, 2, 4])
plt.show()
plt.plot([0, 1, 2, 1.5], [3, 1, 2, 4])
plt.show()
top_right_ax = plt.subplot(2, 3, 3)
bottom_left_ax = plt.subplot(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 matplotlib figure
Step2: On its own, drawing the figure artist is uninteresting and will result in an empty piece of paper (that's why we d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.