Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
14,600 | <ASSISTANT_TASK:>
Python Code:
print("Hello World")
a = 1 + 1
a
2 + 3
a = 2 + 3
a + 1
42 - 15.3
100 * 11
7 / 5
-7/5
7.0 / 5
7//5
7.0//5
-7//5
-7.0//5
7%5
-7%5
-7.0%5
2 ** 3
9 ** 0.5
# int a_number = 2
a_number = 2
a_word = 'dog'
print(a_number)
print(a_word)
type(a_number)
type(a_word)
a_number + 7
(a_number ... | <SYSTEM_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: 주의
Step4: 나머지를 계산하는 연산자는 % 이다.
Step5: 지수 계산
Step6: 변수 선언 및 활용
Step7: 예를 들어, C... |
14,601 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
import scipy.stats as ss
from functools import partial
import elfi
from elfi.examples import gauss
m = gauss.get_model()
seed = 20170616
n_obs = 50
batch_size = 100
mu, sigma = (5, 1)
y_obs = gau... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We will use a simple model of a univariate Gaussian with an unknown mean to illustrate posterior adjustment. The observed data is 50 data points... |
14,602 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv('data/human_body_temperature.csv')
df.head()
import numpy as np
import math
import pylab
import scipy.stats as stats
import matplotlib.pyplot as plt
plt.hist(df.temperature)
plt.show()
stats.probplot(df.temperature, dist="norm", plot=pylab)
pylab.show... | <SYSTEM_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) The histogram and normal probability plot shows that the distribution of body temperatures approximately follows a normal distribution
Step2... |
14,603 | <ASSISTANT_TASK:>
Python Code:
Testing pbnt.
Run this before anything else
to get pbnt to work!
import sys
# from importlib import reload
if('pbnt/combined' not in sys.path):
sys.path.append('pbnt/combined')
from exampleinference import inferenceExample
# Should output:
# ('The marginal probability of sprinkler=fal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Assignment 3
Step3: Part 1
Step5: 1b
Step7: 1c
Step11: 1d
Step13: Part 2
Step15: 2b
Step17: 2c
Step21: 2d
Step22: 2e
|
14,604 | <ASSISTANT_TASK:>
Python Code:
a = [2, 3, 5, 7]
# Length of a list
len(a)
# Append a value to the end
a.append(11)
a
# Addition concatenates lists
a + [13, 17, 19]
# sort() method sorts in-place
a = [2, 5, 1, 6, 3, 4]
a.sort()
a
a = [1, 'two', 3.14, [0, 3, 5]]
a
a = [2, 3, 5, 7, 11]
a[0]
a[1]
a[-1]
a[-2]
a[0: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: Lists have a number of useful properties and methods available to them.
Step2: One of the powerful features of Python's compound objects is tha... |
14,605 | <ASSISTANT_TASK:>
Python Code:
import lib.ngagent as ngagent
ag_cfg = {
'agent_id':'test',
'voc_cfg':{
'voc_type':'sparse_matrix',
'M':5,
'W':10
},
'strat_cfg':{
'strat_type':'naive',
'voc_update':'Minimal'
}
}
testagent=ngagent.Agent(**ag_cfg)
te... | <SYSTEM_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 create an agent. Vocabulary and strategy are created at the same time.
Step2: We can get visuals of agent objects from strategy and vocab... |
14,606 | <ASSISTANT_TASK:>
Python Code:
import altair
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# Set the plotting style as for a "paper" (smaller labels)
# and using a white background with a grid ("whitegrid")
sns.set(context='paper', style='whitegrid')
%matplotlib inline
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: We'll import the macosko2015 package, which contains a URL pointing to where we've created clean data
Step2: We've created a subset of the data... |
14,607 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_excel('http://cdn.sundog-soft.com/Udemy/DataScience/cars.xls')
df.head()
import statsmodels.api as sm
from sklearn.preprocessing import StandardScaler
scale = StandardScaler()
X = df[['Mileage', 'Cylinder', 'Doors']]
y = df['Price']
X[['Mileage', 'Cylinde... | <SYSTEM_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 use pandas to split up this matrix into the feature vectors we're interested in, and the value we're trying to predict.
|
14,608 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import scipy.spatial.distance
example_array = np.array([[0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 2, 0, 2, 2, 0, 6, 0, 3, 3, 3],
[0, 0, 0, 0, 2, 2, 0, 0, 0, 3, 3, 3],
[0, 0, 0, 0, 0, 0, 0, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
14,609 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pickle as pkl
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
import tensorflow as tf
!mkdir data
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
data_dir = 'data/'
if not isdir(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: Getting the data
Step2: These SVHN files are .mat files typically used with Matlab. However, we can load them in with scipy.io.loadmat which we... |
14,610 | <ASSISTANT_TASK:>
Python Code:
from deepchem.molnet.load_function import hiv_datasets
from deepchem.models import GraphConvModel
from deepchem.data import NumpyDataset
from sklearn.metrics import average_precision_score
import numpy as np
tasks, all_datasets, transformers = hiv_datasets.load_hiv(featurizer="GraphConv")... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrain Model Over Full Dataset For The Screen
Step2: 2. Create Work-Units
Step3: 5. Consume work units from "distribution mechanism"
|
14,611 | <ASSISTANT_TASK:>
Python Code:
def f(x):
y = x**4 - 3*x
return y
def integrate_f(a, b, n):
dx = (b - a) / n
dx2 = dx / 2
s = f(a) * dx2
for i in range(1, n):
s += f(a + i * dx) * dx
s += f(b) * dx2
return s
%timeit integrate_f(-100, 100, int(1e5))
%load_ext cython
%%cython... | <SYSTEM_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, let's time this
Step2: Not too bad, but this can add up. Let's see if Cython can do better
Step3: That's a little bit faster, which is ni... |
14,612 | <ASSISTANT_TASK:>
Python Code:
import rebound
import reboundx
import numpy as np
import astropy.units as u
import astropy.constants as constants
import matplotlib.pyplot as plt
%matplotlib inline
#Simulation begins here
sim = rebound.Simulation()
sim.units = ('yr', 'AU', 'Msun') #changes simulation and G to units of so... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As with all REBOUNDx effects, the parameters must be inputed with the same units as the simulation (in this case it's AU/Msun/yr). We'll use the... |
14,613 | <ASSISTANT_TASK:>
Python Code:
# Load data sets
import pandas as pd
treeSourceUrl = './data/preds_yeastnet_no_gi_0.04_0.5.txt.propagate.small_parent_tree'
geneCountFile = './data/preds_yeastnet_no_gi_0.04_0.5.txt.propagate.term_sizes'
alignmentFile = './data/alignments_FDR_0.1_t_0.1'
geneAssignment = './data/preds_yeas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Build Base CyJS Network
Step2: Layout with networkx
|
14,614 | <ASSISTANT_TASK:>
Python Code:
help([1, 2, 3])
dir([1, 2, 3])
sum??
all([1==1, True, 10, -1]), all([1==5, True, 10, -1])
any([False, True]), any([False, False])
bin(12), oct(12), hex(12), int('12'), float(12)
ord('A'), chr(65)
raw_input(u"Podaj liczbę: ")
zip([1,2,3], [2, 3, 4])
sorted([8, 3, 12, 9, 3]), reversed(rang... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Funkcje wbudowane
Step2: Tuple (krotka)
Step3: Czym się różni krotka od listy?
Step4: Prosta matematyka
Step5: Trochę programowania funkcyjn... |
14,615 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
#%config InlineBackend.figure_format = 'pdf'
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import fsic.data as data
import fsic.glo as glo
import fsic.indtest as it
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: A notebook to process experimental results of ex2_prob_params.py. p(reject) as problem parameters are varied.
Step2: A toy problem where X foll... |
14,616 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import skrf as rf
from skrf.media import CPW
rf.stylely()
import matplotlib.pyplot as plt
# base parameters
freq = rf.Frequency(1e-3,10,1001,'ghz')
cpw = CPW(freq, w=0.6e-3, s=0.25e-3, ep_r=10.6)
l1
0----+-=======-2
|
= c1
|... | <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: Build fixture network
Step4: Build DUT network
Step6: Build the measurement
Step7: Perform de-embedding
Step8: Display results
|
14,617 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd # Cargamos pandas con el alias pd
dfl = pd.read_csv('data/perros_o_gatos.csv', index_col='observacion')
print('Estos datos han sido tomados del libro Mastering machine learning with scikit-learn de Gavin Hackeling, \
PACKT publishing open source, pp. 99')
dfl # En j... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Un problema de clasificación
Step2: Los datos se componen de observaciones numeradas del 1 al 14 y 3 features o características representadas e... |
14,618 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
## Create an ontology factory in order to fetch GO
from ontobio.ontol_factory import OntologyFactory
ofactory = OntologyFactory()
## GOLR queries
from ontobio.golr.golr_query import GolrAssociationQuery
## rendering ontologies
from ontobio import GraphRenderer
## Load ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Finding descendants
Step2: rendering subtrees
Step5: summarizing annotations
Step6: Summarize GO term and descendants
Step7: Summary by assi... |
14,619 | <ASSISTANT_TASK:>
Python Code:
!pip install --pre deepchem
import deepchem as dc
dc.__version__
tasks, datasets, transformers = dc.molnet.load_delaney(featurizer='GraphConv')
train_dataset, valid_dataset, test_dataset = datasets
model = dc.models.GraphConvModel(n_tasks=1, mode='regression', dropout=0.2)
model.fit(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: You can of course run this tutorial locally if you prefer. In this case, don't run the above cell since it will download and install Anaconda on... |
14,620 | <ASSISTANT_TASK:>
Python Code:
import graphlab
import matplotlib.pyplot as plt
import numpy as np
import sys
import os
import time
from scipy.sparse import csr_matrix
from sklearn.cluster import KMeans
from sklearn.metrics import pairwise_distances
%matplotlib inline
'''Check GraphLab Create version'''
from distutils.v... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the Wikipedia dataset
Step2: As we did in previous assignments, let's extract the TF-IDF features
Step3: To run k-means on this dataset, ... |
14,621 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a = np.array([1, 2, 3])
print(a.shape)
print(a.size)
print(a.ndim)
x = np.arange(100)
print(x.shape)
print(x.size)
print(x.ndim)
y = np.random.rand(5, 80)
print(y.shape)
print(y.size)
print(y.ndim)
x.shape = (20, 5)
print(x)
y.shape = (4, 20, -1)
print(y.shape)
# Sc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Array Creation
Step2: Array Manipulation
Step3: NumPy can even automatically figure out the size of at most one dimension for you.
Step4: Arr... |
14,622 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import sklearn.cluster
simM = load_data()
model = sklearn.cluster.AgglomerativeClustering(affinity='precomputed', n_clusters=2, linkage='complete').fit(simM)
cluster_labels = model.labels_
<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:
|
14,623 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import time
import sys
import os
%matplotlib inline
# Change directory to the code folder
os.chdir('..//code')
# Functions to sample the diffusion-weighted gradient directions
from dipy.core.sphere import disperse_charg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Below we define the simulated acquisition parameters
Step2: Next the ground truth values of tissue and water diffusion are defined. Simulations... |
14,624 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
log = pd.read_csv("../dataset/git_log_intellij.csv.gz")
log.head()
log.info()
log['timestamp'] = pd.to_datetime(log['timestamp'])
log.head()
recent = log[log['timestamp'] > log['timestamp'].max() - pd.Timedelta('90 days')]
recent.head()
java = recent[recent['filena... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Wir erkunden die geladenen Daten.
Step2: <b>1</b> DataFrame (~ programmierbares Excel-Arbeitsblatt), <b>6</b> Series (= Spalten), <b>1128819</b... |
14,625 | <ASSISTANT_TASK:>
Python Code:
# coding: utf-8
from sklearn import datasets
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import Perceptron
from sklearn.metrics import accuracy_score
iris = datasets.load_iris() # 加载鸢尾花数... | <SYSTEM_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: 感知器算法对于无法线性分割的数据集,是不收敛的,因此实际中很少只用感知器算法。后面将会介绍更强大的线性分... |
14,626 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as py
#import scipy
# Make the graphs a bit prettier, and bigger
#pd.set_option('display.mpl_style', 'default')
#plt.rcParams['figure.figsize'] = (15, 5)
# This is necessary to show lots of columns in pand... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Najprej sem spletne strani FIS pobrala podatke o smučarjih in njihovih id številkah na spletišču FIS. Id-je sem potrebovala za sestavljanje url ... |
14,627 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from NuPyCEE import omega
from NuPyCEE import sygma
# Run original OMEGA with 1000 timestesp (this may take a minute ..)
o_ori = omega.omega(galaxy='milky_way', special_timesteps=1000)
# Let's create the timestep templ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Original Version
Step2: Fast Version
Step3: By using the dt_in_SSPs array, the OMEGA timesteps can be different from the SSP timesteps. If dt_... |
14,628 | <ASSISTANT_TASK:>
Python Code:
import random
def genEven():
'''
Returns a random even number x, where 0 <= x < 100
'''
return random.randrange(0,100,2)
genEven()
def stochasticNumber():
'''
Stochastically generates and returns a uniformly distributed even
number between 9 and 21
'''
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Again
Step2: On the other side, deterministic means that the outcome - given the same input - will always be the same. There is no unpredictabi... |
14,629 | <ASSISTANT_TASK:>
Python Code:
# Author: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
import mne
from mne.datasets import sample
from mne.minimum_norm import make_inverse_operator, apply_inverse
print(__doc__)
data_path = sample.data_path()
subjects_dir = data_path + '/subjects'
# Read data
fname_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: Fixed orientation
Step2: Let's look at the current estimates using MNE. We'll take the absolute
Step3: Next let's use the default noise normal... |
14,630 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import nsfg
preg = nsfg.ReadFemPreg()
import thinkstats2
live = preg[preg.outcome == 1]
firsts = live[live.birthord == 1]
others = live[live.birthord != 1]
cdf = thinkstats2.Cdf(live.totalwgt_lb)
import thinkplot
thinkplot.Cdf(cdf, label='totalwgt_lb')
thinkplot.Show(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Select live births, then make a CDF of <tt>totalwgt_lb</tt>.
Step2: Display the CDF.
Step3: Find out how much you weighed at birth, if you can... |
14,631 | <ASSISTANT_TASK:>
Python Code:
# Authors: Adonay Nunes <adonay.s.nunes@gmail.com>
# Luke Bloy <luke.bloy@gmail.com>
# License: BSD (3-clause)
import os.path as op
import matplotlib.pyplot as plt
import numpy as np
from mne.datasets.brainstorm import bst_auditory
from mne.io import read_raw_ctf
from mne.preproc... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Notch filter the data
Step2: Plot muscle z-scores across recording
Step3: View the annotations
|
14,632 | <ASSISTANT_TASK:>
Python Code:
# Let's first define a broken function
def blah(a, b):
c = 10
return a/b - c
# call the function
# define some varables to pass to the function
aa = 5
bb = 10
print blah(aa, bb) # call the function
def blah(a, b):
c = 10
print "a: ", a
print "b: ", b
print "c... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As we know, 5/10 - 10 = -9.5 and not -10, so something must be wrong inside the function. In this simple example, it may be super obvious that w... |
14,633 | <ASSISTANT_TASK:>
Python Code:
from elasticsearch import Elasticsearch
es = Elasticsearch()
create_index = {
"settings": {
"analysis": {
"analyzer": {
"payload_analyzer": {
"type": "custom",
"tokenizer":"whitespace",
"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: Load User, Movie and Ratings DataFrames from Elasticsearch
Step2: 2. Run ALS
Step3: 3. Write ALS user and item factors to Elasticsearch
Step4:... |
14,634 | <ASSISTANT_TASK:>
Python Code:
from urllib import request
import zlib
import pandas
from bs4 import BeautifulSoup #para processar o HTML
import re #para processar o html
lista_datas = []
lista_sessoes = []
bytesTransferidos = 0
i = 0
for ano in range(1976,2016):
for mes in range(1,13):
print("Processando... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Agora que temos os dados num dataframe podemos imediatamente tirar partido deles. Por exemplo representar o tamanho das sessoes em bytes ao long... |
14,635 | <ASSISTANT_TASK:>
Python Code:
from hypothesis import find
import dit
from dit.abc import *
from dit.pid import *
from dit.utils.testing import distribution_structures
dit.ditParams['repr.print'] = dit.ditParams['print.exact'] = True
a = distribution_structures(size=3, alphabet=2)
a.example()
def pred(value):
ret... | <SYSTEM_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 illustrate what the distribution source looks like, here we instantiate it with a size of 3 and an alphabet of 2
Step2: Negativity of co-inf... |
14,636 | <ASSISTANT_TASK:>
Python Code:
from netpyne import specs, sim
netParams = specs.NetParams()
simConfig = specs.SimConfig()
netParams.cellParams['pyr'] = {}
netParams.cellParams['pyr']['secs'] = {}
netParams.cellParams['pyr']['secs']['soma'] = {}
netParams.cellParams['pyr']['secs']['soma']['geom'] = {
"diam": 12,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: These NetPyNE objects come with a lot of defaults set which you can explore with tab completion, but we'll focus on that more later.
Step2: Spe... |
14,637 | <ASSISTANT_TASK:>
Python Code:
# code for loading the format for the notebook
import os
# path : store the current path to convert back to it later
path = os.getcwd()
os.chdir(os.path.join('..', '..', 'notebook_format'))
from formats import load_style
load_style(css_style='custom2.css', plot_style=False)
os.chdir(path)... | <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: Machine Translation with Huggingface Transformer
Step5: We print out the content in the data directory and some sample data.
Step7: The origin... |
14,638 | <ASSISTANT_TASK:>
Python Code:
lan = sns.factorplot('Län', data=df, kind='count', size=8, aspect=2)
lan.set_xticklabels(rotation=45)
# Show the 10 contributors that contributed the most. (change value of .nlargest() to show more)
df['Observatör'].value_counts(normalize=False, sort=True, ascending=False, bins=None, dr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Contributors
Step2: Rubrik
Step3: Geographic visualization
Step4: Time series
|
14,639 | <ASSISTANT_TASK:>
Python Code:
!gsutil cp gs://cloud-samples-data/air/fruits360/fruits360-combined.zip .
!ls
!unzip -qn fruits360-combined.zip
import os
from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
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: Getting Started
Step2: Make Datasets
Step3: Make Finer Category Datasets
Step4: Generate the preprocessed Coarse Dataset
Step5: Split Coarse... |
14,640 | <ASSISTANT_TASK:>
Python Code:
import dphox as dp
import numpy as np
import holoviews as hv
from trimesh.transformations import rotation_matrix
hv.extension('bokeh')
import warnings
warnings.filterwarnings('ignore') # ignore shapely warnings
dp.CommonLayer.RIDGE_SI
FABLESS = dp.Foundry(
stack=[
# 1. Firs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Device
Step2: Foundry
Step3: place
Step4: Now let's see what happens after we add gratings to the interposer using place.
Step5: clear
Step6... |
14,641 | <ASSISTANT_TASK:>
Python Code:
# library imports
import pandas as pd
import requests
import pytz
base_url = "http://0.0.0.0:8000"
headers = {"Authorization": "Bearer tokstr"}
url = base_url + "/api/v1/projects/"
projects = requests.get(url, headers=headers).json()
projects
url = base_url + "/api/v1/consumption_metad... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: If you followed the datastore development setup instructions, you will
Step2: Let's test the API by requesting a list of projects in the datast... |
14,642 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def mk_rot_mat(rad=np.pi / 4):
rot = np.array([[np.cos(rad),-np.sin(rad)], [np.sin(rad), np.cos(rad)]])
return rot
rot_mat = mk_rot_mat( np.pi / 4)
x = np.random.randn(100) * 5
y = np.random.randn(100)
points =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Make Some Toy Data
Step2: Add Some Outliers to Make Life Difficult
Step3: Compute SVD on both the clean data and the outliery data
Step4: Jus... |
14,643 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import IFrame
IFrame('https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life',
width = 800, height = 500)
import numpy as np
%pylab inline
from JSAnimation.IPython_display import display_animation, anim_to_html
from matplotlib import animation
from random 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: Import necessary libraries
Step8: Conway Game of Life Grid Class
Step15: Conway Game of Life Cell Class
Step16: Test Text Grid
Step17: Test ... |
14,644 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.colors import LightSource
from sympy import *
from sympy import init_printing
%matplotlib notebook
x, y, z, t = symbols('x y z t')
u, v, a, b, R = symbols('u v a b R')
k, m, n = symb... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Torobius
Step2: We can generate our surface as a composition of two rotations, one around the $z$-axis, and the other one with respect to an ax... |
14,645 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'csiro-bom', 'sandbox-3', 'atmos')
# 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... |
14,646 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import thinkstats2
import thinkplot
import pandas as pd
import numpy as np
import math, random
mean, var = 163, 52.8
std = math.sqrt(var)
pdf = thinkstats2.NormalPdf(mean, std)
print "Density:",pdf.Density(mean + std)
thinkplot.Pdf(pdf, label='normal')
thinkplot.Show()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kernel density estimation - an algorithm that takes a sampel and finds an approximately smooth PDF that fits the data.
Step2: Advantages of KDE... |
14,647 | <ASSISTANT_TASK:>
Python Code:
import math
def FindKthChar(Str , K , X ) :
ans = ' ▁ '
Sum = 0
for i in range(len(Str ) ) :
digit = ord(Str[i ] ) - 48
Range = int(math . pow(digit , X ) )
Sum += Range
if(K <= Sum ) :
ans = Str[i ]
break
return ans
Str = "123"
K = 9
X = 3
ans = Find... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
14,648 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
# Importa la librería financiera.
# Solo es necesario ejecutar la importación una sola vez.
import cashflows as cf
costs = cf.cashflow(const_value=0, # valor 0 por defecto
periods=6, # compra + vida útil
start=2000,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Depreciación en línea recta
Step2: Ejemplo.-- En el año 2001 se compra un activo por valor de $ 200 y en el año 2006 otro activo por valor de $... |
14,649 | <ASSISTANT_TASK:>
Python Code:
import platform
platform.python_version()
r = 5
a = (r**2) * 3.141596
print a
color_list_1 = set(["White", "Black", "Red"])
color_list_2 = set(["Red", "Green"])
print color_list_1
print color_list_1 - color_list_2
# Resultado = []
# for i in color_list_1:
# 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: 2. Calcule el área de un circulo de radio 5
Step2: 3. Escriba código que imprima todos los colores de que están en color_list_1 y no estan pres... |
14,650 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import time
import itertools
import h5py
import numpy as np
from scipy.stats import norm
from scipy.stats import expon
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import seaborn as sns
sns.set(style="ticks", color_codes=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Discretization
Step2: Clearly the system interconverts between two states. We can obtain a potential of mean force from a Boltzmann inversion o... |
14,651 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import numpy as np
from matplotlib import pylab as plt
from mpl_toolkits import mplot3d
from canonical_gaussian import CanonicalGaussian as CG
from gaussian_mixture import GaussianMixtureModel as GMM
from calc_traj import calc_traj
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: Target information
Step2: The Kalman Filter Model
Step3: Motion and measurement models
Step4: Priors
Step5: Linear Kalman Filtering
Step6: ... |
14,652 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import arrow # way better than datetime
import numpy as np
import random
import re
%run helper_functions.py
import string
new_df = unpickle_object("new_df.pkl") # this loads up the dataframe from our previous notebook
new_df.head() #sorted first on date and then time!
... | <SYSTEM_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 see from the above code, that I have removed duplicates by creating a tuple set of the words that are in the tweet after having removed the U... |
14,653 | <ASSISTANT_TASK:>
Python Code:
raw_data = {'dt': ['2017-01-15 00:06:08',
'2017-01-15 01:09:08',
'2017-01-16 02:07:08',
'2017-01-16 02:07:09',
'2017-01-16 03:04:08',
'2017-01-16 03:04:09',
'2017-01-15 ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convert the type column to a category (similar to factor in R)
Step2: Plot the noise readings as a point plot
Step3: Plot the pump state chang... |
14,654 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
import pyNastran
from pyNastran.op2.op2 import read_op2
pkg_path = pyNastran.__path__[0]
model_path = os.path.join(pkg_path, '..', 'models')
solid_bending_op2 = os.path.join(model_path, 'solid_bending', 'solid_bending.op2')
solid_bending = read_op2(solid_ben... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Solid Bending
Step2: Single Subcase Buckling Example
Step3: Keys
Step4: Static Table
Step5: Transient Table
|
14,655 | <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: 모델 정의
Step4: 훈련하는 동안 체크포인트 저장하기
Step5: 이 코드는 텐서플로 체크포인트 파일을 만들고 에포크가 종료될 때마다 업데이트합니다
Step6: 두 모델이 동일한 아키... |
14,656 | <ASSISTANT_TASK:>
Python Code:
import torch
import numpy as np
from IPython import embed
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C
np.random.seed(1)
def f(x):
"A function to... | <SYSTEM_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 a Gaussian process with a small amount of training points.
Step2: Construct a Neural network to do regression using Pytorch
|
14,657 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.1
training_epochs = 2000
x1_label1 = np.random.normal(3, 1, 1000)
x2_label1 = np.random.normal(2, 1, 1000)
x1_label2 = np.random.normal(7, 1, 1000)
x2_label2 = np.random.normal... | <SYSTEM_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 positive and negative to classify 2D data points
Step2: Define placeholders, variables, model, and the training op
Step3: Train the mod... |
14,658 | <ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" }
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This notebook demonstrates how to fit a pharmacokinetic model with TensorFlow probability. This includes defining the relevant joint distributio... |
14,659 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
number_to_words(554)
def number_to_words(n):
Given a number n between 1-1000 inclusive return a list of words for the number.
N=str(n)
x=list(N)
if len(x)==4:
return'one thousand'
if len... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Project Euler
Step2: Now write a set of assert tests for your number_to_words function that verifies that it is working as expected.
Step4: No... |
14,660 | <ASSISTANT_TASK:>
Python Code:
import sys
print(sys.version)
# python2 has list comprehensions
[x ** 2 for x in range(5)]
# python3 has dict comprehensions!
{str(x): x ** 2 for x in range(5)}
# and set comprehensions
{x ** 2 for x in range(5)}
# magic dictionary concatenation
some_kwargs = {'do': 'this',
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: A (non-exhaustive) list of differences between Python 2 and Python 3
Step2: New string formatting
Step3: Writing code for both Python 2 and Py... |
14,661 | <ASSISTANT_TASK:>
Python Code:
import fbu
myfbu = fbu.PyFBU()
myfbu.data = [100,150]
myfbu.response = [[0.08,0.02], #first truth bin
[0.02,0.08]] #second truth bin
myfbu.lower = [0,0]
myfbu.upper = [3000,3000]
myfbu.run()
trace = myfbu.trace
print( trace )
%matplotlib inline
from matplotlib 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: Supply the input distribution to be unfolded as a 1-dimensional list for N bins, with each entry corresponding to the bin content.
Step2: Suppl... |
14,662 | <ASSISTANT_TASK:>
Python Code:
# use the %ls magic to list the files in the current directory.
%ls
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sms
%matplotlib inline
three11s = pd.read_csv("data/pgh-311.csv", parse_dates=['CREATED_ON'])
three11s.dtypes
three11s.head()
three11s.loc[0]
# Plot 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: Embedded Plots
Step2: Exploring Request types
Step3: There are too many request types (268). We need some higher level categories to make this... |
14,663 | <ASSISTANT_TASK:>
Python Code:
# built-in python modules
import os
import inspect
import datetime
# scientific python add-ons
import numpy as np
import pandas as pd
# plotting stuff
# first line makes the plots appear in the notebook
%matplotlib inline
import matplotlib.pyplot as plt
# seaborn makes your plots look be... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: systemdef
Step2: Angle of Incidence Modifiers
Step3: Sandia Cell Temp correction
Step4: Cell and module temperature as a function of wind spe... |
14,664 | <ASSISTANT_TASK:>
Python Code:
x = [0.5,1.3, 2.1, 1.0, 2.1, 1.7, 1.2, 3.9, 3.9, 1.5, 3.5, 3.9, 5.7, 4.7, 5.8, 4.6, 5.1, 5.9, 5.5, 6.4, 6.7, 7.8, 7.4, 6.7, 8.4, 6.9, 10.2, 9.7, 10.0, 9.9]
y = [-1.6,0.5, 3.0, 3.1, 1.5, -1.8, -3.6, 7.0, 8.6, 2.2, 9.3, 3.6, 14.1, 9.5, 14.0, 7.4, 6.4, 17.2, 11.8, 12.2, 18.9, 21.9, 20.6, 15.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 4. Regression in Matlab (30 Points)
Step2: 5. Python Regression (40 Points)
|
14,665 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from IPython.display import Image
from IPython.display import HTML
assert True # leave this to grade the import statements
Image(url='http://www.mohamedmalik.com/wp-content/uploads/2014/11/Physics.jpg',embed=True,width=600,height=600)
assert True # lea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Basic rich display
Step2: Use the HTML object to display HTML in the notebook that reproduces the table of Quarks on this page. This will requi... |
14,666 | <ASSISTANT_TASK:>
Python Code:
#Cargamos los paquetes necesarios
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#Creamos arreglos de datos por un arreglo de numpy
arreglo = np.random.randn(7,4)
columnas = list('ABCD')
df = pd.DataFrame(arreglo, columns=columnas )
df
#Creamos arreglo de datos por... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ya que tenemos hechos nuestros arreglos, ahora vamos a ver las características generales de ellos...
Step2: Ejercicio 1
Step3: Ejercicio 2
Ste... |
14,667 | <ASSISTANT_TASK:>
Python Code:
import pandas
import numpy
import itertools
gene_matrix_for_network_df = pandas.read_csv("shared/bladder_cancer_genes_tcga.txt", sep="\t")
gene_matrix_for_network = gene_matrix_for_network_df.as_matrix()
print(gene_matrix_for_network.shape)
genes_keep = numpy.where(numpy.median(gene_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:
Step1: Load the data file shared/bladder_cancer_genes_tcga.txt into a pandas.DataFrame, convert it to a numpy.ndarray matrix, and print the matrix dime... |
14,668 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context('notebook')
data = tsc.loadExample('fish-series')
examples = data.subset(nsamples=50, thresh=1)
plt.plot(examples.T[0:20,:]);
examples = data.center().subset(nsamples=50, thresh=10)
plt.plot(exampl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Loading series
Step2: Inspection
Step3: Note the variation in raw intensity levels.
Step4: Related methods include standardize, detrend, and ... |
14,669 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
%load_ext memory_profiler
from pomegranate import BayesianNetwork
import seaborn, time
seaborn.set_style('whitegrid')
X = numpy.random.randint(2, size=(2000, 7))
X[:,3] = X[:,1]
X[:,6] = X[:,1]
X[:,0] = X[:,2]
X[:,4] = X[:,5]
model = BayesianNetwork.from_samples(X, algorithm... | <SYSTEM_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 structure attribute returns a tuple of tuples, where each inner tuple corresponds to that node in the graph (and the column of data learned ... |
14,670 | <ASSISTANT_TASK:>
Python Code:
import random
from numba import jit
# Monte Carlo simulation function. This is defined as
# a function so the numba library can be used to speed
# up execution. Otherwise, this would run much slower.
# p1 is the probability of the first area, and s1 is the
# score of the first area, and s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: After spending a significant amount of time spinning the wheel, you feel a little unsatisfied. Sure, you found the expected payout, but there's ... |
14,671 | <ASSISTANT_TASK:>
Python Code:
class SentenceIterator:
def __init__(self, words):
self.words = words
self.index = 0
def __next__(self):
try:
word = self.words[self.index]
except IndexError:
raise StopIteration()
self.index += 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: Example Usage
Step2: Every collection in Python is iterable.
Step3: Some notes on generators
Step4: More notes on generators
Step5: Lecture ... |
14,672 | <ASSISTANT_TASK:>
Python Code:
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
db = client.phonebook
print db.collection_names()
data = {'name': 'Alessandro', 'phone': '+39123456789'}
db.people.insert(data)
print db.collection_names()
db.people.insert({'name': 'Puria', 'phone': '+39... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once the database is retrieved, collections can be accessed as attributes of the database itself.
Step2: Each inserted document will receive an... |
14,673 | <ASSISTANT_TASK:>
Python Code:
# create a collection matrix (using the count vectorizer)
countVectorizer = CountVectorizer()
# The CountVectorizer will return a document-term sparse matrix
# the rows represent the documents, and the columns represent terms
# since we have only 2 documents, I use 2 variables to represen... | <SYSTEM_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 let's try the second vectorization method
Step2: if we add a new document 'meow squeak' to the collection, let's see the difference.
|
14,674 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import sklearn
from sklearn import datasets
from sklearn import svm
from sklearn.feature_extraction.text import CountVectorizer
import nltk
import numpy as np
import scipy
import re
import os, sys
print(os.getcwd())
os.listdir( os.getcwd(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Following ex6.pdf of Programming Exercise 6
Step2: Part 2
Step3: You should try to change the $C$ value below and see how the decision boundar... |
14,675 | <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: Object Detection with TensorFlow Lite Model Maker
Step2: Import the required packages.
Step3: Prepare the dataset
Step4: Step 2. Load the dat... |
14,676 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import time
import pylab as pl
from IPython import display
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(... | <SYSTEM_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... |
14,677 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.2,<2.3"
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b['q'] = 0.8
b['ecc'] = 0.1
b['irrad_method'] = 'none'
b.add_dataset('orb', compute_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: This first line is only necessary for ipython noteboooks - it allows the plots to be shown on this page instead of in interactive mode
Step2: A... |
14,678 | <ASSISTANT_TASK:>
Python Code:
# Import libraries
import numpy as np
import pandas as pd
from time import time
from sklearn.metrics import f1_score
# Read student data
student_data = pd.read_csv("student-data.csv")
print "Student data read successfully!"
# Calculate number of students
n_students = len(student_data.ind... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementation
Step2: Preparing the Data
Step3: Preprocess Feature Columns
Step4: Implementation
Step5: Training and Evaluating Models
Step6... |
14,679 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('kQmHaI5Jw1c', width=800, height=450)
from IPython.display import YouTubeVideo
YouTubeVideo('YbNE3zhtsoo', width=800, height=450)
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here is the ReLU activation function link that Dan mentioned.
Step2: Let's build our model
Step3: Compile and fit
Step4: You know the drill, ... |
14,680 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import io
from mne.time_frequency import single_trial_power
from mne.stats import permutation_cluster_test
from mne.da... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Set parameters
Step2: Compute statistic
Step3: View time-frequency plots
|
14,681 | <ASSISTANT_TASK:>
Python Code:
from copy import copy
import datetime
import os
from pathlib import Path
from pprint import pprint
import shutil
import time
from zipfile import ZipFile
import numpy as np
from planet import api
from planet.api import downloader, filters
# if your Planet API Key is not set as an environm... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 1
Step2: Step 2
Step3: Step 3
Step4: Step 4
Step5: Step 4.2
Step6: Step 5
Step7: Step 5.2
Step8: Step 6
|
14,682 | <ASSISTANT_TASK:>
Python Code:
import pyspark
sc = pyspark.SparkContext(appName="my_spark_app")
lines = sc.textFile("../data/people.csv")
lines.count()
lines.first()
lines = sc.textFile("../data/people.csv")
filtered_lines = lines.filter(lambda line: "individuum" in line)
filtered_lines.first()
# loading an external... | <SYSTEM_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 first thing to note is that with Spark all computation is parallelized by means of distributed data structures that are spread through the c... |
14,683 | <ASSISTANT_TASK:>
Python Code:
from math import *
L = 500
sigma0 = 5.8e7
alpha = 0.0039
d = 0.2e-3
T0 = 20
# The cross section area
S = pi/4*d**2
# Resistance @ -45
R_1 = L/(sigma0*S)*(1+alpha*(-45-T0))
# Resistance @ +10
R_2 = L/(sigma0*S)*(1+alpha*(+10-T0))
print('R(-45) = %2.2f Ohm' % (R_1))
print('R(+10) = %2.2f Oh... | <SYSTEM_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 compute the currents by $I=V/R$.
Step2: We know the resistance is linear with the temperature. However, the current is not. We can check... |
14,684 | <ASSISTANT_TASK:>
Python Code:
import logging
import random
import time
import matplotlib.pyplot as plt
import mxnet as mx
from mxnet import gluon, nd, autograd
import numpy as np
batch_size = 128
epochs = 5
ctx = mx.gpu() if len(mx.test_utils.list_gpus()) > 0 else mx.cpu()
lr = 0.01
train_dataset = gluon.data.vision... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parameters
Step2: Data
Step3: We assign the transform to the original dataset
Step4: We load the datasets DataLoaders
Step5: Multi-task Netw... |
14,685 | <ASSISTANT_TASK:>
Python Code:
# 10 segons de vídeo.
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview(alpha=200)
sleep(10)
camera.stop_preview()
# Guardar una imatge
camera.start_preview()
sleep(5)
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()
# És 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: Guardant una imatge
Step2: GRAVANT UN VIDEO
Step3: EFECTES
Step4: La ressolució mínima és de 64x64, proveu de fer una foto amb aquesta ressol... |
14,686 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import roc_auc_score
congr_datasetDF = pd.DataFrame.from_csv('https://raw.githubusercontent.com/oslugr/contami... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: FORZAMOS VALORES NUMERICOS. ALLI DONDE NO ES POSIBLE SERA PORQUE NO HABIA DATOS, O ERAN TEXTO. ESOS PASAN A SER NP.NAN, AHORA MAS ABAJO LES METE... |
14,687 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alex Rockhill <aprockhill@mailbox.org>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
raw = mne.io.read_raw_fif(data_path + '/MEG/sample/sample_audvis_raw.fif... | <SYSTEM_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 sample subject data
Step2: Plot the raw data and CSD-transformed raw data
Step3: Also look at the power spectral densities
Step4: CSD ca... |
14,688 | <ASSISTANT_TASK:>
Python Code:
data2 = data[(data.TMIN>-9999)]
data3 = data2[(data2.DATE>=20150601) & (data2.DATE<=20150630) & (data2.PRCP>0)]
stations = data2[(data2.STATION=='GHCND:USC00047326') | (data2.STATION=='GHCND:USC00047902') | (data2.STATION=='GHCND:USC00044881')]
st = stations.groupby(['STATION'])
temp = s... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: So we can print data3 and, then, select the stations in the table that will be printed.
Step2: Analysing the plot above, we can see that the 3 ... |
14,689 | <ASSISTANT_TASK:>
Python Code:
import sympy
x, u = sympy.symbols('x u', real=True)
U = sympy.Function('U')(x,u)
U
x = sympy.Symbol('x',real=True)
y = sympy.Function('y')(x)
U = sympy.Function('U')(x,y)
X = sympy.Function('X')(x,y)
Y = sympy.Function('Y')(X)
sympy.pprint(sympy.diff(U,x))
sympy.pprint( sympy.diff(Y,x))
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The case of a(n arbitrary) point transformation
Step2: For $Y''(X)$,
Step4: cf. How to do total derivatives
Step5: This transformation is the... |
14,690 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
from IPython.html.widgets import interact, interactive, fixed
Image('fermidist.png')
def fermidist(energy, mu, kT):
Compute the Fermi distribution at energy, mu and kT.
H = (1... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exploring the Fermi distribution
Step3: In this equation
Step4: Write a function plot_fermidist(mu, kT) that plots the Fermi distribution $F(\... |
14,691 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import sys, os, copy, logging, socket, time
import numpy as np
import pylab as plt
#from ndparse.algorithms import nddl as nddl
#import ndparse as ndp
sys.path.append('..'); import ndparse as ndp
try:
logger
except:
# do this p... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Step 2
Step2: Step 3
Step3: Step 4
|
14,692 | <ASSISTANT_TASK:>
Python Code:
# Create a SystemML MLContext object
from systemml import MLContext, dml
ml = MLContext(sc)
%%sh
mkdir -p data/mnist/
cd data/mnist/
curl -O https://pjreddie.com/media/files/mnist_train.csv
curl -O https://pjreddie.com/media/files/mnist_test.csv
script_string =
source("nn/examples/mnis... | <SYSTEM_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 Data - MNIST
Step3: SystemML "LeNet" Neural Network
Step5: 2. Compute Test Accuracy
Step6: 3. Extract Model Into Spark DataFrames Fo... |
14,693 | <ASSISTANT_TASK:>
Python Code:
class BankAccount:
"Represents a bank account."
def __init__(self, account_number=None):
"Initialize or create a new account."
self.account_number = ''
self.__balance = 0
self.holder = None
self._transactions = []
if ac... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Das ist nun relativ viel Code. Wesentlich aus der Sicht der Kapselung sind hier zwei Dinge
Step2: Sollte sich die Mehrwertsteuer ändern, kann d... |
14,694 | <ASSISTANT_TASK:>
Python Code:
client = Media(env="test", debug=False).configured_login(create_config_file=True)
client.url
result = client.get("POMS_NTR_388772")
print(json.dumps(json.loads(result), indent=1))
client.get("bla")
<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: The credentials where read from a config file. If that file would not have existed, the user would have been requested to provide the api key, s... |
14,695 | <ASSISTANT_TASK:>
Python Code:
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) / 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
print quicksort(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Python versions
Step2: Note that unlike many languages, Python does not have unary increment (x++) or decrement (x--) operators.
Step3: Now we... |
14,696 | <ASSISTANT_TASK:>
Python Code:
from scipy import sparse
sa = sparse.random(10, 10, density = 0.01, format = 'lil')
result = (sa.count_nonzero()==0)
<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:
|
14,697 | <ASSISTANT_TASK:>
Python Code:
import time
import numpy as np
import tensorflow as tf
import utils
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import zipfile
dataset_folder_path = 'data'
dataset_filename = 'text8.zip'
dataset_name = 'Text8 Dataset'
class DLProgress(tq... | <SYSTEM_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 text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ... |
14,698 | <ASSISTANT_TASK:>
Python Code:
sig_train_modes_names = [11114001, 11296013, 11874042, 12103035, 13246001, 13264021]
bck_train_mode_name = 30000000
sig_train_files = ['mod_{}.csv'.format(name) for name in sig_train_modes_names]
bck_train_files = 'mod_30000000.csv'
folder = "datasets/prepared_hlt_body/"
# concat all sign... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Counting events and svrs,
Step2: events distribution by mode
Step3: Define variables
Step4: Counting events and svrs,
Step5: events distribu... |
14,699 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import math
import re
from scipy.sparse import csr_matrix
import matplotlib.pyplot as plt
import seaborn as sns
from surprise import Reader, Dataset, SVD, evaluate
sns.set_style("darkgrid")
# Skip date
df1 = pd.read_csv('../input/combined_data_1.txt... | <SYSTEM_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 let's load first data file and get a feeling of how huge the dataset is
Step2: Let's try to load the 3 remaining dataset as well
Step3: N... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.