Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
8,700 | <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
from IPython.display import Image
from IPython.core.display import clear_output, display
from scipy.signal import convolve2d
from copy 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: Import section specific modules
Step2: 6.2 Interative Deconvolution with Point Sources (CLEAN)<a id='deconv
Step3: Left
Step4: Left
Step5: L... |
8,701 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import time
import helper
source_path = 'data/letters_source.txt'
target_path = 'data/letters_target.txt'
source_sentences = helper.load_data(source_path)
target_sentences = helper.load_data(target_path)
source_sentences[:50].split('\n')
target_sentences[:50].split('\... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's start by examining the current state of the dataset. source_sentences contains the entire input sequence file as text delimited by newline... |
8,702 | <ASSISTANT_TASK:>
Python Code:
# change these to try this notebook out
BUCKET = 'cloud-training-demos-ml'
PROJECT = 'cloud-training-demos'
REGION = 'us-central1'
import os
os.environ['BUCKET'] = BUCKET
os.environ['PROJECT'] = PROJECT
os.environ['REGION'] = REGION
%%bash
if ! gsutil ls | grep -q gs://${BUCKET}/; then
... | <SYSTEM_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 Keras model
Step2: Next, define the feature columns. mother_age and gestation_weeks should be numeric.
Step3: We can visualize the DNN ... |
8,703 | <ASSISTANT_TASK:>
Python Code:
! #complete
! #complete
%%sh
#complete
! #complete
%cd -0 #complete
!mkdir #complete only if you didn't do 0c, or want a different name for your code directory
%%file <yourdirectory>/code.py
def do_something():
# complete
print(something)# this will make it much easier in fut... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 0b
Step2: 0c
Step3: 0d
Step4: Final note
Step5: If you want to test-run your code
Step6: 1b
Step7: 1c
Step8: The -u is a convenience that... |
8,704 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib.pyplot import plot
from matplotlib.pyplot import show
# 首先读入两只股票的收盘价,并计算收益率
bhp_cp = np.loadtxt('BHP.csv', delimiter=',', usecols=(6,), unpack=True)
vale_cp = np.loadtxt('VALE.csv', delimiter=',', usecols=(6,), unpack=True)
bhp_return... | <SYSTEM_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: 协方差描述的是两个变量共同变化的趋势,其实就是归一化前的相关系数。
Step3: 用相关系数来度量两只股票的相关程度。相关系数的取值范围在-1到1之间,一组数据域自身的相关系数为1.使用corrcoef函数计算相关系数。
Step4: 相关系数矩... |
8,705 | <ASSISTANT_TASK:>
Python Code:
print ("hello world!")
port = 22
message = "SSH Server v2"
print ("Search for {} in port {}".format(message,port))
message = "SSH Server v2"
type(message)
port = 22
type(port)
portlist = [22,21,80,5000]
type(portlist)
portOpen = True
type(portOpen)
message= "SSH Server v2"
print (messa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Variáveis
Step2: Em Python, o tipo da variável não precisa ser declarado explicitamente, o interpretador verifica qual o tipo de variável e o v... |
8,706 | <ASSISTANT_TASK:>
Python Code:
!gsutil cp -r $MODEL_PATH/* gs://$BUCKET/taxifare/model/
%%writefile predictor.py
import tensorflow as tf
from google.cloud import bigquery
PROJECT_ID = 'will_be_replaced'
class TaxifarePredictor(object):
def __init__(self, predict_fn):
self.predict_fn = predict_fn
... | <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: 2. Implement Predictor Interface
Step3: Test Predictor Class Works Locally
Step4: 3. Package Predictor Class and Dependencies
Step5: 4. Deplo... |
8,707 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style='white', font_scale=1.1, palette='Set2')
from desitarget.mock.mockmaker import QSOMaker, LYAMaker, LRGMaker, ELGMaker
for Maker in (QSOMaker, LYAMaker, LRGMaker, ELGMaker):
M = Maker()
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dark-time targets
Step2: Bright-time extragalactic targets
Step3: Bright-time stellar targets
Step4: Sky targets
|
8,708 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccma', 'canesm5', 'aerosol')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,709 | <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!"
# TODO: Calculate number of students - DONE
n_students = student... | <SYSTEM_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... |
8,710 | <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.
e=ener... | <SYSTEM_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(\... |
8,711 | <ASSISTANT_TASK:>
Python Code:
# sphinx_gallery_thumbnail_number = 9
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import find_events, fit_dipole
from mne.datasets.brainstorm import bst_phantom_ele... | <SYSTEM_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 data were collected with an Elekta Neuromag VectorView system at 1000 Hz
Step2: Data channel array consisted of 204 MEG planor gradiometers... |
8,712 | <ASSISTANT_TASK:>
Python Code:
import sys
from gastrodon import *
from rdflib import *
import pandas as pd
pd.options.display.width=120
pd.options.display.max_colwidth=100
boros=inline(r
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://example.com/> .
:New_York_City
:boro :Manhattan,:Q... | <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: Representing Sets
Step3: Note that the comma is a shorthand notation that lets me write a number of statements that share the same predicate an... |
8,713 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# Required imports
from wikitools import wiki
from wikitools import category
import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
import gensim
import numpy as np
import lda
import lda.datasets
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: 1. Corpus acquisition.
Step2: You can try with any other categories. Take into account that the behavior of topic modelling algorithms may depe... |
8,714 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccma', 'sandbox-1', 'atmos')
# 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... |
8,715 | <ASSISTANT_TASK:>
Python Code:
cat ./poi_names.txt
enron_data = pickle.load(open("./final_project_dataset.pkl"))
enron_data.iteritems().next()
# Replace "Nan" with NaN
for columns in enron_data.itervalues():
for k,v in columns.iteritems():
if type(v) is str and v.lower() == "nan":
columns[k] =... | <SYSTEM_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 file contains a list of 35 people who were a person of interest in the Enron scandal. A POI is defined as someone who was
Step2: Features ... |
8,716 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-1', 'land')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "email... | <SYSTEM_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... |
8,717 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from preamble import *
plt.rcParams['savefig.dpi'] = 100 # This controls the size of your figures
# Comment out and restart notebook if you only want the last output of each cell.
InteractiveShell.ast_node_interactivity = "all"
# This is a temporary read-only OpenML ke... | <SYSTEM_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 selection (4 points (1+2+1))
Step2: Robots and SVMs (4 points (2+1+1))
Step3: A benchmark study (3 points (2+1))
|
8,718 | <ASSISTANT_TASK:>
Python Code:
import auto_martini as am
import numpy as np
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import Image
import rdkit
from rdkit.Chem import Draw
from rdkit.Chem import AllChem
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parametrization (recap of Tutorial 1)
Step2: Highlighting atoms and CG beads
Step3: We'll want to color atoms according to beads, so let's def... |
8,719 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import glob
import skbio
import re
mer = 6
path_glob = '/Users/luke/singlecell/jellyfish/*_%smer.fa' % mer
df = pd.DataFrame(index=[x.split('/')[-1] for x in glob.glob(path_glob)])
for path in glob.glob(path_glob):
fasta = skbio.io.read(path, format='fasta')
f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Dataframe of merged jellyfish results
Step2: Genome metadata (want to know if it's Prochlorococcus or Pelagibacter)
Step3: Write combined and ... |
8,720 | <ASSISTANT_TASK:>
Python Code:
# I sometimes need to choose PyTorch...
import inspect
import sys
#sys.path.insert(0, '/home/tv/pytorch/pytorch/build/lib.linux-x86_64-3.8//')
import torch
import torch.utils.dlpack
# import TVM
import sys
import os
tvm_root = '/home/tv/rocm/tvm/tvm/'
tvm_paths = [os.path.join(tvm_root, 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: Helpfully, transformers supports tracing their model with the PyTorch JIT. We use their tutorial on it, the following is copied straight from th... |
8,721 | <ASSISTANT_TASK:>
Python Code:
data = list(csv.DictReader(open('data/columbia_crime.csv', 'r').readlines()))
# This part just splits out the latitude and longitude coordinate fields for each incident, which we need for mapping.
coords = [(float(d['lat']), float(d['lng'])) for d in data if len(d['lat']) > 0]
print coord... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: K-means clustering
Step2: The data comes out in the format of cluster_id,incident_type,lat,lng. If we save it to a csv file, we can load it int... |
8,722 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from numpy import *
Eq = np.array([[1, 1, -1, 9],[0, 1, 3, 3],[-1, 0, -2, 2]])
A = Eq[:,0:3] # As
b = Eq[:,3] # Resultados 9, 3, 2
# Las soluciones son: [0.666666666666667, 7.0, -1.3333333333333333]
U,s,V = linalg.svd(A) # descomposición SVD de A
# inversa usando pinv
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Resolviendo caso A=[[1,1],[0,0]]
Step2: El experimento anerior nos da error por ser una matriz singular, ahora intentamos con A=[[1,1],[0,1e-32... |
8,723 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
plt.xticks?
def plot_sin1(a,b):
x=np.linspace(0,4*np.pi,300)
plt.figure(figsize=(12,5))
plt.plot(x,np.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: Plotting with parameters
Step2: Then use interact to create a user interface for exploring your function
Step3: In matplotlib, the line style ... |
8,724 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def readucr(filename):
data = np.loadtxt(filename, delimiter="\t")
y = data[:, 0]
x = data[:, 1:]
return x, y.astype(int)
root_url = "https://raw.githubusercontent.com/hfawaz/cd-diagram/master/FordA/"
x_train, y_train = readucr(root_url + "FordA_TRAIN.ts... | <SYSTEM_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 the model
Step2: We include residual connections, layer normalization, and dropout.
Step3: The main part of our model is now complete. W... |
8,725 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import io
# downloading R may takes a few minutes (80Mo)
try:
import urllib.request as urllib2 # Python 3
except:
import urllib2 # Python 2
# specify R binary and (md5, sha1) hash
# R-3.4.3:
r_url = "https://cran.r-project.org/bin/windows/base/R-3.4.3-win.ex... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2 - checking and Installing R binary in the right place
Step4: During Installation (if you wan't to move the R installation after)
Step5: 4- I... |
8,726 | <ASSISTANT_TASK:>
Python Code:
n = int(input())
for i in range(1,n + 1, 3):
print(i)
n = int(input())
for i in range(n, 0, -1):
print(i)
n = int(input())
for i in range(0, n + 1, 1):
print(pow(2,i))
n = int(input())
for i in range(0, n + 1, 1):
if i % 2 == 0:
print(pow(2,i))
n = int(input())... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h2>02. Numbers N...1</h2>
Step2: <h2>03. Powers of Two</h2>
Step3: <h2>04. Even Powers of 2</h2>
Step4: <h2>05. Sequence 2k+1</h2>
Step5: <... |
8,727 | <ASSISTANT_TASK:>
Python Code:
import networkx as nx
g = nx.Graph()
g.add_node(1)
g.add_node(2)
g.add_node(3)
g.add_node(4)
#oder schneller
g.add_nodes_from([1,2,3,4])
#Hinzufügen von Kanten
g.add_edge(1,2)
g.add_edge(1,3)
g.add_edge(1,4)
#oder schneller
g.add_edges_from([(1,2),(1,3),(1,4)])
nr_nodes = len(g.nodes())
... | <SYSTEM_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 können uns die Informationen über einen Graphen schnell ausgeben lassen
Step2: Oft ist es noch besser, den Graphen zu visualisieren
Step3: ... |
8,728 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import bruges as bg
w, top, base, ref = bg.models.wedge()
plt.imshow(w, interpolation='none')
plt.axvline(ref, color='k', ls='--')
plt.plot(top, 'r-', lw=4)
plt.plot(base, 'r-', lw=4)
plt.show()
import numpy as np
vps = np.array([2320, 2350, 2350])
rhos = ... | <SYSTEM_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 then use this integer model to index into an array of rock properties
Step2: We can use these to make vp and rho earth models. We can u... |
8,729 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
import sqlite3
import random
import time
import datetime
# Criando uma conexão
conn = sqlite3.connect('dsa.db')
# Criando um cursor
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: Inserindo Dados com Variáveis
|
8,730 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
pd.set_option('display.max_colwidth', -1)
df = pd.read_csv('../../data/processed/complaints-3-29-scrape.csv')
df.count()[0]
df[df['... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h3>How many total complaints are there?</h3>
Step2: <h3>How many complaints do not appear in the state's public database?</h3>
Step3: <h3>How... |
8,731 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%reload_ext XTIPython
vImaris.GetVersion()
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
%imaris_screenshot
nx = vDataSet.GetSizeX()
ny = vDataSet.GetSizeY()
nz = vDataSet.GetSizeZ()
dtype = BridgeLib.GetType(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: For info, this is what the dataset looks like (fly embryo).
Step2: 8 bit transfer
Step3: Let's fetch the data volume and check how long it tak... |
8,732 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# Ivezic, Figure 8.1
# Author: Jake VanderPlas
# License: BSD
# The figure produced by this code is published in the textbook
# "Statistics, Data Mining, and Machine Learning in Astronomy" (2013)
# For more information, see http://astroML.github.com
# To report ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Bayesian Regression
Step2: Print $C$, $M$, $A$, $B$, and $\theta$ and make sure that you understand how these are constructed.
Step3: Polynomi... |
8,733 | <ASSISTANT_TASK:>
Python Code:
import SimpleITK as sitk
import numpy as np
# If the environment variable SIMPLE_ITK_MEMORY_CONSTRAINED_ENVIRONMENT is set, this will override the ReadImage
# function so that it also resamples the image to a smaller size (testing environment is memory constrained).
%run setup_for_testing... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Utilities
Step2: Loading Data
Step3: Demons Registration
Step4: Running the Demons registration with the conjugate gradient optimizer on this... |
8,734 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from autoc import DataExploration, PreProcessor, NaImputer
from autoc.utils.getdata import get_dataset
import numpy as np
# skicit learn
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import cross_val_score,train_test_split
from skle... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Playing with titanic data
Step2: Preprocessing data
Step3: Transform everything to numeric variables for skicit learn model
Step4: Simple Mod... |
8,735 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-3', 'ocnbgchem')
# 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... |
8,736 | <ASSISTANT_TASK:>
Python Code:
import NotebookImport
from Imports import path
import numpy as np
import pandas as pd
def tranfer_fx(x, adult_age=20):
x = np.float(x)
x=(x+1)/(1+adult_age)
y = np.log(x) if x <= 1 else x - 1
return y
def anti_tranfer_fx(x, adult_age=20):
if x < 0:
return... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Horvath's Transfer Functions
Step2: Horvath Model
Step3: Hannum Model
|
8,737 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
from __future__ import print_function
import sys
import numpy as N
import libstempo as T
import libstempo.plot as LP, libstempo.toasim as LT
T.data = T.__path__[0] + '/data/' # example files
print("Python version :",sys.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: We open up a NANOGrav par/tim file combination with libstempo, and plot the residuals.
Step2: We now remove the computed residuals from the TOA... |
8,738 | <ASSISTANT_TASK:>
Python Code:
import os
os.chdir("../eppy/useful_scripts")
# changes directory, so we are where the scripts are located
# you would normaly install eppy by doing
# python setup.py install
# or
# pip install eppy
# or
# easy_install eppy
# if you have not done so, the following three lines are needed
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: If you look in the folder "./eppy/useful_scripts", you fill find the following scripts
Step2: That was useful !
Step3: Redirecting output to a... |
8,739 | <ASSISTANT_TASK:>
Python Code:
import graphlab
image_train_url = 'https://d396qusza40orc.cloudfront.net/phoenixassets/image_train_data.csv'
image_test_url = 'https://d396qusza40orc.cloudfront.net/phoenixassets/image_test_data.csv'
image_train_data = graphlab.SFrame(image_train_url)
image_train_data.head()
image_test_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: Load CIFAR-10 dataset
Step2: Train classifier using raw image pixels, no deep features yet
Step3: Predict five images with this raw pixel mode... |
8,740 | <ASSISTANT_TASK:>
Python Code:
import pynams
from pynams import fO2
fO2 = fO2(celsius=1000, buffer_curve='NNO')
print(fO2)
from pynams import V_from_log10fO2
V_from_log10fO2(celsius=1000, log10fO2=fO2)
from pynams import log10fO2_from_V
logfO2 = log10fO2_from_V(celsius=1000, volts=-0.8)
<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: What is the log base 10 of the fO2 in bars for a given temperature and buffer?
Step2: What does that fO2 correspond to in mV reported by an O2 ... |
8,741 | <ASSISTANT_TASK:>
Python Code:
# Load Biospytial modules and etc.
%matplotlib inline
import sys
sys.path.append('/apps')
sys.path.append('..')
#sys.path.append('../../spystats')
import django
django.setup()
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
## Use the ggplot style
plt.style.use('ggp... | <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: Algorithm to simulate GMRF with block-circulant Matrix.
Step3: For benchmarking we will perfom a GF simulation.
Step4: comparison
|
8,742 | <ASSISTANT_TASK:>
Python Code:
import sys, os
from adaptivemd import Project
# Use this to completely remove the example-worker project from the database.
Project.delete('tutorial-multi')
project = Project('tutorial-multi')
from adaptivemd import LocalCluster, AllegroCluster
resource = LocalCluster()
project.initia... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Alright, let's load the package and pick the Project since we want to start a project
Step2: Let's open a project with a UNIQUE name. This will... |
8,743 | <ASSISTANT_TASK:>
Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
# Retrieve the training and test data
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
# Visualizing the data
import matplotli... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Retrieving training and test data
Step2: Visualize the training data
Step3: Building the network
Step4: Training the network
Step5: Testing
|
8,744 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import numpy as np
from numpy import pi, sqrt,cos
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 25, 'legend.handlelength' : 1.25})
%matplotlib inline
import seaborn as sns
#sns.set(style="darkgrid")
sns.set_context("paper", font_scale=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: A function to compute difference matrices
Step2: Load data
Step3: set up domain
Step4: compute wavestructure
|
8,745 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
print(matplotlib.__version__)
print(matplotlib.get_backend())
matplotlib.use('nbagg')
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
plt.show()
# Twice as tall as it is wide:
fig = plt.figure(figsize=plt.figaspect(2.0))
plt.show()
fig = plt.f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Normally we wouldn't need to think about this too much, but IPython/Jupyter notebooks behave a touch differently than "normal" python.
Step2: O... |
8,746 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import utilsNetwork
networkShp = '/home/openquake/GEM/Lifelines/Building_NetworkNew/Input_files/EntireNetwork/mo_FINAL.shp'
(shpAdj,maxNumConn) = utilsNetwork.shp_adj(networkShp)
resultsFolder = '/media/sf_Shared_Folder/Paper_Scenarios/2016-09-Revision/'
maxDist = 2... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Specify the location of the vector GIS file containing the network
Step2: Specify the location of the folder where the results will be saved
St... |
8,747 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from numpy import fft
from numpy import linalg as LA
from scipy import ndimage
from scipy import signal
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import os
%matplotlib inline
def int2intvec(a):
Auxiliary function to recover a vector with the 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:
Step7: Auxiliary functions
Step8: Spiral architecture implementation
Step9: We now compute, in sa2hex, the address of the center of the hyperpel corr... |
8,748 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
# Check that GPU is available: cf. https://colab.research.google.com/notebooks/gpu.ipynb
assert(tf.test.gpu_device_name())
tf.keras.backend.clear_session()
tf.config.optimizer.set_jit(False) # Start with XLA disabled.
def load_data():
(x_train, y_train), (x_test,... | <SYSTEM_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 define the model, adapted from the Keras CIFAR-10 example
Step2: We train the model using the
Step3: Now let's train the model again, using... |
8,749 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
def compute_mean(list_of_numbers):
return float(sum(list_of_numbers))/len(list_of_numbers)
def count_elements_greater_than(list_of_numbers, threshold):
bool_list = [number >= threshold for number in list_of_numbers]
return bool_list.count(True)
input_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: 2) Definizione della funzione compute_mean()
Step2: 3) Definizione della funzione count_elements_greater_than()
Step3: 4) Definizione dei para... |
8,750 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
import pandas as pd
import os
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from time import time
from mclearn.experiment import ActiveExperiment, load_results, save_results
from mclearn.tools import log
from sklearn.externals ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Experiment
Step2: No passive arm
Step3: Results
|
8,751 | <ASSISTANT_TASK:>
Python Code:
plt.plot(ST.index[1:], np.log10(ST.values)[1:])
#plt.plot(f[1:N_final], 20.0 / len(T) * np.log10(np.abs(ST[1:N_final])))
plt.xlabel('frequency in days')
plt.ylabel('Power')
plt.title('T spectra')
rx = (1. / N) * correlate(T, T, mode = 'same')
plt.plot(fftshift(rx)[0:N//2])
# THIS METHOD 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: Repeating the process is not useful
|
8,752 | <ASSISTANT_TASK:>
Python Code:
# Importa as bibliotecas
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Carrega os dados
cols = ['buying','maint','doors','persons','lug_book','safety','class']
carset = pd.read_csv('carData.csv',names=cols)
carset.head()
carset.info()
# Implementa o classifica... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sem valores faltantes. Amém!
Step2: Questão 2
Step3: Questão 3
|
8,753 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import string
from collections import defaultdict
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
matplotlib.style.use('ggplot')
df = pd.read_csv('data/train_data2.csv', encoding='latin-1')
print(len(df))
df.head()
df['Released... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Read in TRAIN data set and select pertinent columns
Step2: Convert dates to datetime objects
Step3: Inspect years
Step4: df => df_yr
Step5: ... |
8,754 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import Image
Image(filename='images/bn.png')
#%matplotlib notebook
%matplotlib inline
from matplotlib.widgets import Button
import matplotlib.pyplot as plt
import numpy as np
import math
fig = plt.figure(figsize=(9, 3))
ax1 = fig.add_subplot(1,2,1)
ax1.set_titl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: rewrite it by adding inputs from previous layer
Step2: Motivation
Step3: Data whitening means that you need to transform each dimension of dat... |
8,755 | <ASSISTANT_TASK:>
Python Code:
list1 = [["a", "b", "c"], [1, 2, 3]]
# print tuple(["a", "b", "c"])
# print tuple([1, 2, 3])
map(tuple, list1)
for item in list1:
tuple(item)
table1 = [["a", "b", "c"], [1, 2, 3]]
table2 = [["a", "b", "c"], [1, 2, 3]]
table3 = [["a", "b", "c"], [1, 2, 4]]
table4 = [[1, 2, 3], ["a", "b... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sets
Step2: Problem
Step3: Designing a Program to Use Functions
Steps in Top-Down Design
Step4: Example
Step5: File Input and Output
Step6: ... |
8,756 | <ASSISTANT_TASK:>
Python Code:
# Sign up for a free account at Genius.com to access the API
# http://genius.com/api-clients
client_access_token = 'CLIENT_ACCESS_TOKEN'
# Let's take a look at how we might search for an artist using the Genius API.
import requests
import urllib2
# Format a request URL for the Genius API
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <img src="https
Step2: Scrape song lyrics
Step3: Python wrapper
|
8,757 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.filter(qualifier='l3_mode')
b.add_dataset('lc', times=np.linspace(0,1,101), dataset='lc01')
print(b.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As always, let's do imports and initialize a logger and a new bundle.
Step2: Relevant Parameters
Step3: So let's add a LC dataset
Step4: We n... |
8,758 | <ASSISTANT_TASK:>
Python Code:
# nametuple 举例
from collections import namedtuple
point = namedtuple('Point', ['x', 'y'])
p = Point(1, 2)
print(p.x, p.y)
print(type(p))
i = p.x + p.y
print(i)
# nametuple 举例
from collections import namedtuple
Web = namedtuple('web', ['name', 'type', 'url'])
p1 = Web('google', 'search',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: deque
Step2: defaultdict
Step3: OrderedDict
Step4: Counter
Step5: 思考一下
|
8,759 | <ASSISTANT_TASK:>
Python Code:
import sys
print(sys.version)
import numpy as np # Import library and give it alias np
print(np.__version__) # The version I'm using
a = np.zeros(3) # Create an array of zeros
a # Print a
type(a)
a = np.zeros(3)
type(a[1])
z = np.zeros(10)
z.shape
z.shap... | <SYSTEM_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 NumPy
Step2: NumPy defines a basic data type called an array (actually a numpy.ndarray)
Step3: Note that array data must be homogeneous
... |
8,760 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
np.random.seed(42)
np.random.seed(4)
m = 60
w1, w2 = 0.1, 0.3
noise = 0.1
angles = np.random.rand(m) * 3 * np.pi / 2 - 0.5
X = np.empty((m, 3))
X[:, 0] = np.cos(angles) + np.sin(angles)/2 + noise * np.random.randn(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: Generate the dataset
Step2: Plot the dataset
Step3: Factorise the matrix using the Singular Value Decomposition (SVD)
Step4: The columns of $... |
8,761 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from geopy.distance import great_circle
from collections import deque
cols = ["Airport ID", "Name", "City", "Country", "IATA", "ICAO", "Latitude", "Longitude", "Altitude",
"Timezone", "DST",... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Date to make a graph with
Step2: Step one is is to get rid of all the info we don't need for our graph.
Step3: Edges, aka routes flown
Step4: ... |
8,762 | <ASSISTANT_TASK:>
Python Code:
# As usual, a bit of setup
import numpy as np
import matplotlib.pyplot as plt
from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient
from cs231n.layers import *
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Modular neural nets
Step2: Affine layer
Step3: Affine layer
Step4: ReLU layer
Step5: ReLU layer
Step6: Loss layers
|
8,763 | <ASSISTANT_TASK:>
Python Code:
# reshape is needed so we can use plt.imshow
rgb_to_gray = tf.reshape(tf.image.rgb_to_grayscale(ob), [ob.shape[0], ob.shape[1]])
gray_ob = rgb_to_gray.eval()
gray_ob.shape, gray_ob.dtype
plt.gray()
plt.imshow(gray_ob)
# let's get the current ratio
from __future__ import division
ratio = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Resizing Images
Step2: Scaling Pixel Values
Step3: Putting it Together - Making a Image Preprocessing Pipeline
|
8,764 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
Image('../../../python_for_probability_statistics_and_machine_learning.jpg')
%matplotlib inline
from matplotlib.pylab import subplots
from numpy import ma
import numpy as np
np.random.seed(12345678)
from sklearn import tree
clf = tree.DecisionTreeClassi... | <SYSTEM_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 decision tree is the easiest classifer to understand, interpret, and explain.
Step2: Let's also create some example data,
Step3: Programming... |
8,765 | <ASSISTANT_TASK:>
Python Code:
%time d_pagerank = G.pagerank()
%time u_pagerank = G.as_undirected().pagerank()
%time d_betweenness = G.betweenness(directed=True)
%time u_betweenness = G.as_undirected().betweenness(directed=False)
%time d_closeness = G.closeness(mode="IN", normalized=True)
%time u_closeness = G.as_undi... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: issue area
Step2: compare metric vs. issue type
Step3: permutation test
Step4: Results
|
8,766 | <ASSISTANT_TASK:>
Python Code:
import tempfile
import girder_client
import numpy as np
from pandas import read_csv
from histomicstk.annotations_and_masks.annotation_and_mask_utils import (
delete_annotations_in_slide)
from histomicstk.saliency.cellularity_detection_thresholding import (
Cellularity_detector_thr... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Prepwork
Step2: Let's explore the GTcodes dataframe
Step3: Initialize the cellularity detector
Step4: The only required arguments to initiali... |
8,767 | <ASSISTANT_TASK:>
Python Code:
from sklearn.metrics.pairwise import cosine_similarity
similarity=cosine_similarity(document_term_matrix)
pd.DataFrame(similarity)
similarity=cosine_similarity(document_term_matrix.T)
pd.DataFrame(similarity, index=vocab, columns=vocab)
<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: What if want to understand which words are more similar in this context?
|
8,768 | <ASSISTANT_TASK:>
Python Code:
%load_ext watermark
%watermark -u -v -d -p matplotlib,numpy,scipy
%matplotlib inline
import matplotlib.pyplot as plt
def errorbar_default():
# Data
data = [1, 1.5, 1.2]
std_devs = [0.15, 0.25, 0.12]
# X axis positions
x_pos = range(len(data))
for d, std, x in zip... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <font size="1.5em">More info about the %watermark extension</font>
Step2: <br>
Step3: Modified Errorbar Plot
Step4: <hr>
Step5: <br>
Step6: ... |
8,769 | <ASSISTANT_TASK:>
Python Code:
from arcgis.gis import GIS
import getpass
password = getpass.getpass("Enter your ArcGIS Organizational Account Password: ")
gis = GIS("https://esrihax.maps.arcgis.com", "johnyHack", password)
print("Logged in successfully to {} as {}.".format(gis.properties.urlKey + '.' + gis.properties.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: Load a map widget from the gis class
Step2: Use the Content Manager to access data in your portal.
Step3: Correct results from API functions r... |
8,770 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import seaborn as sns
from IPython.display import display, HTML
series_one = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
series_one
series_two = pd.Series({'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5})
series_two
series_one[2:4]
serie... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pandas Python Data Analysis Library
Step2: <span class="mark">Starting from version v0.8.0, pandas supporst non-unique index values</span>
Step... |
8,771 | <ASSISTANT_TASK:>
Python Code:
USERNAME = ""
BASE_URL = "https://{u}.carto.com".format(u=USERNAME)
API_KEY = ""
from carto.auth import APIKeyAuthClient
auth_client = APIKeyAuthClient(api_key=API_KEY, base_url=BASE_URL)
from carto.kuvizs import KuvizManager
km = KuvizManager(auth_client)
html = "<html><body><h1>Workin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Kuviz manager creation
Step2: Create public Kuviz
Step3: Create Kuviz protected by password
Step4: Update a kuviz
Step5: If you want to remo... |
8,772 | <ASSISTANT_TASK:>
Python Code:
# install Pint if necessary
try:
import pint
except ImportError:
!pip install pint
# download modsim.py if necessary
from os.path import exists
filename = 'modsim.py'
if not exists(filename):
from urllib.request import urlretrieve
url = 'https://raw.githubusercontent.com/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: In the previous chapter we simulated a model of world population with
Step2: System objects
Step3: Some of these are parameters we need to sim... |
8,773 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
n = 20
x = np.random.random((n,1))
y = 5 + 6 * x ** 2 + np.random.normal(0,0.5, size=(n,1))
plt.plot(x, y, 'b.')
plt.show()
intercept_x = np.hstack((np.ones((n,1)), x))
intercept_x
np.linalg.lstsq(intercept_x,y)
coef... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This is a very simple dataset. There is only one input value for each record and then there is the output value. Our goal is to determine the ou... |
8,774 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import statsmodels.api as sm
import statsmodels.formula.api as smf
star98 = sm.datasets.star98.load_pandas().data
formula = 'SUCCESS ~ LOWINC + PERASIAN + PERBLACK + PERHISP + PCTCHRT + \
PCTYRRND + PERMINTE*AVYRSEXP*AVSALK + PERSPENK*PTRAT... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then, we fit the GLM model
Step2: Finally, we define a function to operate customized data transformation using the formula framework
Step3: A... |
8,775 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
with open('../sentiment_network/reviews.txt', 'r') as f:
reviews = f.read()
with open('../sentiment_network/labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
from string import punctuation
all_text = ''.join([c for c in reviews if... | <SYSTEM_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 preprocessing
Step2: Encoding the words
Step3: Encoding the labels
Step4: Okay, a couple issues here. We seem to have one review with ze... |
8,776 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# CODE HERE
np.zeros(10)
# CODE HERE
np.ones(10)
# CODE HERE
np.ones(10) * 5
# CODE HERE
np.arange(10,51)
# CODE HERE
np.arange(10,51,2)
# CODE HERE
np.arange(9).reshape(3,3)
# CODE HERE
np.eye(3)
# CODE HERE
np.random.rand(1)
# CODE HERE
np.random.randn(25)
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: Create an array of 10 zeros
Step2: Create an array of 10 ones
Step3: Create an array of 10 fives
Step4: Create an array of the integers from ... |
8,777 | <ASSISTANT_TASK:>
Python Code:
import random
from tenacity import retry
@retry
def do_something_unreliable():
# Pick a number between 0 and 10
if random.randint(0, 10) > 1:
# If it's greater than 1, raise an error
print("this number was bad...")
raise Exception
else:
print(".... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: - Stop After (X) Attempts
Step2: - Wait Between Attempts
|
8,778 | <ASSISTANT_TASK:>
Python Code:
# Create a pymatgen Structure for NaCl
from pymatgen import Structure, Lattice
# Create a pymatgen Structure for NaCl
from pymatgen import Structure, Lattice
a = 5.6402 # NaCl lattice parameter
lattice = Lattice.from_parameters(a, a, a, 90.0, 90.0, 90.0)
lattice
structure = Structure.from... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The default required arguments for creating a RadialDistributionFunction object are a list of pymatgen Structure objects, and the numerical indi... |
8,779 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import MeanShift
# Load data
iris = datasets.load_iris()
X = iris.data
# Standarize features
scaler = StandardScaler()
X_std = scaler.fit_transform(X)
# Create meanshift ... | <SYSTEM_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 Iris Flower Dataset
Step2: Standardize Features
Step3: Conduct Meanshift Clustering
|
8,780 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'niwa', 'sandbox-1', 'atmos')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "emai... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
8,781 | <ASSISTANT_TASK:>
Python Code:
import pandas
import numpy as np
import scipy.optimize
import matplotlib.pyplot as plt
%matplotlib inline
data1 = pandas.read_csv("ex2data1.txt", header=None, names=['test1', 'test2', 'accepted'])
data1.head()
def plotData(data):
fig, ax = plt.subplots()
results_accepted = 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: Part 1
Step2: Plotting data with + indicating (y = 1) examples and o
Step3: Part 2
Step4: The cost at initial theta (zeros) should be about ... |
8,782 | <ASSISTANT_TASK:>
Python Code:
import pymysql
db = pymysql.connect(
"db.fastcamp.us",
"root",
"dkstncks",
"sakila",
charset='utf8',
)
film_df = pd.read_sql("SELECT * FROM film;", db)
film_df.head(1)
SQL_QUERY =
SELECT *
FROM film
WHERE
(release_year = 2006 OR release_year = 2007... | <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: 2T_데이터 분석을 위한 SQL 실습 (1) - WHERE IN, LIKE, JOIN
Step3: pandas
Step5: film 테이블에서 설명에 "Boring"이라는 텍스트가 포함되면서, 렌탈 비용이 0.99인
Step7: rental_rate 에... |
8,783 | <ASSISTANT_TASK:>
Python Code:
!pip install -U tensorflow
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import tensorflow as tf
import math
from mnist_viz import *
!pip install -U okpy
from client.api.notebook import Notebook
ok = Notebook('lab14.ok')
f... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Today's lab is a reprise of TensorFlow and a brief foray into a more advanced topic in machine learning
Step2: Run the next cell to display som... |
8,784 | <ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division
import numpy as np
import pandas as pd
from scipy.stats import multivariate_normal, wishart
from itertools import product, starmap
import thinkbayes2
import thinkplot
%matplotlib inline
a = np.array([122.8, 115.5, 102.5, 84.7, 154.2, 83.7,
... | <SYSTEM_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 contains a solution to a problem posted on Reddit; here's the original statement of the problem
Step2: And make a scatter plot
St... |
8,785 | <ASSISTANT_TASK:>
Python Code:
# setup SymPy
from sympy import *
x, y, z, t = symbols('x y z t')
init_printing()
# a vector is a special type of matrix (an n-vector is either a nx1 or a 1xn matrix)
Vector = Matrix # define alias Vector so I don't have to explain this during video
# setup plotting
%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: Prerequisites
Step2: Vector addition
Step3: Vector length $\|\vec{u}\|$
Step4: Unit-length vectors $\hat{u}$
Step5: Dot product
Step6: Intu... |
8,786 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import gym
import numpy as np
import math
import reinforcement_learning as rl
# TensorFlow
tf.__version__
# OpenAI Gym
gym.__version__
env_name = 'Breakout-v0'
# env_name = 'SpaceInvaders-v0'
rl.checkpoint_base... | <SYSTEM_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 main source-code for Reinforcement Learning is located in the following module
Step2: This was developed using Python 3.6.0 (Anaconda) with... |
8,787 | <ASSISTANT_TASK:>
Python Code:
# Imports
import numpy as np
import pandas as pd
from sklearn.datasets import load_boston
#Ploting
import seaborn as sns
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib inline
# %matplotlib notebook
def read_sklearn_dataset():
data = load_boston()
... | <SYSTEM_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 the dataset
Step2: Feature Selection Steps (in practice)
Step3: <b> The SEAPORN regression plot </b> can instantly confirms our claims ... |
8,788 | <ASSISTANT_TASK:>
Python Code:
import graphlab
def polynomial_sframe(feature, degree):
# assume that degree >= 1
# initialize the SFrame:
poly_sframe = graphlab.SFrame()
# and set poly_sframe['power_1'] equal to the passed feature
poly_sframe['power_1'] = feature
# first check if degree > 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: Polynomial regression, revisited
Step2: Let's use matplotlib to visualize what a polynomial regression looks like on the house data.
Step3: As... |
8,789 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl/')
train_data,test_data = sales.random_split(.8,seed=0)
example_features = ['sqft_living', 'bedrooms', 'bathrooms']
example_model = graphlab.linear_regression.create(train_data, target = 'price', features = example_features,
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in house sales data
Step2: Split data into training and testing.
Step3: Learning a multiple regression model
Step4: Now that we have fit... |
8,790 | <ASSISTANT_TASK:>
Python Code:
from nams import load_data as cf
books = cf.load_game_of_thrones_data()
# We also add this weight_inv to our dataset.
# Why? we will discuss it in a later section.
books['weight_inv'] = 1/books.weight
books.head()
robbstark = (
books.query("book == 3")
.query("Source == 'Robb-Stark' 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: The resulting DataFrame books has 5 columns
Step2: From the above data we can see that the characters Addam Marbrand and Tywin Lannister have i... |
8,791 | <ASSISTANT_TASK:>
Python Code:
import regionmask
regionmask.__version__
import xarray as xr
import numpy as np
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from matplotlib import colors as mplc
from shapely.geometry import Polygon
color1 = "#9ecae1"
color2 = "#fc9272"
color3 = "#cab2d6"
cmap1 = mplc.Lis... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Other imports
Step2: Define some colors
Step3: Methods
Step4: Let's create a mask with each of these methods
Step5: Plot the masked regions
... |
8,792 | <ASSISTANT_TASK:>
Python Code:
import cashflows as cf
##
## Se tienen cuatro fuentes de capital con diferentes costos
## sus datos se almacenarar en las siguientes listas:
##
monto = [0] * 4
interes = [0] * 4
## emision de acciones
## --------------------------------------
monto[0] = 4000
interes[0] = 25.0 / 1.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: En la modelación de créditos con cashflow se consideran dos tipos de costos
|
8,793 | <ASSISTANT_TASK:>
Python Code:
class Contig:
def __init__(self, name, seq):
self.name = name
self.seq = seq
def __repr__(self):
return '< "%s" %i nucleotides>' % (self.name, len(self.seq))
def read_contigs(input_file_path):
contigs = []
current_name = ""
seq_collecti... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generate a fasta with informative columns
Step2: Pair wise table
Step3: Iterate over all the sequences at the same time
|
8,794 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
old_LCIA = pd.read_excel('put_the_path_to_your_old_LCIA_implementation_file.xls_here','CFs')
incomplete_LCIA = pd.read_excel('put_the_path_to_your_incomplete_LCIA_implementation_file.xls_here','CFs')
complete_LCIA = incomplete_LCIA.merge(old_LCIA,how='left')
# drop obs... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Pollutants which were already present in your old version will have their exchange unit introduced in the incomplete_LCIA. New pollutants of the... |
8,795 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
def read_file(filename):
# ...
return something
def histogram(texte):
# ...
return something
def normalize(hist):
# ...
return something
from pyensae.datasource import download_data
texts = downloa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: L'objectif est de distinguer un texte anglais d'un texte français sans avoir à le lire. Le premier réflexe consisterait à chercher la présence d... |
8,796 | <ASSISTANT_TASK:>
Python Code:
# Versão da Linguagem Python
from platform import python_version
print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version())
# Condicional If
if 5 > 2:
print("Python funciona!")
# Statement If...Else
if 5 < 2:
print("Python funciona!")
else:
print("Alg... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Condicional If
Step2: Condicionais Aninhados
Step3: Elif
Step4: Operadores Lógicos
|
8,797 | <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: TensorFlow에서 모델 및 레이어 정의하기
Step3: 모듈과 더 나아가 레이어는 "객체"에 대한 딥 러닝 용어입니다. 내부 상태와 해당 상태를 사용하는 메서드가 있습니다.
Step4: 다음은 모듈로 구성된... |
8,798 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import time
%matplotlib inline
from matplotlib.colors import ListedColormap
# Another messy looking function to make pretty plots of basketball courts
def visualize_court(log_reg_mode... | <SYSTEM_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've created a function that we'll use later to create visualizations. It is a bit messy and not essential to the material so don't worry about... |
8,799 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)
import tensorflow as tf
from rl_coach.architectures.tensorflow_components.heads.head import Head
from rl_coach.architectures.head_parameters import HeadP... | <SYSTEM_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 define a class - CategoricalQHead class. Each class in Coach has a complementary Parameters class which defines its constructor parame... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.