Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
12,000 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%reload_ext autoreload
%autoreload 2
from openfermion.ops import QuadOperator
from openfermion.utils import commutator, normal_ordered
H = QuadOperator('q0 q0', 0.5) + QuadOperator('p0 p0', 0.5) - QuadOperator('q0', 2)
(1j/2)*normal_ordered(commutator(H, QuadOperator(... | <SYSTEM_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. Forced quantum harmonic oscillator
Step2: In the Heisenberg picture, the time-evolution of the $\hat{q}$ and $\hat{p}$ operators is given by... |
12,001 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
a = pd.Series([20, 50, 190, 11, 76])
a
dados = [20, 50, 190, 11, 76]
rotulos = ['a', 'b', 'c', 'd', 'e']
b = pd.Series(dados, index=rotulos)
b
print(a[2])
print(b[2])
print(b['c'])
a.apply(lambda x: 2*x)
matriz = np.array([[1, 2, 3], [4, 5, 6]])... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Series
Step2: Os dados em uma série podem conter um índice, permitindo uma otimização no acesso dos dados
Step3: Além disso, o índice pode ser... |
12,002 | <ASSISTANT_TASK:>
Python Code:
!sudo pip3 install -q tensorflow-hub==0.4.0
!sudo pip3 install -q --upgrade tensorflow==1.15.0
import tensorflow as tf
import tensorflow_hub as hub
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
import re
import seaborn as sns
import scipy
import math
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: Make sure to restart your notebook's kernel before proceeding further.
Step2: <h2>TensorFlow Hub Concepts</h2>
Step3: When I completed this ex... |
12,003 | <ASSISTANT_TASK:>
Python Code:
print ("Hello my name is Levi.")
table={}
print (table)
table={}
table['a'] = 'n'
print (table)
newletter = table['a']
print(newletter)
table['b'] = 'f'
table['c'] = 'r'
print(table)
table.keys()
table.values()
print(table['c'])
print(table)
print(table['d'])
'd' in table.keys( )
t... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: You can also change the code in the boxes before you run them. Try replacing "Levi" with your name in the box above. Now, while the cursor is st... |
12,004 | <ASSISTANT_TASK:>
Python Code:
import sys, csv
from itertools import izip
def convert_XY_toVW(inputX_file_path, inputY_file_path, output_file_path):
with open(inputX_file_path, 'rb') as inputX_f, \
open(inputY_file_path, 'rb') as inputY_f, \
open(output_file_path, 'wb') as output_f:
reade... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Function to convert to VW format
Step2: Convert the training data to VW format
Step3: Convert the test data to VW format
Step4: Convert the t... |
12,005 | <ASSISTANT_TASK:>
Python Code:
import os
# if your Planet API Key is not set as an environment variable, you can paste it below
API_KEY = os.environ.get('PL_API_KEY', 'PASTE_YOUR_KEY_HERE')
# alternatively, you can just set your API key directly as a string variable:
# API_KEY = "YOUR_PLANET_API_KEY_HERE"
# construct 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: Set the base url for the Planet Analytic Feeds product
Step2: Test API Connection
Step3: Summarizing Feeds
Step4: Inspecting feed metadata
St... |
12,006 | <ASSISTANT_TASK:>
Python Code:
from pyspark import SparkContext
sc = SparkContext(master = 'local')
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("Python Spark SQL basic example") \
.config("spark.some.config.option", "some-value") \
.getOrCreate()
iris = sp... | <SYSTEM_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 data
Step2: Merge features to create a features column
Step3: Index label column with StringIndexer
Step4: Build pipeline
Step5: T... |
12,007 | <ASSISTANT_TASK:>
Python Code:
import warnings
warnings.filterwarnings("ignore")
import numpy as np
import scipy.stats as st
from sci_analysis import analyze
%matplotlib inline
import numpy as np
import scipy.stats as st
from sci_analysis import analyze
np.random.seed(987654321)
data = st.norm.rvs(size=1000)
analyze(... | <SYSTEM_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 will tell python to import the sci-analysis function analyze().
Step2: Now, sci-analysis should be ready to use. Try the following code
St... |
12,008 | <ASSISTANT_TASK:>
Python Code:
paragraph_text = "The Apollo program, also known as Project Apollo, was the third United States human spaceflight program carried out by the National Aeronautics and Space
Administration (NASA), which accomplished landing the first humans on the Moon from 1969 to 1972. First conceived du... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question
Step2: In this example we ask our BERT model questions related to the following paragraph
Step3: TensorRT Inference
Step4: Data Post... |
12,009 | <ASSISTANT_TASK:>
Python Code:
import wikinetworking as wn
import networkx as nx
from pyquery import PyQuery
%matplotlib inline
print "OK"
url = "https://en.wikipedia.org/wiki/List_of_Marvel_Cinematic_Universe_film_actors"
print url
links = wn.filter_links(PyQuery(url=url))
print links
selector="th"
links = wn.filte... | <SYSTEM_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 just ran some Python code that imports packages. Packages are pre-written Python code. The wikinetworking package contains code for crawling... |
12,010 | <ASSISTANT_TASK:>
Python Code:
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 = 'cifar-10-batches-py'
class DLProgress(tqdm):
last_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: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
12,011 | <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
t=np.linspace(0,4*np.pi,250)
def plot_sine1(a, b):
plt.figure(figsize=(6+a,6))
plt.plot(t, np.sin(t*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: Plotting with parameters
Step2: Then use interact to create a user interface for exploring your function
Step3: In matplotlib, the line style ... |
12,012 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mlxtend.data import iris_data
from mlxtend.preprocessing import shuffle_arrays_unison
X, y = iris_data()
X, y = shuffle_arrays_unison([X, y], random_seed=123)
X_train, X_test = X[:100], X[100: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:
Step2: Iris Feature by Class Distribution in Random Subsampling
|
12,013 | <ASSISTANT_TASK:>
Python Code:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import urllib2
import scipy.stats as stats
np.set_printoptions(precision=3, suppress=True)
url = ('https://raw.githubusercontent.com/Upward-Spiral-Science'
'/data/master/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: Label Data by It's Associated Cluster
Step2: 1) Run general regressions on data associated with actual cluster
Step3: 2) Change polynomial deg... |
12,014 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.1,<2.2"
import phoebe
b = phoebe.default_binary()
b.add_dataset('mesh')
print b.get_parameter('columns').get_choices()
b.add_dataset('lc')
print b.get_parameter('columns').get_choices()
b['columns'] = ['*@lc01', 'teffs']
b.get_parameter('columns').get_value()
... | <SYSTEM_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 this tutorial we will review the changes in the PHOEBE mesh structures. We will first explain the changes and then demonstrate them in code. ... |
12,015 | <ASSISTANT_TASK:>
Python Code:
from model.db.tb_raw import TbRaw
query = TbRaw.select().where(TbRaw.id > 0)
print "select query:", query.sql()[0] % tuple(query.sql()[1])
print "query result:"
for item in query.dicts().execute():
print item
# UNION查询
query = TbRaw.select().where(TbRaw.id >= 2) | TbRaw.select().wher... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 分析每一次调用
|
12,016 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import tensorflow as tf
with open('./reviews.txt', 'r') as f:
reviews = f.read()
with open('./labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
from string import punctuation
all_text = ''.join([c for c in reviews if c not in punctuation])
reviews = all_... | <SYSTEM_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: If you built labels correctly, you should see the next output.... |
12,017 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import os
import numpy as np
# Connect to the database backend and initalize a Snorkel session
from lib.init import *
from snorkel.annotations import load_marginals
from snorkel.models import candidate_subclass
Spouse = candidate_subcl... | <SYSTEM_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. Loading Candidates and Gold Labels
Step2: II. Training a Long Short-term Memory (LSTM) Neural Network
Step3: Now, we get the precision, rec... |
12,018 | <ASSISTANT_TASK:>
Python Code:
from random import randint
class RandomPlayer():
Player that chooses a move randomly.
def move(self, game, legal_moves, time_left):
if not legal_moves: return (-1,-1)
return legal_moves[randint(0,len(legal_moves)-1)]
class HumanPlayer():
Player that chooses 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: This is the ipython notebook you should use as a template for your agent. Your task for this assignment is to implement a winning AI for the gam... |
12,019 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import Image
%%html
<style>
.box-note {
padding: 10px;
margin: 20px;
background: #efefef;
font-size: 12px;
color: #333333;
}
</style>
mapserver_url = '172.17.0.2'
url = (
'http://172.17.0.2/?map=/maps/meteorological/ndvi.map&' +
'SERVICE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introdução
Step2: A endereço completo de acesso ao servidor de mapas necessita os seguintes parâmetros
Step3: Como comentado anteriormente, é ... |
12,020 | <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: TFX Keras Component Tutorial
Step2: Install TFX
Step3: Did you restart the runtime?
Step4: Let's check the library versions.
Step5: Set up p... |
12,021 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pylab as plt
x=np.linspace(0,50,100)
ts1=pd.Series(3.1*np.sin(x/1.5)+3.5)
ts2=pd.Series(2.2*np.sin(x/3.5+2.4)+3.2)
ts3=pd.Series(0.04*x+3.0)
#ts1.plot()
#ts2.plot()
#ts3.plot()
#plt.ylim(-2,10)
#plt.legend(['ts1','ts2','ts3'])
#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: In the above example, it is clear that $ts1$ and $ts2$ are most similar (they are both $sin$ functions under different transformations). $ts3$ ... |
12,022 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
np.__version__
x = [1,2]
y = [[4, 1], [2, 2]]
print np.dot(x, y)
print np.dot(y, x)
print np.matmul(x, y)
print np.inner(x, y)
print np.inner(y, x)
x = [[1, 0], [0, 1]]
y = [[4, 1], [2, 2], [1, 1]]
print np.dot(y, x)
print np.matmul(y, x)
x = np.array([[1, 4], [5, 6]... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Matrix and vector products
Step2: Q2. Predict the results of the following code.
Step3: Q3. Predict the results of the following code.
Step4: ... |
12,023 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from time import time
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction.text import HashingVectorizer
from sklearn.feature_selection import SelectKB... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Restore BF Reviews and Ratings
Step2: Restore Yelp Reviews and Ratings
Step3: Create a training and test data sets
Step4: Try RidgeClassifier... |
12,024 | <ASSISTANT_TASK:>
Python Code:
import cartopy.crs as ccrs
import cartopy.feature as feat
import matplotlib.pyplot as plt
import numpy as np
from metpy.calc import get_wind_components
from metpy.cbook import get_test_data
from metpy.plots import simple_layout, StationPlot, StationPlotLayout
from metpy.units import units... | <SYSTEM_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 setup
Step2: This sample data has way too many stations to plot all of them. Instead, we just select
Step3: Next grab the simple variables... |
12,025 | <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: So far the differential equations we've worked with have been first
Step2: where y is height above the sidewalk and v is velocity.
Step3: In ... |
12,026 | <ASSISTANT_TASK:>
Python Code:
# Imports the functionality that we need to display YouTube videos in a Jupyter Notebook.
# You need to run this cell before you run ANY of the YouTube videos.
from IPython.display import YouTubeVideo
# WATCH THE VIDEO IN FULL-SCREEN MODE
YouTubeVideo("8_wSb927nH0",width=640,height=360... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Question 1
Step2: Question 2
Step3: Question 3
Step4: Question 4
Step6: Assignment wrapup
|
12,027 | <ASSISTANT_TASK:>
Python Code:
%%sh
ctapipe-info
%%sh
ctapipe-info --version
ctapipe-info --dependencies
ctapipe-info --tools
%matplotlib inline
import warnings
warnings.filterwarnings("ignore") # get rid of some annoyances in latest matplotlib
import matplotlib.pyplot as plt
import numpy as np
from ctapipe.io 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: So there are so far not a lot of tools... the API is more interesting to start with.
Step2: first let's load up a blank image. Rememeber that... |
12,028 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sys
import os
import platform
import numpy as np
import matplotlib.pyplot as plt
import flopy
import flopy.utils as fputl
#Set name of MODFLOW exe
# assumes executable is in users path statement
exe_name = 'mfnwt'
if platform.system() == 'Windows':
exe_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: Function to calculate the analytical solution at specified points in a aquifer
Step2: Model data required to create the model files and calcula... |
12,029 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
pwd
cd output
ls
ranking_frame = pd.read_csv('rankings_20170425.csv')
ranking_frame.columns
ranking_frame.rrover.head(20)
ranking_frame.rrover.tail(20)
ranking_frame['bins'] = pd.qcut(ranking_frame.probability, 10, labels=False)... | <SYSTEM_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 the ranked predictions of the test set.
Step2: The probabilities are in descending order. Observe the greater number of True... |
12,030 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.ticker as mtick
import os
sns.set(style="whitegrid", color_codes=True)
import string
#this code is loading the book(in this case boy.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: get books
Step2: Reading the book
Step3: assigning the end of the book
Step4: adding up and getting percentages
Step5: Plotting the data and... |
12,031 | <ASSISTANT_TASK:>
Python Code:
def squareMax(num1, num2):
maxNum = max(num1, num2)
return maxNum*maxNum
def noInput():
answer = "abcd"
return answer
output = noInput()
print output
print answer
print squareMax(5,2)
print squareMax(3,3)
def squareMax(num1, num2):
maxNum = max(num1, num2)
retur... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Functions don't always require input. In the following example, the function outputs a string which we can store to a variable. Try running the ... |
12,032 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from __future__ import print_function
import sys, os
from ptha_paths import data_dir, events_dir
fixed_grid_file = os.path.join(data_dir, 'MapsTopo', 'fixedgrid_xyB_small.npy')
d=load(fixed_grid_file)
x=d[:,0]
y=d[:,1]
B=d[:,2]
print("x,y,B are 1-dimensional arrays of lengt... | <SYSTEM_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 topography data
Step2: Write out to text file
Step3: Another way to do the same thing
Step4: Read in zeta for a single event
Step5: ... |
12,033 | <ASSISTANT_TASK:>
Python Code::
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(x_train , y_train)
pred = model.predict(x_test)
<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:
|
12,034 | <ASSISTANT_TASK:>
Python Code:
import random
toss = random.random() # returns a random value between 0 and 1
if toss > 0.5:
print 'I won'
toss = random.random()
if toss > 0.5:
print 'I won'
else:
print 'You won'
fruits = ['apple', 'orange', 'banana', 'water melon']
fruit_index = random.randint(0, 3) # Ge... | <SYSTEM_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 else statement
Step2: if - else if Statment
|
12,035 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
lllat = 41.0 # latitude of lower left hand corner of the desired map domain (degrees).
urlat = 52.0 # latitude of upper right hand corner of the desired map domain (degree... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: TODO
|
12,036 | <ASSISTANT_TASK:>
Python Code:
import openpnm as op
import matplotlib.pyplot as plt
import scipy as sp
import numpy as np
import openpnm.models.geometry as gm
import openpnm.topotools as tt
%matplotlib inline
wrk = op.Workspace()
wrk.loglevel=50
%run shared_funcs.ipynb
x_values, y_values = simulation(n=8)
plt.figure... | <SYSTEM_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 the workspace loglevel to not print anything
Step2: As the paper requires some lengthy calculation we have split it into parts and put the ... |
12,037 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
from numpy.random import rand, seed
import seaborn as sns
import scipy.stats as stats
from matplotlib.pyplot import *
seed(10)
import itertools
# Create the inputs:
encoded_inputs = list( itertools.product([-1,1],[-1,1],[-1,1],[-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: <a name="fullfactorial"></a>
Step2: <a name="varlablels"></a>
Step3: Now that we have variable labels for each main effect and interaction eff... |
12,038 | <ASSISTANT_TASK:>
Python Code:
import os
ENDPOINT = # Enter your Kubeflow ENDPOINT here.
PATH=%env PATH
%env PATH={PATH}:/home/jupyter/.local/bin
shell_output=!gcloud config list --format 'value(core.project)' 2>/dev/null
GOOGLE_CLOUD_PROJECT=shell_output[0]
%env GOOGLE_CLOUD_PROJECT={GOOGLE_CLOUD_PROJECT}
# Docker 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: Step 1. Environment setup
Step2: tfx and kfp tools setup
Step3: You may need to restart the kernel at this point.
Step4: Modify the PATH envi... |
12,039 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
ds = xr.tutorial.load_dataset("air_temperature")
# to celsius
air = ds.air - 273.15
# resample from 6-hourly to daily values
air = air.resample(time="D").mean()
air
proje... | <SYSTEM_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
Step2: Plot the first timestep
Step3: Creating weights
Step4: Weighted mean
Step5: Plot
|
12,040 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import statsmodels
from statsmodels.imputation import mice
import random
random.seed(10)
df = pd.read_csv("http://goo.gl/19NKXV")
df.head()
original = df.copy()
original.describe().loc['count',:]
def add_nulls(df, n):
new = df.copy()
new.il... | <SYSTEM_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 data frame
Step2: Add some missing values
Step3: Confirm the presence of null values
Step4: Create categorical variables
Step5: Creat... |
12,041 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn.linear_model as lm
np.random.seed(1)
N = 400
𝜇 = 10
X = np.random.randn(N) + 𝜇
noise = 0.5 * np.random.randn(len(X))
Y = X + noise
model = lm.LinearRegression()
X ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We will work with artificially generated data. The independent variable X is a numpy array
Step2: The dependent variable Y is created by addi... |
12,042 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cams', 'sandbox-1', '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... |
12,043 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
iris = load_iris()
X, y = iris.data, iris.target
print(X.shape)
print("mean : %s " % X.mean(axis=0))
print("standard deviation : %s " % X.std(axis=0))
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(X)
X_scal... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The iris dataset is not "centered" that is it has non-zero mean and the standard deviation is different for each component
Step2: To use a prep... |
12,044 | <ASSISTANT_TASK:>
Python Code:
# Load libraries
import numpy as np
from sklearn.covariance import EllipticEnvelope
from sklearn.datasets import make_blobs
# Create simulated data
X, _ = make_blobs(n_samples = 10,
n_features = 2,
centers = 1,
random_state = 1)
# Rep... | <SYSTEM_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 Data
Step2: Detect Outliers
|
12,045 | <ASSISTANT_TASK:>
Python Code:
myExperiment = metatlas_objects.Experiment(name = 'QExactive_Hilic_Pos_Actinobacteria_Phylogeny')
myPath = '/global/homes/b/bpb/ExoMetabolomic_Example_Data/'
myPath = '/project/projectdirs/metatlas/data_for_metatlas_2/20150324_LPSilva_BHedlund_chloroflexi_POS_rerun/'
myFiles = glob.glob(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: <h1>Get a list of mzML files that you uploaded and assign them to a group</h1>
Step2: <h1>Specify the descriptive names for each group</h1>
Ste... |
12,046 | <ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
import seaborn as _
from bob_emploi.data_analysis.lib import read_data
from bob_emploi.data_analysis.lib import plot_helpers
data_folder = os.getenv('DATA_FOLDER')
fiche_dicts = read_data.load_fiches_from_xml(os.path.join(data_folder, 'rome/ficheMetierXml'))... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Before using the XML version of the data, I had a look at the CSV data. I saw that i could use unix_coherence_item_v330_utf8 to establish a mapp... |
12,047 | <ASSISTANT_TASK:>
Python Code:
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 = 'cifar-10-batches-py'
# Use Floyd's cifar-10 dataset 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: Image Classification
Step2: Explore the Data
Step5: Implement Preprocess Functions
Step8: One-hot encode
Step10: Randomize Data
Step12: Che... |
12,048 | <ASSISTANT_TASK:>
Python Code:
# Initial import
import dcgpy
# For plotting
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
# For scientific computing and more ...
import numpy as np
from tqdm import tqdm
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: Data set
Step2: Encoding and training a FFNN using dCGP
Step3: Same training is done using Keras (Tensor Flow backend)
Step4: Repeating ten t... |
12,049 | <ASSISTANT_TASK:>
Python Code:
# Prints Hello, world!
print('Hello, world!')
def hello():
'''Function that prints Hello, world!
'''
print('Hello, world!')
hello()
x = 4
print(x)
# Addition
print(x+5)
# Subtraction
print(x-5)
# Multiplication
print(x*5)
# Division
print(x/5)
print(x//5) #integer
# Modulus... | <SYSTEM_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 is a way of calling the same sequence, without having to rewrite it.
Step2: A variable is a storage location. It represents a value.... |
12,050 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
# Lotka Volterra model
# initialise parameters
k1 = 1.5
k2 = 1.
k3 = 3.
k4 = 1.
def my_dxdt(s,t):
Function returns values of derivatives of Lotka Volterra model
return [k1*s[0] - k2*s[0]*s[1], - k3*s[1]+k4*s[0]*s[1]]
def my_euler_solver(dxdt, s0, timeg... | <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: ODE to joy
Step3: To test the accuracy, we run the simulation with 2 different time grids, one with a step size of 0.01 and one with step size ... |
12,051 | <ASSISTANT_TASK:>
Python Code:
#@title Imports and Definitions
import numpy as np
import os
import tensorflow.compat.v2 as tf
tf.enable_v2_behavior()
import gin
from rigl import sparse_utils
from rigl.rigl_tf2 import init_utils
from rigl.rigl_tf2 import utils
from rigl.rigl_tf2 import train
from rigl.rigl_tf2 import ne... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Copyright 2020 Google LLC.
Step2: Here we demonstrate how we can calculate the standard deviation of random noise at initialization for layer-w... |
12,052 | <ASSISTANT_TASK:>
Python Code:
def imprime(i):
print (i)
def imprimeLista(l):
for e in l:
imprime (e)
imprimeLista([1, 3, 5, 7])
def fatorial(n):
fat = 1
while n > 1:
fat *= n
n -= 1
return fat
print(fatorial(3))
print(fatorial(6))
import sys
sys.setrecursionlimit(50)
# Ao ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Entretanto, nada impede de uma função chamar ela mesma!
Step2: Uma outra forma de cálcular o fatorial é
Step3: O principal problema do exemplo... |
12,053 | <ASSISTANT_TASK:>
Python Code:
def plasma_frequency(n, q, m):
'''
Returns the plasma angular frequency for a given species.
'''
omega_p = sqrt(n*q**2/(m*epsilon_0))
return omega_p
def cyclotron_frequency(q, m, B0):
'''
Returns the cyclotron angular frequency for a given species.
'''
... | <SYSTEM_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 define a convenient object
Step2: The cold plasma tensor
|
12,054 | <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: Writing a training loop from scratch
Step2: Introduction
Step3: Let's train it using mini-batch gradient with a custom training loop.
Step4: ... |
12,055 | <ASSISTANT_TASK:>
Python Code:
from __future__ import division
import sys
from pprint import pprint
from astropy.time import Time
from itertools import izip
import matplotlib.pyplot as plt
import tables
import numpy as np
from astropy.table import Table, join
%matplotlib inline
sys.path.insert(0, '/home/aldcroft/git/st... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mean actual success rate vs. predicted within bins
Step2: Actual number of stars per obsid vs. expected
Step3: Why mean expected number of sta... |
12,056 | <ASSISTANT_TASK:>
Python Code:
# Author: Marijn van Vliet <w.m.vanvliet@gmail.com>
# Roman Goj <roman.goj@gmail.com>
# Denis Engemann <denis.engemann@gmail.com>
#
# License: BSD (3-clause)
import numpy as np
import mne
from mne.datasets import sample
from mne.time_frequency import csd_morlet
from mne.be... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Reading the raw data
Step2: Computing the cross-spectral density matrix at 4 evenly spaced frequencies
|
12,057 | <ASSISTANT_TASK:>
Python Code:
from pymc3 import Model, Normal, Uniform, NUTS, sample, find_MAP, traceplot, summary, df_summary, trace_to_dataframe
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
x = np.array([1,2,3,4,5,6,7,8,9,10])
y =np.array([5.19, 6.56, 9.19, 8.09, 7.6,... | <SYSTEM_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 dataset and plot
Step2: Create the model
Step3: Priors....
Step4: Find and assign the priors, then perform MCMC using the NUT sampler ... |
12,058 | <ASSISTANT_TASK:>
Python Code:
import sys
fishes = ["teri", "kakap", "tongkol"]
items = (" sword"," halberd"," axe"," knife"," blade")
for fish in fishes:
print("ini ikan "+fish)
for item in items:
print(item)
print(fishes[0])
print(items[-1])
del(fishes[-1])
for fish in fishes:
print("ini ikan "+fish)
nam... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Tuple
Step2: Sequences
Step3: Dictionary
Step4: With it yo can see that if we can identify the name, we can get the other content of the fiel... |
12,059 | <ASSISTANT_TASK:>
Python Code:
def NumberOfSolutions(x , y , z , n ) :
ans = 0
for i in range(x + 1 ) :
for j in range(y + 1 ) :
temp = n - i - j
if temp >= 0 :
temp = min(temp , z )
ans += temp + 1
return ans
if __name__== "__main __":
x , y , z , n = 1 , 2 , 3 , 4
print(NumberOfSolu... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
|
12,060 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
# Google Cloud Notebook
if os.path.exists("/opt/deeplearning/metadata/env_version"):
USER_FLAG = "--user"
else:
USER_FLAG = ""
! pip3 install -U google-cloud-aiplatform $USER_FLAG
! pip3 install -U google-cloud-storage $USER_FLAG
if not os.getenv("IS_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: Install the latest GA version of google-cloud-storage library as well.
Step2: Restart the kernel
Step3: Before you begin
Step4: Region
Step5:... |
12,061 | <ASSISTANT_TASK:>
Python Code:
import cobra.test
import os
from os.path import join
data_dir = cobra.test.data_dir
print("mini test files: ")
print(", ".join(i for i in os.listdir(data_dir) if i.startswith("mini")))
textbook_model = cobra.test.create_test_model("textbook")
ecoli_model = cobra.test.create_test_model("ec... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: SBML
Step2: There are other dialects of SBML prior to FBC 2 which have previously been use to encode COBRA models. The primary ones is the "COB... |
12,062 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from qutip.qip.circuit import QubitCircuit
from qutip.qip.operations import gate_sequence_product
import numpy as np
from qutip.qip.models.spinchain import CircularSpinChain
from qutip.qip.models.spinchain import LinearSpinChain
from qutip.qip.device import CircularSp... | <SYSTEM_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 your qutip version is lower than 4.4.1 please run the following cell
Step2: Otherwise please run this cell
Step3: Hamiltonian
Step4: The n... |
12,063 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
a = torch.rand((10, 1000, 23))
lengths = torch.randint(1000, (10,))
for i_batch in range(10):
a[i_batch, :lengths[i_batch], :] = 2333
<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:
|
12,064 | <ASSISTANT_TASK:>
Python Code:
A = np.eye(5)
print(A)
datafile = 'ex1\\ex1data1.txt'
df = pd.read_csv(datafile, header=None, names=['Population', 'Profit'])
def plot_data(x, y):
plt.figure(figsize=(10, 6))
plt.plot(x, y, '.', label='Training Data')
plt.xlabel("Population of City in 10,000s", fontsize=16)
... | <SYSTEM_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 Linear Regression with One Variable
Step2: 2.2 Gradient Descent
Step3: Let's make the (totally random) guess that $\theta_0$ = 0 and $\theta... |
12,065 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from collections import Counter
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set()
# Importing Games
from game_types import PrisonersDilemma
from game_types import Coordination
# Importing Strategies
from strategies import chaos as c
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: Simulating Games
Step2: In this scenario defecting is the domiant strategy. Where the agent is better off defecting no matter what other agents... |
12,066 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import scipy.interpolate
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
xmin, xmax = 0., 4*np.pi
x = np.linspace(xmin, xmax, 10)
y = np.sin(x)
x2 = np.linspace(xmin, xmax, 100)
# Linear interpolation wit... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Official documentation
Step2: Interpolate 1D functions
Step3: Linear interpolation
Step4: B-Splines interpolation
Step5: Spline linear inter... |
12,067 | <ASSISTANT_TASK:>
Python Code:
# dependencies
import matplotlib.pyplot as plt
import pickle
import numpy as np
f = open('final_dataset.pickle','rb')
dataset = pickle.load(f)
sample_image = dataset['train_dataset'][0]
sample_label = dataset['train_labels'][0]
print(sample_label)
plt.figure()
plt.imshow(sample_image)
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: Now lets add some erosive noise to the image and then lets see the recall
|
12,068 | <ASSISTANT_TASK:>
Python Code:
# Imports
import sys # Required for system access (below)
import os # Required for os access (below)
sys.path.append(os.path.join(os.path.dirname(os.getcwd()), 'dependencies'))
from neuron_readExportedGeometry import * # Required to interpret hoc files
# Convert the given hoc file into 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: Next, load up a neuron hoc file as a geo object
Step2: Now that we have a geo object ready to go, let's make a list of all the neurite paths fr... |
12,069 | <ASSISTANT_TASK:>
Python Code:
# this is code cell -> click on it, then press Shift+Enter
from IPython.display import YouTubeVideo
YouTubeVideo('vasBnRS3tQk')
import packages.initialization
import pioneer3dx as p3dx
p3dx.init()
import motion_widget
<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: Initialization
Step2: Motion
|
12,070 | <ASSISTANT_TASK:>
Python Code:
PROJECT = !gcloud config get-value project
PROJECT = PROJECT[0]
BUCKET = PROJECT
REGION = "us-central1"
%env PROJECT=$PROJECT
%env BUCKET=$BUCKET
%env REGION=$REGION
%%bash
# Create a BigQuery dataset for serverlessml if it doesn't exist
datasetexists=$(bq ls -d | grep -w serverlessml)
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: Create a BigQuery Dataset and Google Cloud Storage Bucket
Step2: Model 1
Step3: Once the training is done, visit the BigQuery Cloud Console an... |
12,071 | <ASSISTANT_TASK:>
Python Code:
# Setup code. Make sure you run this first!
import os
import random
import math
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
import tensorflow as tf
from tensorflow import keras
from learntools.core import binder; binder.bind(globals())
from learntools.embed... | <SYSTEM_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: Part 2
Step3: At the start of the notebook we also trained a model with 64-dimensional movie and user embeddings. How do you exp... |
12,072 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def well2d(x, y, nx, ny, L=1.0):
Compute the 2d quantum well wave function.
return (2/L) * np.sin((nx * np.pi * x)/L) * np.sin((ny * np.pi * y)/L)
psi = well2d(np.linspace(0,1,10), np.linspace(0,1,10), 1, 1)
as... | <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: Contour plots of 2d wavefunctions
Step3: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali... |
12,073 | <ASSISTANT_TASK:>
Python Code:
%pylab notebook
r1 = 0.641 # Stator resistance
x1 = 0.750 # Stator reactance
r2 = 0.300 # Rotor resistance for single cage motor
r2i = 0.400 # Rotor resistance for inner cage of double-cage motor
r2o = 3.200 # ... | <SYSTEM_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, initialize the values needed in this program.
Step2: Calculate the Thevenin voltage and impedance from Equations 7-41a
Step3: Now calcu... |
12,074 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
boston = load_boston()
#print boston.DESCR
X = boston.data
y = boston.target
Xtrain, Xtest, ytrain, ytest = train_test_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: Of course, that only predicts the value for a fraction of the data set. I don't think that I have made it entirely clear how to use cross-valid... |
12,075 | <ASSISTANT_TASK:>
Python Code:
import sys
from os.path import *
import os
from astropy.io import fits
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from matplotlib.colors import LogNorm
from pylab import figure, cm
import astropy.time
import astropy.units as u
from astropy.coordinates import get_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:
Step 1
Step1: Get the data from the FITS file.
Step2: Rotate to solar coordinates
Step3: Write the output to a new FITS file.
|
12,076 | <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... |
12,077 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# import all shogun classes
from modshogun import *
import random
import numpy as np
import matplotlib.pyplot as plt
from math import exp
# plot likelihood for three different noise lebels $\sigma$ (which is not yet squared)
sigmas=np.array([0.5,1,2])
# likelihood inst... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Some Formal Background (Skip if you just want code examples)
Step2: Apart from its apealling form, this curve has the nice property of given ri... |
12,078 | <ASSISTANT_TASK:>
Python Code:
from sklearn.metrics import confusion_matrix
y_true = [2, 0, 2, 2, 0, 1]
y_pred = [0, 0, 2, 2, 0, 2]
confusion_matrix(y_true, y_pred)
y_true = ["cat", "ant", "cat", "cat", "ant", "bird"]
y_pred = ["ant", "ant", "cat", "cat", "ant", "cat"]
confusion_matrix(y_true, y_pred, labels=["ant", "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: 이진 분류 결과표 Binary Confusion Matrix
Step2: ROC 커브
Step3: Multi-Class 예제
Step4: AUC (Area Under the Curve)
Step5: Precision-Recall 커브
|
12,079 | <ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.1,<2.2"
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
b.add_constraint('semidetached', 'primary')
b['requiv@constraint@primary']
b['requiv... | <SYSTEM_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. See Building a System for more details.
Step2: Semi-Detached Systems
Ste... |
12,080 | <ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('../../metal')
import metal
%load_ext autoreload
%autoreload 2
%matplotlib inline
import pickle
with open("data/basics_tutorial.pkl", 'rb') as f:
X, Y, L, D = pickle.load(f)
from metal.utils import split_data
Ls = split_data(L, splits=[0.8, 0.1, 0.1], ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We reload the synthetic data from the basics tutorial.
Step2: In this case, there isn't a lot to see, since these label matrices were created s... |
12,081 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
%matplotlib inline
import pandas
df = pandas.read_csv('muct76.csv', header=0, usecols=np.arange(2,154), dtype=float)
df.head()
X = df.iloc[:, ::2].values
Y = df.iloc[:, 1::2].values
print(X.shape, Y.shape)
plt.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: After downloading the dataset, unzip the landmarks, and use a file named muct76.csv.
Step2: The df contains both $x$ and $y$ coordinates of lan... |
12,082 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import scipy as sp
import scipy.stats as stats
import matplotlib.pyplot as plt
import cPickle as pickle
import os
%matplotlib inline
covSim = np.array([[1.0, .8, .2, .2],
[.8, 1.0, .3, .3],
[.3, .3, 1.0, .8],
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Generation of a simulated data set
Step2: Calculate Mahalanobis distance
|
12,083 | <ASSISTANT_TASK:>
Python Code:
# 载入所需要的库
import numpy as np
import pandas as pd
from time import time
from sklearn.metrics import f1_score
# 载入学生数据集
student_data = pd.read_csv("student-data.csv")
print "Student data read successfully!"
# TODO: 计算学生的数量
n_students = None
# TODO: 计算特征数量
n_features = None
# TODO: 计算通过的学生数... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 练习
Step2: 数据准备
Step3: 预处理特征列
Step4: 实现
Step5: 训练和评价模型
Step6: 练习
Step7: 结果表格
|
12,084 | <ASSISTANT_TASK:>
Python Code:
from matplotlib import pyplot
pyplot.rc("figure", figsize=(10, 10))
from fuzzylogic.classes import Domain
from fuzzylogic.functions import R, S, alpha
T = Domain("test", 0, 30, res=0.1)
T.up = R(1,10)
T.up.plot()
T.down = S(20, 29)
T.down.plot()
T.polygon = T.up & T.down
T.polygon.plot()
... | <SYSTEM_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 show off a few interesting functions ;)
Step2: Domains
Step3: Many times you end up with sets that never hit 1 like with sigmoids, trian... |
12,085 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
Gradient Descent
Example
f(x) = x**4 -3*x**3 + 2
f'(x) = 4*x**3 - 9*x**2
We want f'(x) = 0 - slope is zero / minima
Initial guess: x=4
f'(4) = 112
Second guess: x=-1
f'(-1) = -13
=> f'(4) > 0 => decrease x | f'(-1) < 0 => increase x
x_new = x_old - f'(x) ??? => not ide... | <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: Gradient Descent
Step3: Example for Backprop
Step5: Example for Backprop of a simple Neural Networks
|
12,086 | <ASSISTANT_TASK:>
Python Code:
#-- SET ME Tutorial should work with most binary black hole events
#-- Default is no event selection; you MUST select one to proceed.
eventname = ''
eventname = 'GW150914'
#eventname = 'GW151226'
#eventname = 'LVT151012'
#eventname = 'GW170104'
# want plots?
make_plots = 1
plottype = ... | <SYSTEM_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 the event properties from a local json file (download in advance)
Step2: Read in the data
Step3: Data Gaps
Step4: The data are dominated... |
12,087 | <ASSISTANT_TASK:>
Python Code:
map_coords = (45.1973288, 5.7103223) #( 45.166672, 5.71667 )
import pysolar.solar as solar
import datetime as dt
d = dt.datetime.now()
#d = dt.datetime(2017, 6, 20, 13, 30, 0, 130320)
solar.get_altitude( *map_coords, d)
solar.get_azimuth(*map_coords, d)
Alt = [ solar.get_altitude(*map_co... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Remarque
Step2: Projection sur une surface inclinée
Step3: Verif
|
12,088 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import pastas as ps
import matplotlib.pyplot as plt
ps.show_versions()
fname = '../data/MenyanthesTest.men'
meny = ps.read.MenyData(fname)
# Get distances from metadata
xo = meny.H["Obsevation well"]['xcoord']
yo = meny.H["Obsevation well"]['ycoord... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load data from a Menyanthes file
Step2: Get the distances of the extractions to the observation well. Extraction 1 is about two times as far fr... |
12,089 | <ASSISTANT_TASK:>
Python Code:
my_data = cellreader.CellpyData()
# only for my MacBook
filename = "/Users/jepe/scripting/cellpy/dev_data/out/20190204_FC_snx012_01_cc_01.h5"
assert os.path.isfile(filename)
my_data.load(filename)
%%timeit
my_data.make_summary()
%%timeit
my_data.make_step_table()
<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: Timing
|
12,090 | <ASSISTANT_TASK:>
Python Code:
# A bit of setup
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# for auto-reloading external modules
# see h... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Implementing a Neural Network
Step2: The neural network parameters will be stored in a dictionary (model below), where the keys are the paramet... |
12,091 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import seaborn as sns
from scipy import stats
import matplotlib.pyplot as plt
%matplotlib inline
# Please adjust the random seed for new results
np.random.seed(11)
# See Part 2 for code comments
def core_hot_spot(ambient_temp, overload_ratio, t0=35, tc=30, N=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: Type I Prognostics
Step2: The resulting failure distribution of all simulated transformers from the training set is shown below. The predicted ... |
12,092 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
xv=[1,2,3,4]; yv=[5,1,4,0]
plt.plot(xv,yv);
plt.plot(xv,yv,'ro');
myplot=plt.plot(xv,yv,'k--');
plt.setp(myplot,linewidth=3.0,marker='+',markersize=30);
myplot=plt.plot(xv,yv,'k--');
plt.setp(myplot,'linewidth',... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Above commands enable pylab environment => direct access to numpy, scipy and matplotlib. The option 'inline' results in plot outputs to be direc... |
12,093 | <ASSISTANT_TASK:>
Python Code:
(1, 2, 3)
()
(1,)
t = 1, 2, 3
t
len(t)
t[1]
u = 4, 5
t + u
2 * u
x, y = 1, 2
x
y
x, y = y, x
x
y
s = {0, 1, 0, 5, 5, 1, 0}
s
1 in s, 2 in s, 1 not in s
l = [0, 1, 0, 5, 5, 1, 0]
set(l)
set('абба')
set()
{}
len(s)
for x in s:
print(x)
{i for i in range(5)}
s2 = s | {2, 5}
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: Скобки ставить не обязательно, если кортеж - единственная вещь в правой части присваивания.
Step2: Работать с кортежами можно так же, как со сп... |
12,094 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
from statsmodels.compat import lzip
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
from statsmodels.formula.api import ols
prestige = sm.datasets.get_rdataset("Duncan", "carData"... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Duncan's Prestige Dataset
Step2: Influence plots
Step3: As you can see there are a few worrisome observations. Both contractor and reporter ha... |
12,095 | <ASSISTANT_TASK:>
Python Code:
PROJECT = "cloud-training-demos" # Replace with your PROJECT
BUCKET = "cloud-training-bucket" # Replace with your BUCKET
REGION = "us-central1" # Choose an available region for AI Platform
TFVERSION = "1.14" # TF version for AI Platform to use
import os
os.env... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Move code into python package
Step2: Create model.py
Step3: Create task.py
Step4: Create hypertuning configuration
Step5: Run the training j... |
12,096 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-3', 'toplevel')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 2... |
12,097 | <ASSISTANT_TASK:>
Python Code:
binary_command = {'NOT': '~', 'AND': '&', 'OR': '|', 'LSHIFT': '<<', 'RSHIFT': '>>'}
operators = binary_command.values()
import csv
def translate(l):
return [binary_command[a] if a in binary_command else a for a in l]
def display(input_file):
produce a dict mapping variables to 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: Day 7
Step2: Test
Step4: This approach seems correct, but it creates huge expressions along the way that become harder and harder to parse. Th... |
12,098 | <ASSISTANT_TASK:>
Python Code:
a = 1+1j
output = np.angle(a, deg=False)
print(output)
a = np.array([1+2j, 3+4j, 5+6j])
real = a.real
imag = a.imag
print("real part=", real)
print("imaginary part=", imag)
a = np.array([1+2j, 3+4j, 5+6j])
a.real = 9
a.imag = [5, 7, 9]
print(a)
a = 1+2j
output = np.conjugate(a)
print(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: Q2. Return the real part and imaginary part of a.
Step2: Q3. Replace the real part of a with 9, the imaginary part with [5, 7, 9].
Step3: Q4. ... |
12,099 | <ASSISTANT_TASK:>
Python Code:
import requests
import json
from TM1py import TM1Service
STATION = 'GHCND:USW00014732'
FROM, TO = '2017-01-01', '2017-01-04'
HEADERS = {"token": 'yyqEBOAbHVbtXkfAmZuPNfnSXvdfyhgn'}
url = 'https://www.ncdc.noaa.gov/cdo-web/api/v2/data?' \
'datasetid=GHCND&' \
'startdate=' + 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: Constants
Step2: Step 2
Step3: This is the URL we will get the data from.
Step 3
Step4: Step 4
Step5: Step 5
Step6: With TM1py we can send ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.