Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
13,900 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from sklearn.preprocessing import Imputer
from sklearn import tree
from sklearn import metrics
import numpy as np
import matplotlib.pyplot as plt
% matplotlib inline
#train_df = pd.read_csv("titanic.csv")
#test_df = pd.read_csv("titanic_test.csv")
from google.colab 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: visit http
Step2: What happen when we change the tree depth?
Step3: Try by yourself
Step4: Random Forest
|
13,901 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.extend(['../'])
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
%matplotlib inline
import onsager.crystal as crystal
import onsager.OnsagerCalc as onsager
from scipy.constants import physical_constants
kB = physical_constants['Bolt... | <SYSTEM_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 need to analyze the geometry of our representative site; we get the position, then find the zero entry in the position vector, and work from ... |
13,902 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.spatial.distance import cdist
def centroids(X_nd, label_n):
Given X_nd, a 2-dimensional array of n d-dimensional points,
and n cluster assignments label_n (a 1-d array of n labels,
ints in range [0, k)), return (c_kd, dist_n) the k centroids ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Frequently, we run into situations where need to deal with arrays of varying sizes in numpy. These result in much slower code that deals with di... |
13,903 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('../Evaluation')
from eval_proposal import ANETproposal
import matplotlib.pyplot as plt
import numpy as np
import json
%matplotlib inline
def run_evaluation(ground_truth_filename, proposal_filename,
max_avg_nr_proposals=100,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Help functions to evaluate a proposal submission file and plot the metric results
Step2: Generate uniform random proposal for the validation su... |
13,904 | <ASSISTANT_TASK:>
Python Code:
def name_of_function(arg1,arg2):
'''
This is where the function's Document String (doc-string) goes
'''
# Do stuff here
#return desired result
def say_hello():
print 'hello'
say_hello()
def greeting(name):
print 'Hello %s' %name
greeting('Jose')
def add_num... | <SYSTEM_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 begin with def then a space followed by the name of the function. Try to keep names relevant, for example len() is a good name for a length()... |
13,905 | <ASSISTANT_TASK:>
Python Code:
%libraryDependencies += "org.viz.lightning" %% "lightning-scala" % "0.1.6"
%update
import org.viz.lightning._
import org.apache.spark.graphx._
val lgn = Lightning(host="https://lightning-spark-summit.herokuapp.com" )
lgn.enableNotebook()
val source = "/Users/mathisonian/projects/spark-su... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load structure similarity data
Step2: Show the network (unlabeled)
Step3: Show the network colored by degree
Step4: Show the network colored ... |
13,906 | <ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
from os.path import isfile
from tqdm import tqdm
class DLProgress(tqdm):
last_block = 0
def hook(self, block_num=1, block_size=1, total_size=None):
self.total = total_size
self.update((block_num - self.last_block) * block_size... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Overview
Step2: Load the Data
Step3: Preprocess the Data
Step4: Normalize the features
Step5: One-Hot Encode the labels
Step6: Keras Sequen... |
13,907 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
a = np.arange(1, 16).reshape(3, 5).T
a
np.arange(1, 6)[:, np.newaxis] + np.arange(0, 11, 5)
a = np.arange(25).reshape((5,5))
a
b = np.array([1., 5, 10, 15, 20])
b
a/b[:, np.newaxis]
x = np.random.rand(10,3)
a= np.abs(x - 0.5)
b = a.argsort()
b
e = b[:, 0]
f = np.tile... | <SYSTEM_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
Step2: 문제 2
Step3: 문제 3
Step4: 문제 4
Step5: plt.imshow 함수를 이용하여 이미지를 확인할 수 있다.
Step6: 위 사진은 2차원 어레이 정보를 이용하므로 정확하지 않다.
Step7: 영역선택(cr... |
13,908 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import blosc
import tensorflow as tf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from tqdm import tqdm_notebook as tqn
from collections import OrderedDict
%matplotlib inline
sys.path.append('../../..')
from batch import ResBatch, ax_draw
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: We will train the model with the following parameters
Step2: About parameters
Step3: We'll compare ResNet model with FreezeOut vs classic ResN... |
13,909 | <ASSISTANT_TASK:>
Python Code:
AMOUNT_VETS = 1000
AMOUNT_SPECIALTIES = 2 * AMOUNT_VETS
AMOUNT_OWNERS = 10 * AMOUNT_VETS
AMOUNT_PETS = 2 * AMOUNT_OWNERS
AMOUNT_PET_TYPES = int(AMOUNT_PETS / 10)
AMOUNT_VISITS = 2 * AMOUNT_PETS
print(
Generating fake data for
- %d vets,
- each having ~%d specialties,
- each for serving ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TL;DR I generate a big amount of fake data for Spring PetClinic with Faker that I store directly in a MySQL database via Pandas / SQLAlchemy.
St... |
13,910 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings("ignore")
from astropy.io import ascii
import pandas as pd
names = ["BKLT","Other ID","RA_1950","DEC_1950","SpT_prev","SpT_IR","SpT_adopted",
"Teff","AJ","Lbol","J-H","H-K","K","rK","BrGamma"]
tbl1 = pd.read_csv("http://iopscience.iop.org... | <SYSTEM_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 1 - Data for Spectroscopic Sample in ρ Ophiuchi
Step2: Save data
|
13,911 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
import cmath
def loop_DFT(x):
Implementing the DFT in a double loop
Input: x = the vector we want to find the DFT of
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step3: This assignment is to implement a python-based Fast Fourier Transform (FFT). Building on $\S$ 2.8 ➞ we will implement a 1-D radix-2 Coole... |
13,912 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import lfilter
import librosa
import librosa.display
import IPython.display as ipd
wave_filename = 'speech_segment.wav'
# load file, do *not* resample
x, sampling_rate = librosa.load(wave_filename, sr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Consider two different wave files
Step2: Plot the correlation of $x[k]$ and $d[k]$ to show long-term effects
|
13,913 | <ASSISTANT_TASK:>
Python Code:
parser = ISFReader("inputs/isc_test_catalogue_isf.txt",
selected_origin_agencies=["ISC", "GCMT", "HRVD", "NEIC", "EHB", "BJI"],
selected_magnitude_agencies=["ISC", "GCMT", "HRVD", "NEIC", "BJI"])
catalogue = parser.read_file("ISC_DB1", "ISC Global 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: Define Rule Sets
Step4: Magnitude Rules
Step11: ISC/NEIC
Step16: BJI
Step17: Define Magnitude Hierarchy
Step18: Pre-processing
Step19: Har... |
13,914 | <ASSISTANT_TASK:>
Python Code:
# Start with importing some packages
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# I want to make a pcolor map with only lots of nice shades of purple and maybe some pink
# How many colors do you want?
nbr_color = 10
# Initiate a color array
purples = np.zeros(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: 1) Only purple and pink colors
Step2: 2) How many years is a year on the other planets?
Step3: 3) The Menu
Step4: 4) Vega-like stars with Gai... |
13,915 | <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:
Step2: Composing Decision Forest and Neural Network models
Step3: Your composed model has three stages
Step4: Wurlitzer is needed to display the deta... |
13,916 | <ASSISTANT_TASK:>
Python Code:
import ee
ee.Initialize()
from geetools import batch
p1 = ee.Geometry.Point([-71,-42])
p2 = ee.Geometry.Point([-71,-43])
p3 = ee.Geometry.Point([-71,-44])
feat1 = ee.Feature(p1.buffer(1000), {'site': 1})
feat2 = ee.Feature(p2.buffer(1000), {'site': 2})
feat3 = ee.Feature(p3.buffer(1000),... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: FeatureCollection
Step2: Image
Step3: Execute
|
13,917 | <ASSISTANT_TASK:>
Python Code:
import scipy.io
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
mat_data = scipy.io.loadmat('/train_1/1_12_1.mat')
' :: '.join([str(mat_data['__header__']), str(mat_data['__version__']), str(mat_data['__globals__'])])
data = mat_data['dataStruct']
for i in [data, 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: NIH Seizure
Step2: Load the Data Scientist weapons
Step5: Create some usefull methods
Step6: Load the files and calculate their Standar devia... |
13,918 | <ASSISTANT_TASK:>
Python Code:
BATCH_SIZE = 128
EPOCHS = 10
training_images_file = 'gs://mnist-public/train-images-idx3-ubyte'
training_labels_file = 'gs://mnist-public/train-labels-idx1-ubyte'
validation_images_file = 'gs://mnist-public/t10k-images-idx3-ubyte'
validation_labels_file = 'gs://mnist-public/t10k-label... | <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: Imports
Step3: tf.data.Dataset
Step4: Let's have a look at the data
Step5: Keras model
Step6: Learning Rate schedule
Step7: Train and valid... |
13,919 | <ASSISTANT_TASK:>
Python Code:
from math import sin, cos, log, ceil
import numpy
from matplotlib import pyplot
%matplotlib inline
from matplotlib import rcParams
rcParams['font.family'] = 'serif'
rcParams['font.size'] = 16
# model parameters:
g = 9.8 # gravity in m s^{-2}
v_t = 30.0 # trim velocity in m s^{-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:
Step3: We will again need the code implementing Euler's method the full phugoid model notebook.
Step4: This time we will need lots of solutions in ord... |
13,920 | <ASSISTANT_TASK:>
Python Code:
from bigbang.archive import Archive
import pandas as pd
arx = Archive("ipython-dev",archive_dir="../archives")
print(arx.data.shape)
arx.data.drop_duplicates(subset=('From','Date'),inplace=True)
response_times = []
response_times = []
for x in list(arx.data.iterrows()):
if x[1]['In-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: We will look at messages in our archive that are responses to other messages and how long after the original email the response was made.
|
13,921 | <ASSISTANT_TASK:>
Python Code:
%config InlineBackend.figure_format = 'retina'
import numpy as np
import matplotlib.pyplot as plt
import uncertainties as uct
from uncertainties import unumpy as unp
import pandas as pd
import pytheos as eos
x = unp.uarray(np.linspace(0.01,15.,20), np.ones(20)*0.5) # 0.1,7.25
energy = 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: 0. General note
Step2: 1. Calculate Debye energy with uncertainties
Step3: 2. Calculate Gruneisen parameter
Step4: Calculate Gruneisen parame... |
13,922 | <ASSISTANT_TASK:>
Python Code:
import PaSDqc
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pathlib
%matplotlib inline
%load_ext autoreload
%autoreload 2
sns.set_context('poster')
sns.set_style("ticks", {'ytick.minor.size': 0.0, 'xtick.minor.size': 0.0})
chr1_MN1a =... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Analyze MN1a from Zhang et al, 2015
Step2: Analyze 1465 MDA 30 from Lodato et al, 2015
Step3: Make the figure
|
13,923 | <ASSISTANT_TASK:>
Python Code:
!pip install tqdm
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import problem_unittests as tests
import tarfile
cifar10_dataset_folder_path = '/Users/syednasar/sn/dev/workspace/myg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
13,924 | <ASSISTANT_TASK:>
Python Code:
# Execute this cell to load the notebook's style sheet, then ignore it
from IPython.core.display import HTML
css_file = '../style/custom.css'
HTML(open(css_file, "r").read())
import numpy
numpy.array([3, 5, 8, 17])
numpy.ones(5)
numpy.zeros(3)
numpy.arange(4)
numpy.arange(2, 6)
numpy.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Play with NumPy Arrays
Step2: Creating arrays
Step3: NumPy offers many ways to create arrays in addition to this. We already mentioned some of... |
13,925 | <ASSISTANT_TASK:>
Python Code:
import io, os, sys, types
from IPython import get_ipython
from nbformat import read
from IPython.core.interactiveshell import InteractiveShell
def find_notebook(fullname, path=None):
find a notebook, given its fully qualified name and an optional path
This turns "foo.bar" in... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step2: Import hooks typically take the form of two objects
Step5: Notebook Loader
Step7: The Module Finder
Step8: Register the hook
Step9: After th... |
13,926 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(filename='circuit.png')
# %matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from IPython.display import HTML, display
# For tables
def tableit(data):
display(HTML(
'<table><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: Parameters
Step2: Currents
Step3: Voltages
Step4: Offset of signal voltage
Step5: Dependency of signal voltage on the mains voltage
Step6: ... |
13,927 | <ASSISTANT_TASK:>
Python Code:
We begin by using an inbuilt iPython Magic function to display plots
within the window.
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib
print(matplotlib.__version__)
%matplotlib inline
import matplotlib.pyplot as chuck_norris
y = [1,2,3,4,5,4,3,2,1]
x = [2,4,6,8,10,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Table of Contents
Step2: import matplotlib.pyplot as plt is python convention. <br>
Step3: So as you see, the convention plt can save you from... |
13,928 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
subjects = pd.read_csv('./data/subjects.csv')
nodes = pd.read_csv('./data/nodes.csv')
merged = pd.merge(nodes, subjects, on="subjectID")
merged.head()
import matplotlib.pyplot as plt
import seaborn as sns
stats = nodes.columns.drop(["subjectID", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Merging nodes and subjects
Step2: Visualizing the data
Step3: We focus on the calculated diffusion statistics that are included in the nodes t... |
13,929 | <ASSISTANT_TASK:>
Python Code:
%run "../Functions/2. Google form analysis.ipynb"
import mca
np.set_printoptions(formatter={'float': '{: 0.4f}'.format})
pd.set_option('display.precision', 5)
pd.set_option('display.max_columns', 25)
data = pd.read_table('../../data/burgundies.csv',sep=',', skiprows=1, index_col=0, head... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MCA
Step2: For input format, mca uses
Step3: Table 1
Step4: MCA
Step5: Table 2 (L, expl_var)
Step6: The inertia is simply the sum of the p... |
13,930 | <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... |
13,931 | <ASSISTANT_TASK:>
Python Code:
from hgvs.easy import (__version__, parser, hdp, vm)
from hgvs.exceptions import HGVSDataNotAvailableError
__version__
# hgvs_g = "NC_000010.11:g.94762693G>A" # GRCh38
hgvs_g = "NC_000010.10:g.96522450G>A" # GRCh37
hgvs_c = "NM_000769.4:c.-13G>A"
var_c = parser.parse(hgvs_c)
var_g = par... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Discovering available alignments
Step2: Alignments for a gene
Step3: Alignments for a genomic region (new method)
Step4: Alternate method for... |
13,932 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
import scipy.stats as ss
import numpy.linalg as linalg
x1 = [1, 1, -1, -1]
x2 = [1, -1, 1, -1]
y = [1.2, 3.2, 4.1, 3.6]
x_mat = np.column_stack((np.ones(4), x1, x2))
x_mat
beta, *_ = linalg.lstsq(x_mat, y)
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: We'll use multidimensional ordinary least squares with an intercept
Step2: We'll compute our coefficients and their standard error
Step3: Now ... |
13,933 | <ASSISTANT_TASK:>
Python Code:
iloczyn = set([1, 2, 3, 4, 5]) & set([3, 4])
suma = set([1, 2, 3,]) | set([4, 5])
roznica = set([1, 2, 3, 4, 5]) - set([4, 5])
print(iloczyn)
print(suma)
print(roznica)
a = [1, 2, 3, 4]
b = [2, 3]
zbior1 = set(a)
zbior2 = set(b)
iloczyn = zbior1 & zbior2
print(zbior2)
imiona = {
"and... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Słowniki (Maps/Dictionaries)
Step2: OrderedDict
Step3: Counter
|
13,934 | <ASSISTANT_TASK:>
Python Code:
# それぞれ必要なものを import するけど、こういう風に短く書くのがこっち界隈だと一般的らしい
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Creating a Series by passing a list of values, letting pandas create a default integer index:
# リストを指定してシリーズを作成すると、Pandasはデフォルトで数値のインデックスを生成する
s = pd.Series([1,3,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: Object creation
Step2: Viewing Data
|
13,935 | <ASSISTANT_TASK:>
Python Code:
!pip install -q -U "tensorflow-text==2.8.*"
!pip install -q tf-models-official==2.4.0
import os
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds
tfds.disable_progress_bar()
from official.modeling 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: Imports
Step2: Resources
Step3: You can get a pre-trained BERT encoder from TensorFlow Hub
Step4: The data
Step5: The info object describes ... |
13,936 | <ASSISTANT_TASK:>
Python Code:
#code for making artificial dataset
import random
def swap_two_characters(seq):
'''define a function that swaps two characters at random positions in a string '''
line = list(seq)
id_i = random.randint(0,len(line)-1)
id_j = random.randint(0,len(line)-1)
line[id_i], lin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Artificial data generation
Step2: Discriminative model on categorical labels
Step3: Note
Step4: Model Auto Optimization
|
13,937 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pylab as plt
import oedes
import numpy as np
oedes.init_notebook() # for displaying progress bars
L = 200e-9 # device thickness, m
model = oedes.models.std.electrononly(L, traps=['trap'])
params = {
'T': 300, # K
'electrode0.workfunction': 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: Model and parameters
Step2: Sweep parameters
Step3: Result
|
13,938 | <ASSISTANT_TASK:>
Python Code:
# Import essential libraries for following calculation
import libpysal as ps
import numpy as np
from libpysal.cg.shapes import Ring, Polygon
from libpysal.cg.segmentLocator import BruteSegmentLocator
from libpysal.cg.polygonQuadTreeStructure import QuadTreeStructureSingleRing
import libpy... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: How to Use
Step2: The process of building quadtree
Step3: Visualizing the result of "Point in Polygon" test
Step4: Test the performance of th... |
13,939 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# RMS Titanic data visualization code
from titanic_visualizations import survival_stats
from IPython.display import display
%matplotlib inline
# Load the dataset
in_file = 'titanic_data.csv'
full_data = pd.read_csv(in_file)
# Print the first few ent... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: From a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship
Step3: The very same sample of th... |
13,940 | <ASSISTANT_TASK:>
Python Code:
data_agr = pd.read_csv('CrowdstormingDataJuly1st_aggregated_encoded.csv')
data_agr.head()
data_agr = data_agr.drop(['playerShort', 'player'], axis=1)
data_train = data_agr.drop(['color_rating'], axis=1)
colors = data_agr['color_rating']
col = data_train.columns
data_train = pd.DataFrame(... | <SYSTEM_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 drop the features that are unique to the players and we normalize them. That way all the features will be in [-1;1]. We also remove the color... |
13,941 | <ASSISTANT_TASK:>
Python Code:
print_synonyms('dx::440.0', model)
#Crohn's Disease
print_synonyms('dx::555.9', model)
print_synonyms_filt('dx::042', model, 'rx')
<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: Peptic Ulcers
Step2: Arthritis
|
13,942 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from google.cloud import bigquery
PROJECT = !gcloud config get-value project
PROJECT = PROJECT[0]
%env PROJECT=$PROJECT
def create_query(phase, sample_size):
basequery =
SELECT
(tolls_amount + fare_amount) AS fare_amount,
EXTRACT(DAYOFWEEK 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:
Step5: Review
Step6: Write to CSV
Step7: Note that even with a 1/5000th sample we have a good amount of data for ML. 150K training examples and 30K v... |
13,943 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 転移学習で花を分類する
Step4: Flowers データセット
Step10: データを確認する
Step12: モデルを構築する
Step16: ネットワークをトレーニングする
Step17: 不正確な予測
|
13,944 | <ASSISTANT_TASK:>
Python Code:
import torch
from torch.autograd import Variable
x = Variable(torch.Tensor([[1], [2], [3]]))
y = Variable(torch.Tensor([[1], [2], [3]]))
w = Variable(torch.randn(1, 1), requires_grad = True)
b = Variable(torch.randn(1), requires_grad = True)
learning_rate = 1e-2
# trainning
for i in ran... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: optimizer 이용하여 구현
Step2: torch.nn에서 제공하는 funcion으로 구현
Step3: Tensorflow 코드와 비교
|
13,945 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
try:
from importlib import reload # python3
except:
pass # python2 (reload in default namespace)
import sys
import shutil
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import flopy
from flopy.utils.geometry import Polygon, LineStrin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: write a numpy record array to a shapefile
Step2: set the spatial reference
Step3: make geometry objects for the cells with errors
Step4: writ... |
13,946 | <ASSISTANT_TASK:>
Python Code:
import skgstat as skg
from skgstat.util.likelihood import get_likelihood
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import minimize
import warnings
from time import time
import matplotlib.pyplot as plt
warnings.filterwarnings('ignore')
# use the same dataset a... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We use the pancake dataset, sampled at 300 random locations to produce a quite dense sample.
Step2: First of, the variogram is calculated. We u... |
13,947 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_digits
from sklearn.cross_validation import train_test_split
digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data,
digits.target)
from sklearn.pipeline import Pipeline,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Cross-validated pipelines including scaling, we need to estimate mean and standard deviation separately for each fold.
Step2: Cross-validation ... |
13,948 | <ASSISTANT_TASK:>
Python Code:
# We really like this spiral dataset
import numpy as np
import matplotlib.pyplot as plt
N = 1000 # points per class
D = 2 # dimensionality at 2 so we can eyeball it
K = 3 # number of classes
X = np.zeros((N*K, D)) # generate an empty matrix to hold X features
y = np.zeros(N*K, dtype='int3... | <SYSTEM_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 much more highly optimized DNNClassifier
Step2: Launching TensorBoard
Step3: Notice that the accuracy only contains one point. That's becaus... |
13,949 | <ASSISTANT_TASK:>
Python Code:
import pyperclip
import pyautogui
# PyAutoGUI中文输入需要用粘贴实现
# Python 2版本的pyperclip提供中文复制
def paste(foo):
pyperclip.copy(foo)
pyautogui.hotkey('ctrl', 'v')
foo = u'学而时习之'
# 移动到文本框
pyautogui.click(130,30)
paste(foo)
import pyautogui
screenWidth, screenHeight = pyautogui.size()
pyau... | <SYSTEM_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.简介
Step2: PyAutoGUI可以模拟鼠标的移动、点击、拖拽,键盘按键输入、按住操作,以及鼠标+键盘的热键同时按住等操作,可以说手能动的都可以。
Step3: 1.4 保护措施(Fail-Safes)
Step4: 通过把pyautogui.PAUSE设置成float或... |
13,950 | <ASSISTANT_TASK:>
Python Code:
cat /proc/cpuinfo
# import libraries and set up the molecule geometry
from ase.units import Ry, eV, Ha
from ase.calculators.siesta import Siesta
from ase import Atoms
import numpy as np
import matplotlib.pyplot as plt
H2O = Atoms('H2O', positions = [[-0.757, 0.586, 0.000],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: I do not have on my laptop an
Step2: We can then run the DFT calculation using Siesta
Step3: The TDDFT calculations with PySCF-NAO
|
13,951 | <ASSISTANT_TASK:>
Python Code:
n = 50000
min_timestamp = '2000-01-01T00:00:00Z' # start of time
t1 = time.time()
query =
SELECT
*
FROM
enwiki.article_talk_diff_no_bot_sample
WHERE
rev_timestamp > '%(min_timestamp)s'
AND ns = 'article'
LIMIT %(n)d
params = {
'n': int(n * 1.7),
'min_timestamp':... | <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: Query
|
13,952 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('/home/pi/minecraft-programming')
import mcpi.block as block
import time
import drawings
# Task 1 program
userName="blah"
mc.postToChat(userName)
# Task 2 program
drawings.drawMyCircle(radius, blockToUse)
# Task 3 program
# Task 4 program
drawings.drawSolid(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Task 1
Step2: Task 2
Step3: 3D Shapes and Polyhedrons
Step4: Task 4
|
13,953 | <ASSISTANT_TASK:>
Python Code:
import flexcode
import numpy as np
import xgboost as xgb
from flexcode.regression_models import XGBoost, CustomModel
def generate_data(n_draws):
x = np.random.normal(0, 1, n_draws)
z = np.random.normal(x, 1, n_draws)
return x, z
x_train, z_train = generate_data(5000)
x_valida... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Data Creation
Step2: FlexZBoost
Step3: Custom Model
Step4: The two conditional density estimates should be the same across the board. <br>
|
13,954 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.imports import *
from fastai.structured import *
from pandas_summary import DataFrameSummary
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
from IPython.display import display
from sklearn 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: 2. Data
Step2: In any sort of analytics work, it's important to look at your data, to make sure you understand the format, how it's stored, wha... |
13,955 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
probabilit = [0.333, 0.334, 0.333]
lista_elegir = [(3, 3), (3, 4), (3, 5)]
samples = 1000
np.random.seed(42)
temp = np.array(lista_elegir)
result = temp[np.random.choice(len(lista_elegir),samples,p=probabilit)]
<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:
|
13,956 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from IPython.core.display import HTML
import warnings
warnings.filterwarnings('ignore')
import os
if os.getcwd().split('/')[-1] == 'notebooks':
os.chdir('../')
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Notebook Config
Step2: Data Preprocessing
Step3: Exploration
Step4: Data Munging
Step5: Feature Engineering
Step6: Drop Features
Step7: Lo... |
13,957 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import networkx as nx
Gu = nx.Graph()
for i, j in [(1, 2), (1, 4), (4, 2), (4, 3)]:
Gu.add_edge(i,j)
nx.draw(Gu, with_labels = True)
import networkx as nx
Gd = nx.DiGraph()
for i, j in [(1, 2), (1, 4), (4, 2), (4, 3)]:
Gd.add_edg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Directed
Step2: <img src = './img/networks.png' width = 1000>
Step3: Undirected network
Step4: Directed network
Step5: For a sample of N val... |
13,958 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy.integrate import odeint
from IPython.html.widgets import interact, fixed
g = 9.81 # m/s^2
l = 0.5 # length of pendulum, in meters
tmax = 50. # seconds
t = np.linspace(0, tmax, 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: Damped, driven nonlinear pendulum
Step4: Write a function derivs for usage with scipy.integrate.odeint that computes the derivatives for the da... |
13,959 | <ASSISTANT_TASK:>
Python Code:
help('learning_lab.03_interface_names')
from importlib import import_module
script = import_module('learning_lab.03_interface_names')
from inspect import getsource
print(getsource(script.main))
print(getsource(script.demonstrate))
run ../learning_lab/03_interface_names.py
from basics.o... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementation
Step2: Execution
Step3: HTTP
|
13,960 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mri', 'sandbox-3', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,961 | <ASSISTANT_TASK:>
Python Code:
!curl -Lo conda_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import conda_installer
conda_installer.install()
!/root/miniconda/bin/conda info -e
!pip install --pre deepchem
import deepchem as dc
tasks, datasets, transformers = dc.molnet... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: What are Graph Convolutions?
Step2: Let's now train a graph convolutional network on this dataset. DeepChem has the class GraphConvModel that w... |
13,962 | <ASSISTANT_TASK:>
Python Code:
# Authors: Teon Brooks <teon.brooks@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
from mne.report import Report
from mne.datasets import sample
from mne import read_evokeds
from matplotlib import pyplot as plt
data_path = sample.data_path()
meg_pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Do standard folder parsing (this can take a couple of minutes)
Step2: Add a custom section with an evoked slider
|
13,963 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cams', 'sandbox-2', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "em... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,964 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import rampy as rp
x = np.arange(0,100,1.0) # a dummy x axis
ref1 = 50.0*np.exp(-1/2*((x-40)/20)**2) + np.random.randn(len(x)) # a gaussian with added noise
ref2 = 70.0*np.exp(-1/2*((x-60)/15)**2) + np.random.randn(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: Problem setting
Step2: We now create 4 intermediate $obs$ signals, with $F1$ = 20%,40%,60% and 80% of ref1.
Step3: Now we can use rp.mixing_sp... |
13,965 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
data = [446.6565, 454.4733, 455.663 , 423.6322, 456.2713, 440.5881, 425.3325, 485.1494, 506.0482, 526.792 , 514.2689, 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: Simple Exponential Smoothing
Step2: Here we run three variants of simple exponential smoothing
Step3: Holt's Method
Step4: Seasonally adjuste... |
13,966 | <ASSISTANT_TASK:>
Python Code:
import pickle
import os
import glob
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn.model_selection as skms
import sklearn.linear_model as skl
import sklearn.metrics as skm
import tqdm
import copy
import time
from IPython.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: Reading in the data
Step2: This dataset consists of $10000$ samples, i.e., $10000$ spin configurations with $40 \times 40$ spins each, for $16$... |
13,967 | <ASSISTANT_TASK:>
Python Code:
import twitter
CONSUMER_KEY =
CONSUMER_SECRET =
OAUTH_TOKEN =
OAUTH_TOKEN_SECRET =
# let's do the Oauth dance!
auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET)
twitter_api = twitter.Twitter(auth=auth)
# success if object created
print(twitter_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Twitter uses Where On Earth identifiers for places - see http
Step2: The format above is json (javascript object notation). You can read about ... |
13,968 | <ASSISTANT_TASK:>
Python Code:
!pip install -q numpyro@git+https://github.com/pyro-ppl/numpyro
# first, we need some imports
import os
from IPython.display import set_matplotlib_formats
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
from jax import numpy as jnp
from jax import random
from 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: Dataset
Step2: Look at the data info, we know that there are missing data at Age, Cabin, and Embarked columns. Although Cabin is an important f... |
13,969 | <ASSISTANT_TASK:>
Python Code:
from stix2 import Identity
Identity(name="John Smith",
identity_class="individual",
x_foo="bar")
identity = Identity(name="John Smith",
identity_class="individual",
custom_properties={
"x_foo": "bar"
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: To create a STIX object with one or more custom properties, pass them in as a dictionary parameter called custom_properties
Step2: Alternativel... |
13,970 | <ASSISTANT_TASK:>
Python Code:
np.random.seed(0)
X_xor = np.random.randn(200, 2)
y_xor = np.logical_xor(X_xor[:, 0] > 0, X_xor[:, 1] > 0)
y_xor = np.where(y_xor, 1, -1)
plt.scatter(X_xor[y_xor==1, 0], X_xor[y_xor==1, 1], c='b', marker='o', label='1', s=100)
plt.scatter(X_xor[y_xor==-1, 0], X_xor[y_xor==-1, 1], c='r', 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: 기저 함수를 사용한 비선형 판별 모형
Step2: 커널 트릭
Step3: 커널의 의미
Step4: 커널 파라미터
Step5: 예
Step6: KSVM에서 사실 가장 많이 쓰이는 커널함수는 RBF이다.
|
13,971 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.stats import uniform
f = lambda x: np.log(x)
x = np.linspace(0.1, 5.1, 100)
y = f(x)
Eps = uniform.rvs(-1., 2., size=(100,))
plt.plot(x, y, label='$f(x)$', lw=3)
plt.scatter(x, y + Eps, label='y')
plt.xlabel('x')
plt.legend(loc='best')
plt.show()
models = ['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Goal
Step2: How do we estimate $\hat{f}$?
Step3: Can fit this perfectly with a cubic model. But assuming that this is correct.
Step4: In the ... |
13,972 | <ASSISTANT_TASK:>
Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
view_sentence_range = (0, 10)
DON'T MODIFY ANYTHING IN THIS CELL
import num... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TV Script Generation
Step3: Explore the Data
Step6: Implement Preprocessing Functions
Step9: Tokenize Punctuation
Step11: Preprocess all the... |
13,973 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import numpy
import matplotlib.pyplot as plt
from jyquickhelper import RenderJsDot
def plot_network(mat):
# Dessine un graph à l'aide du language DOT
# https://graphviz.org/doc/info/lang.html
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: Enoncé
Step2: Le graphe se lit comme suit
Step3: On vérifie sur un graphe plus compliqué.
Step4: Q2
|
13,974 | <ASSISTANT_TASK:>
Python Code:
import pandas
import numpy
import csv
#from scipy.stats import mode
from sklearn import neighbors
from sklearn.neighbors import DistanceMetric
from pprint import pprint
MY_TITANIC_TRAIN = 'train.csv'
MY_TITANIC_TEST = 'test.csv'
titanic_dataframe = pandas.read_csv(MY_TITANIC_TRAIN, heade... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Remove Columns
Step2: Which are the factors?
Step3: Pre-Processing
|
13,975 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
import warnings
warnings.filterwarnings("ignore", category=matplotlib.cbook.MatplotlibDeprecationWarning)
%matplotlib inline
# The S3 URL did not work for me, despite .edu domain
#url = 'http://thredds-aws.unidata.ucar.edu/thredds/radarServer/nexrad/level2/S3/'
#Trying ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First we'll create an instance of RadarServer to point to the appropriate radar server access URL.
Step2: Next, we'll create a new query object... |
13,976 | <ASSISTANT_TASK:>
Python Code:
from ipyleaflet import Map, basemaps, basemap_to_tiles
center = (52.204793, 360.121558)
m = Map(
layers=(basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2018-11-12"), ),
center=center,
zoom=4
)
m
from ipyleaflet import Marker, Icon
icon = Icon(icon_url='https://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: Layers
Step2: <center><img src="src/jupyterlab-sidecar.svg" width="50%"></center>
Step3: Heatmap layer
Step4: Velocity
Step5: Controls
Step6... |
13,977 | <ASSISTANT_TASK:>
Python Code:
from four_way_interactions import four_way_from_ranking
from total_n_way_interaction import total_n_way_interaction
interaction = four_way_from_ranking([0, 1, 10, 11, 110, 111, 1000, 1001,
1010, 1011, 1100, 1101, 1110, 1111, 100, 101], 110)
print("[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: Four-way interaction coordinates
Step2: The latter 110 in the four_way_from_ranking call corresponds to u.
Step3: The output is a pair of trut... |
13,978 | <ASSISTANT_TASK:>
Python Code:
import re
import pytz
import gdelt
import datetime
import numpy as np
import pandas as pd
import seaborn as sns
import geoplot as gplt
from tzwhere import tzwhere
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
tz1 = tzwhere.tzwhere(forceTZ=True)
gd = gdelt.gdelt()
%time 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: Setting up gdeltPyR
Step3: Time format transformations
Step4: Now we apply the functions to create a datetime object column (dates) and a time... |
13,979 | <ASSISTANT_TASK:>
Python Code:
import os
import pickle
import sys
import nltk
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
import tensorflow as tf
from tensorflow.keras.layers import (
Dense,
Embedding,
GRU,
Input,
)
from tensorflow.keras.models 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: Downloading the Data
Step2: From the utils_preproc package we have written for you,
Step3: Sentence Integerizing
Step4: The outputted tokeniz... |
13,980 | <ASSISTANT_TASK:>
Python Code:
# imports
from astropy import units as u
from astropy.coordinates import SkyCoord
import specdb
from specdb.specdb import SpecDB
from specdb import specdb as spdb_spdb
from specdb.cat_utils import flags_to_groups
db_file = specdb.__path__[0]+'/tests/files/IGMspec_DB_v02_debug.hdf5'
reloa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Setup
Step2: Check one of the meta tables
Step3: Query meta with Query dict
Step4: Another example
Step5: One more
Step6: Query meta at pos... |
13,981 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function # only necessary if using Python 2.x
import matplotlib.pyplot as plt
import numpy as np
from pyshtools.shclasses import SHCoeffs, SHWindow, SHGrid
nl = 100 # l = [0, 199]
lmax = nl - 1
a = 4 # scale length
ls = np.arange(nl, dtype... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, we generate random coefficients from this input power spectrum, plot the power spectrum of the random realization, and expand the coeffifi... |
13,982 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# Random time series.
n = 1000
rs = np.random.RandomState(42)
data = rs.randn(n, 4).cumsum(axis=0)
plt.figure(figsize=(15,5))
plt.plot(data[:, :])
# df = pd.DataFrame(...)
# df.plot(...)
data = [10,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2 Categories
Step2: 3 Frequency
Step3: 4 Correlation
Step4: 5 Dimensionality reduction
|
13,983 | <ASSISTANT_TASK:>
Python Code:
# define your first ever function
def my_pet(your_favourite_animal):
print(your_favourite_animal + " is the best!")
print("Congratulations, you have used your first ever python function!")
# Hint = if you are getting this error:
# TypeError: function_name() missing 1 required... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Put the name of an animal into the brackets. Hint
Step2: Note
Step3: Another example
Step4: Now we have a function named fibonacci which take... |
13,984 | <ASSISTANT_TASK:>
Python Code:
import rebound
rebound.add("Sun")
rebound.add("Jupiter")
rebound.add("Saturn")
for orbit in rebound.calculate_orbits():
print(orbit)
rebound.add("Churyumov-Gerasimenko")
rebound.dt = -0.01
import numpy as np
Noutputs = 1000
year = 2.*np.pi # One year in units where G=1
times = np.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Now all the data is in REBOUND! Let's have a look at the orbits of the two planets.
Step2: Although there are three bodies, the get_orbits() fu... |
13,985 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image(filename='images/mgxs.png', width=350)
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import openmc
import openmc.mgxs as mgxs
# Instantiate a Material and register the Nuclides
inf_medium = openmc.Material(name='moderator')... | <SYSTEM_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 variety of tools employing different methodologies have been developed over the years to compute multi-group cross sections for certain applic... |
13,986 | <ASSISTANT_TASK:>
Python Code:
!pip install -q -U tensorflow==2.1
!pip install -U -q google-api-python-client
!pip install -U -q pandas
# Automatically restart kernel after installs
import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
PROJECT_ID = "[your-project-Id]" #@param {type:"string... | <SYSTEM_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 up your GCP project and GCS bucket
Step2: Authenticate your GCP account
Step3: Import libraries
Step4: Define constants
Step5: Create a ... |
13,987 | <ASSISTANT_TASK:>
Python Code:
# Librerias utilizadas
import pandas as pd
import sys
module_path = r'D:\PCCS\01_Dmine\Scripts'
if module_path not in sys.path:
sys.path.append(module_path)
from SUN.asignar_sun import asignar_sun
from SUN_integridad.SUN_integridad import SUN_integridad
from SUN.CargaSunPrincipal 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: 1. Revisión y estandarización inicial al DataSet Pigoo
Step2: Gracias a que este dataset ya contiene etiquetas con claves geoestadísticas, es p... |
13,988 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import scipy.stats as sp
# %matplotlib notebook
%matplotlib inline
import seaborn as sns; sns; sns.set_style('dark')
import statsmodels.api as sm
import matplotlib.pyplot as plt
df = pd.read_csv('turnstile_data_master_with_weather.csv')
df.index = pd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: References
Step2: In this data, we can see summary statistic of number of ridership hourly, represented by ENTRIESn_hourly variable between ra... |
13,989 | <ASSISTANT_TASK:>
Python Code:
# For use in Quantopian Research, exploring interactively
from quantopian.interactive.data.quandl import cboe_vxxle as dataset
# import data operations
from odo import odo
# import other libraries we will use
import pandas as pd
# Let's use blaze to understand the data a bit using Blaze d... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's go over the columns
Step2: <a id='pipeline'></a>
Step3: Now that we've imported the data, let's take a look at which fields are availabl... |
13,990 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
iris = load_iris()
print(iris.data.shape)
measurements = [
{'city': 'Dubai', 'temperature': 33.},
{'city': 'London', 'temperature': 12.},
{'city': 'San Francisco', 'temperature': 18.}
]
from sklearn.feature_extraction import DictVectoriz... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Las características son
Step2: Características derivadas
Step3: Aquí tenemos una descripción de lo que significan cada una de las variables
St... |
13,991 | <ASSISTANT_TASK:>
Python Code:
from Registry import Registry
from Registry.RegistryParse import ParseException
path_to_reg_hive = '../data/system' # The included SYSTEM hive file
hive = Registry.Registry(path_to_reg_hive)
print(type(hive))
print("Hive Name: ", hive.hive_name())
print("Hive Type: ", hive.hive_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: Root Object
Step2: Key Objects
Step3: Value Objects
Step4: The System Hive Sandbox
|
13,992 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import missingno as msno
from matplotlib import pyplot as plt
stats2015 = pd.read_csv("the-counted-revised-2015.csv")
stats2016 = pd.read_csv("the-counted-revised-2016.csv")
msno.bar(stats2015)
msno.bar(stats2016)
stats2015.head()
stats2016.head()
#Dropping the extra... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Missing Data
Step2: 'streetaddress' seems to be the only column that is missing data. That is good news as we can count any of the other column... |
13,993 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import numpy as np
from scipy import stats
import statsmodels.api as sm
from statsmodels.base.model import GenericLikelihoodModel
data = sm.datasets.spector.load_pandas()
exog = data.exog
endog = data.endog
print(sm.datasets.spector.NOTE)
print(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: The Spector dataset is distributed with statsmodels. You can access a vector of values for the dependent variable (endog) and a matrix of regres... |
13,994 | <ASSISTANT_TASK:>
Python Code:
from reprophylo import *
coi = Locus(char_type='dna',
feature_type='CDS',
name='MT-CO1',
aliases=['cox1', 'coi'])
print coi
list_loci_in_genbank('data/Tetillidae.gb', # The input genbank
# file
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Once this is done we can start a Project. A Project contains all the data, metadata, methods and environment information, and it is the unit tha... |
13,995 | <ASSISTANT_TASK:>
Python Code:
import random
import numpy as np
from matplotlib.colors import hsv_to_rgb
from PIL import Image as PILImage, ImageDraw as PILImageDraw
%load_ext watermark
%watermark
%watermark -a "Lilian Besson (Naereen)" -p numpy,matplotlib,PIL
def identicon(hashval=None,
size=256,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: First try
Step2: Second try
Step3: Tests
Step4: And every parameter can be changed and tuned.
Step5: List of vignettes
|
13,996 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
# Load Part-of-Speech data
from lxmls.readers.pos_corpus import PostagCorpusData
data = PostagCorpusData()
from lxmls.deep_learning.numpy_models.rnn import NumpyRNN
numpy_model = NumpyRNN(
input_size=data.input_size,
embedding_size=50,
hidd... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Check Numpy and Pytorch Gradients match
Step2: To debug your code you can compare the numpy and Pytorch gradients using
Step3: and then plotti... |
13,997 | <ASSISTANT_TASK:>
Python Code:
!pip install graphspace_python==0.8.3
print("Hello World")
l = []
# l = list()
l = ['apple', 'orange', 123]
print(l)
print(l[0], l[1])
tup = ()
#tup = tuple()
tup3 = tuple([1,2,3])
print(tup3)
tup4 = tuple('Hello')
print(tup4)
data = {}
# data = dict()
data['firstname'] = 'Aditya'
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Part 2
Step2: Lists
Step3: In python, Indexing starts from 0. Thus now the list l, which has three elements will have apple at 0 index, orange... |
13,998 | <ASSISTANT_TASK:>
Python Code:
import os,sys
import numpy
%matplotlib inline
import matplotlib.pyplot as plt
sys.path.insert(0,'../')
from utils.mkdesign import create_design_singlecondition
from nipy.modalities.fmri.hemodynamic_models import spm_hrf,compute_regressor
from utils.make_data import make_continuous_data
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: Load the data generated using the DCM forward model. In this model, there is a significant static connectivity from 1->2 and 1->3 (A matrix), an... |
13,999 | <ASSISTANT_TASK:>
Python Code:
# Load library
import numpy as np
# Create matrix
matrix_a = np.array([[1, 1, 1],
[1, 1, 1],
[1, 1, 2]])
# Create matrix
matrix_b = np.array([[1, 3, 1],
[1, 3, 1],
[1, 3, 8]])
# Add two matrices
np.add(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: Create Matrices
Step2: Add Matrices
Step3: Subtract Matrices
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.