Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
12,900 | <ASSISTANT_TASK:>
Python Code:
from os.path import exists
from goatools.obo_parser import GODag
if not exists('go-basic.obo'):
!wget http://geneontology.org/ontology/go-basic.obo
dag = GODag('go-basic.obo', optional_attrs=['def'])
term = next(iter(dag.values()))
print(dir(term))
pattern = '{ID} {NAME}\n{DEF}'
pr... | <SYSTEM_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 one GOTerm object
Step2: The optional 'def' obo field becomes a 'defn' data member in a GOTerm object
Step3: Print one GO term and its opt... |
12,901 | <ASSISTANT_TASK:>
Python Code:
from nipype import Node, Workflow
from nipype.interfaces.fsl import BET, IsotropicSmooth
# Initiate a skull stripping Node with BET
skullstrip = Node(BET(mask=True,
in_file='/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz'),
name="sku... | <SYSTEM_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 smoothing Node with IsotropicSmooth
Step2: Now, to use iterables and therefore smooth with different fwhm is as simple as that
Step3: ... |
12,902 | <ASSISTANT_TASK:>
Python Code:
%reload_ext pymldb
%mldb help
%mldb GET /v1/types/datasets
%mldb DELETE /v1/datasets/titanic
%mldb loadcsv titanic https://raw.githubusercontent.com/datacratic/mldb-pytanic-plugin/master/titanic_train.csv
%mldb query select * from titanic limit 5
df = %mldb query select * from titani... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: And then we'll ask it for some help
Step2: The most basic way in which the %mldb magic can help us with MLDB's REST API is by allowing us to ty... |
12,903 | <ASSISTANT_TASK:>
Python Code:
import numpy
# use a consistent seed so that everyone has the same data
numpy.random.seed(1000)
import os,sys
%matplotlib inline
import matplotlib.pyplot as plt
sys.path.insert(0,'../utils')
from mkdesign import create_design_singlecondition
from graph_utils import show_graph_from_adjmtx
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Show the true graph
Step2: Run an analysis using SPM
Step3: Click "done", which will take you to the next window to specify the B and C matric... |
12,904 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import os
import sys
import platform
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
import flopy
print(sys.version)
print('numpy version: {}'.format(np.__version__))
print('matplotlib version: {}'.format(mpl.__version__))... | <SYSTEM_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 File Containing Zones
Step2: Extract Budget Information from ZoneBudget Object
Step3: Convert Units
Step4: Alias Names
Step5: Return th... |
12,905 | <ASSISTANT_TASK:>
Python Code:
sim = simulator.Simulator(
model=models.Generic2dOscillator(),
connectivity=connectivity.Connectivity(load_default=True),
coupling=coupling.Linear(),
integrator=integrators.EulerDeterministic(),
monitors=Raw(pre_expr='V;W;V**2;W-V', post_expr=';;sin(mon);exp(mon)'))
si... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Plotting the results demonstrates the effect of the transformations of the state variables through the monitor. Here, a Raw monitor was used to ... |
12,906 | <ASSISTANT_TASK:>
Python Code:
import time
import sys
import operator
import numpy as np
import matplotlib.pyplot as plt
from IPython import display
import elfi
%matplotlib inline
# Add the code folder to the path
sys.path.append('code')
import simulator as si
import elfi_operations as ops
s = si.Simulator(200, 0.1, 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: Simulator illustration
Step2: ELFI model
Step3: Test the model
Step4: The inference
Step5: We will create a sample of 1000 points from the a... |
12,907 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_path = 'Bike-Sharing-Dataset/hour.csv'
rides = pd.read_csv(data_path)
rides.head()
rides[:24*10].plot(x='dteday', y='cnt')
dummy_fields = ['seas... | <SYSTEM_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 and prepare the data
Step2: Checking out the data
Step3: Dummy variables
Step4: Scaling target variables
Step5: Splitting the data into... |
12,908 | <ASSISTANT_TASK:>
Python Code:
import sys # system module
import pandas as pd # data package
import matplotlib.pyplot as plt # graphics module
import datetime as dt # date and time module
import numpy as np # foundation for Pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: The Data Source
Step2: We see that the data set has been successfully imported, though the meaning of some variables in their current form are ... |
12,909 | <ASSISTANT_TASK:>
Python Code:
import datetime
import os
import shutil
import numpy as np
import pandas as pd
import tensorflow as tf
from google.cloud import aiplatform
from matplotlib import pyplot as plt
from tensorflow import keras
from tensorflow.keras.callbacks import TensorBoard
from tensorflow.keras.layers impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load raw data
Step2: Use tf.data to read the CSV files
Step3: Build a simple keras DNN model
Step4: Next, we create the DNN model. The Sequen... |
12,910 | <ASSISTANT_TASK:>
Python Code:
BRK['simple_return'] = (BRK['Close'] / BRK['Close'].shift(1)) - 1
print(BRK['simple_return'])
BRK['simple_return'].plot(figsize=(8,5))
plt.show()
avg_returns_d = BRK['simple_return'].mean()
avg_returns_d
avg_returns_a = avg_returns_d * 250 # multiply by the average number of business days... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Logarithmic Return
|
12,911 | <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: Grappler による TensorFlow グラフ最適化
Step2: オプティマイザの状態を簡単に切り替えるためのコンテキストマネージャを作成します。
Step3: Grappler 使用の有無による実行パフォーマンスを比較する
Step4: 定数折り畳みオプティマイザをオフ... |
12,912 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
import geopandas as gpd
import pandas as pd
from OpticalRS import *
from OpticalRS.ArrayUtils import band_df
from sklearn.neighbors import KNeighborsRegressor
from sklearn.metrics import mean_squared_error
from sklearn.cross_validation import train_test_split
style.use('ggpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Depth Restriction
Step2: I want to make the masks match on my data sets so that the unmasked pixels will line up correctly.
Step3: Split data ... |
12,913 | <ASSISTANT_TASK:>
Python Code:
import pymc as pm
parameter = pm.Exponential("poisson_param", 1)
data_generator = pm.Poisson("data_generator", parameter)
data_plus_one = data_generator + 1
print("Children of `parameter`: ")
print(parameter.children)
print("\nParents of `data_generator`: ")
print(data_generator.parents)... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: parameter controls the parameter of data_generator, hence influences its values. The former is a parent of the latter. By symmetry, data_generat... |
12,914 | <ASSISTANT_TASK:>
Python Code:
!git clone https://github.com/ultralytics/yolov3 # clone repo
%cd yolov3
%pip install -qr requirements.txt # install dependencies
import torch
from IPython.display import Image, clear_output # to display images
clear_output()
print(f"Setup complete. Using torch {torch.__version__} ({to... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 1. Inference
Step2: 2. Test
Step3: COCO test-dev2017
Step4: 3. Train
Step5: Train a YOLOv3 model on COCO128 with --data coco128.yaml, starti... |
12,915 | <ASSISTANT_TASK:>
Python Code:
# start qkit and import the needed modules. we here assume an already configured qkit measurement environment
import qkit
qkit.start()
from qkit.measure.spectroscopy import spectroscopy
import qkit.measure.samples_class as sc
import numpy as np
# initialize instruments; as an example we 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: Creating a spectrum object. The init takes<br>
Step2: The general VNA parameters (probing frequencies, power, etc.) can be either set at the de... |
12,916 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
import seaborn as sns
import statsmodels.api as sm
from sklearn import linear_model
iris = sns.load_dataset("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: On va utiliser la fameuse base des Iris qu'on peut appeler depuis la librairie seaborn.
Step2: Grâce à ces graphiques, on observere une forte r... |
12,917 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib
#matplotlib.use('nbagg')
import matplotlib.pyplot as plt
x = np.linspace(1e-6,1,200)
y1 = -np.log(x)
y2 = -5*x+5
plt.plot(x,y1,label='$-\log p(x)$',lw=2)
plt.plot(x,y2,label='$-5p(x)+5$',lw=2)
plt.xlabel("$p(x)$")
plt.ylim(-0.5,10)
plt.tight_layout()
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: As we see, the $-\log p(x)$ is a convex function and cannot be bounded above by a line for all $p(x)$. However $p(x)$ is a density function and ... |
12,918 | <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 numpy as np
import matplotlib.pyplot as plt
from diGP.preprocessing import (readHCP,
averageb0Volumes,
... | <SYSTEM_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 a folder containing preprocessed HCP data.
Step2: Read data from file.
Step3: This data has some negative values, which is unrealistic... |
12,919 | <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... |
12,920 | <ASSISTANT_TASK:>
Python Code:
# Compatibility with python 3.0
from __future__ import division
# Array fast operation
import numpy as np
from numpy import (ones, pi, log10)
# Signal processing routines
import scipy.signal as sig
# Plotting
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
mpl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Introduction
Step2: The phase error $\phi_{out}[n]$ can be calculated integrating the error in the frequency. Then the power spectrum density i... |
12,921 | <ASSISTANT_TASK:>
Python Code:
#Exercise 3.1.1
logger.setLevel(logging.WARNING)
data = [
set([1, 2, 3, 4]),
set([2, 3, 5, 7]),
set([2, 4, 6]),
]
def Jaccard_similarity_calc(set_a, set_b):
calculate the Jaccard similarity of two sets
res = \frac{a \cap b}{a \cup b}
assert isinstanc... | <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: 3 Finding Similar Items
Step5: exercise 3.1.3
Step7: exercise
Step9: #exercise 3.2.3
Step11: Minhashing
Step13: minhash and Jaccard Similar... |
12,922 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('S4ZUwgesjS8')
%pylab inline
from partSix import *
NN = Neural_Network()
# X = (hours sleeping, hours studying), y = Score on test
X = np.array(([3,5], [5,1], [10,2], [6,1.5]), dtype=float)
y = np.array(([75], [82], [93], [70]), dtype... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Last time, we trained our Neural Network, and it made suspiciously good predictions of your test score based on how many hours you slept, and ho... |
12,923 | <ASSISTANT_TASK:>
Python Code:
# Jupyter Directive
%matplotlib inline
# imports
import matplotlib
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
matplotlib.rcParams['figure.figsize'] = (20.0, 10.0) # larger figure size
# Matplotlib requires lists to plot
x = [1,2,3,4,5]
xsquared = [1,4,9,16,25... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Manual Plotting in Matplotlib
Step2: Plotting chart types
Step3: Plotting with Pandas
|
12,924 | <ASSISTANT_TASK:>
Python Code:
from pyesgf.logon import LogonManager
lm = LogonManager()
lm.logoff()
lm.is_logged_on()
OPENID = 'https://esgf-data.dkrz.de/esgf-idp/openid/USERNAME'
lm.logon_with_openid(openid=OPENID, password=None, bootstrap=True)
lm.is_logged_on()
myproxy_host = 'esgf-data.dkrz.de'
lm.logon(hostname... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: NOTE
Step2: NOTE
|
12,925 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
data_file = 'data/sms.csv'
sms = pd.read_csv(data_file, sep='\t', header=None, names=['label', 'message'])
sms.head()
tfidf = TfidfVectorizer()
matrix = tfidf.fit_transform(sms['message'])
matrix.shape
tf... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Next, let's load the data. Write the path to your sms.csv file in the cell below
Step2: Execute the cell below to load the CSV data into a pand... |
12,926 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis Engemann <denis.engemann@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import numpy as np
import mne
from mne.preprocessing import ICA
from mne.preprocessing import create_ecg_epochs, create_eog_epochs
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: Setup paths and prepare raw data.
Step2: 1) Fit ICA model using the FastICA algorithm.
Step3: 2) identify bad components by analyzing latent s... |
12,927 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_pickle('trimmed_titanic_data.pkl')
df.info()
simulation_df = df.copy()
categorical_features = ['Survived','Pclass','Sex','Embarked','Title']
for feature in categorical_features:
simulation_df[feature] = simulation_df[feature].astype('category')
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: By "cleaned" I mean I've derived titles (e.g. "Mr.", "Mrs.", "Dr.", etc) from the passenger names, imputed the missing Age values using polynomi... |
12,928 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
%matplotlib inline
# The memory consumption of different types of variables can vary significantly:
num_int = np.array(4, dtype='int8')
print("Memory (bytes) used by the int8 is: ", num_int.nbytes)
num_float = np.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Multiply these values by large matricies, and it becomes a bit more clear why some data types might be more practical than others for a given ap... |
12,929 | <ASSISTANT_TASK:>
Python Code:
#This line is very important: (It turns on the inline visuals)!
%pylab inline
#This library is one of the libraries one can use for importing tiff files.
#For detailed info:http://effbot.org/imagingbook/image.htm
from PIL import Image
#We import our cell_fluorescent.tif image
im = Image.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: <font color='brown'>Reading a multi-page tiff</font>
Step2: <font color='brown'>Reading a multi-page tiff with multiple channels</font>
Step3: ... |
12,930 | <ASSISTANT_TASK:>
Python Code:
# Let's begin by importing some libraries we'll need
import numpy as np
# And creating some random data
size = 100
np.random.seed(0)
x_data = np.arange(size)
y_data = np.cumsum(np.random.randn(size) * 100.0)
from bqplot import pyplot as plt
plt.figure(title='My First Plot')
plt.plot(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: Your First Plot
Step2: Let's plot y_data against x_data, and then show the plot.
Step3: Use the buttons above to Pan (or Zoom), Reset or save ... |
12,931 | <ASSISTANT_TASK:>
Python Code:
# Authors: Denis Engemann <denis.engemann@gmail.com>
# Eric Larson <larson.eric.d@gmail.com>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.time_frequency 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: Set parameters
Step2: We have to make sure all conditions have the same counts, as the ANOVA
Step3: Create TFR representations for all conditi... |
12,932 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function
import numpy as np
import mdtraj as md
help(md.shrake_rupley)
trajectory = md.load('ala2.h5')
sasa = md.shrake_rupley(trajectory)
print(trajectory)
print('sasa data shape', sasa.shape)
total_sasa = sasa.sum(axis=1)
print(total_sas... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: We'll use the algorithm from Shrake and Rupley for computing the SASA. Here's the function in MDTraj
Step2: The computed sasa array contains th... |
12,933 | <ASSISTANT_TASK:>
Python Code:
a = 'Pop'
%sql select * from genres where Name = :a
a = %sql select * from genres
type(a)
print(a)
import sqlite3
# Создаем БД в RAM
db=sqlite3.connect(':memory:')
# После окончания работы не забываем закрыть соединение
db.close()
# Создаем или открываем бд
db=sqlite3.connect('testdb')... | <SYSTEM_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: Создание (CREATE) и Удаление (DROP) таблиц.
Step4: Вста... |
12,934 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
from qutip.qip.device import OptPulseProcessor, LinearSpinChain
from qutip.qip.circuit import QubitCircuit
from qutip.operators import sigmaz, sigmax, identity
from qutip.tensor import tensor
from qutip.states import basis
from qutip.qobj import ptrace
basis00 = tensor(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Using the optimal control module to find the pulse
Step2: To quickly visualize the pulse, Processor has a method called plot_pulses. In the fig... |
12,935 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
import pandas as pd
from scipy import stats
from scipy import optimize
import emcee
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
clr_plt = sns.color_palette()
import models
# the true parameters
eps_true = 5e-4
t_true = 3e5
rho... | <SYSTEM_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 mathematical (deterministic, forward) model
Step2: The data
Step3: The gendata Python module is used to generate the dataset (see the note... |
12,936 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: DDSP Training
Step2: Get a batch of data
Step3: Get a distribution strategy
Step4: Get model and trainer
Step6: or gin
Step7: Train
Step8: ... |
12,937 | <ASSISTANT_TASK:>
Python Code:
# Check that imports for the rest of the file work.
import tensorflow.compat.v1 as tf
!pip install tensorflow-gan
import tensorflow_gan as tfgan
import tensorflow_datasets as tfds
import matplotlib.pyplot as plt
import numpy as np
# Allow matplotlib images to render immediately.
%matplotl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Overview
Step2: Download the data and sanity check the inputs.
Step4: Neural Network Architecture
Step5: Evaluating Generative Models, and ev... |
12,938 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
raw = pd.read_csv("datasets/jacoco_production_coverage_spring_petclinic.csv")
raw.head()
df = pd.DataFrame(index=raw.index)
df['class'] = raw['PACKAGE'] + "." + raw['CLASS']
df['lines'] = raw['LINE_MISSED'] + raw['LINE_COVERED']
df['coverage'] = raw['LINE_COVERED'] / ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's create a nice dataframe that makes this data better consumable later.
Step3: Visualization
Step4: Basics
Step5: One of the important li... |
12,939 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import graphviz
import lingam
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptions(precision=3, suppress=True)
np.random.seed(0)
def make_graph(adjacency_matrix, labels=None):
idx = np.abs(adjacen... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Utility function
Step2: Test data
Step3: Causal Discovery
Step4: Prediction Model
Step5: Identification of Feature with Greatest Causal Infl... |
12,940 | <ASSISTANT_TASK:>
Python Code:
#Kd-prime and Kd-doubleprime as expressions of Kd and alpha (cooperativity)
#as well as their concentration ratios
kd, alpha, p, l, pl, plp = symbols('K_{D} alpha [P] [L] [PL] [PLP]')
kd_p = Eq(kd / 2, p * l / pl)
kd_p
kd_pp = Eq(2 * kd / alpha, p * pl / plp)
kd_pp
l_t, p_t = symbols('[L... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Mass Balance
Step2: The mass balance equations may be combined with the equilibrium dissociation equations into a cubic form. Isolating $[P \bu... |
12,941 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nims-kma', '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... |
12,942 | <ASSISTANT_TASK:>
Python Code:
%run db2.ipynb
%%sql -q
CREATE FUNCTION SYSTOOLS.JSON_TABLE(
INJSON BLOB(16M), INELEM VARCHAR(2048), RETTYPE VARCHAR(100))
RETURNS TABLE(TYPE INTEGER, VALUE VARCHAR(2048))
LANGUAGE C
PARAMETER STYLE SQL
PARAMETER CCSID UNICODE
NO SQL
NOT FENCED
DETERMINISTIC
NO EXTERNA... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Table of Contents
Step2: Back to Top
Step3: If SYSTOOLS is not part of the path, you can update it with the following SQL.
Step4: From this p... |
12,943 | <ASSISTANT_TASK:>
Python Code:
! pip uninstall -y tensorflow
! pip install -U tf-nightly
import tensorflow as tf
tf.enable_eager_execution()
! git clone --depth 1 https://github.com/tensorflow/models
import sys
import os
if sys.version_info.major >= 3:
import pathlib
else:
import pathlib2 as pathlib
# Add `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: Train and export the model
Step2: For the example, we only trained the model for a single epoch, so it only trains to ~96% accuracy.
Step3: Us... |
12,944 | <ASSISTANT_TASK:>
Python Code:
from pytadbit import load_chromosome
crm = load_chromosome('results/crm18.tdb')
hindiii, mboi = crm.experiments
hindiii
hindiii.load_hic_data('results/HindIII/04_normalizing/100000_raw/chr18.mat')
hindiii.load_norm_data('results/HindIII/04_normalizing/100000_norm/chr18.mat')
mboi.load_hi... | <SYSTEM_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 raw data matrices, and normalized matrices
Step2: Check that the data is there
Step3: Decide which region to model.
Step4: Optimization ... |
12,945 | <ASSISTANT_TASK:>
Python Code:
# Only run this the VERY first time
!pip install metaknowledge
!pip install networkx
!pip install pandas
!pip install python-louvain
# Run this before you do anything else
import metaknowledge as mk
import networkx as nx
import pandas
import community
import webbrowser
# The line below is... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Networks
Step2: Make Network
Step3: Writing the HTML file
Step4: Display the Network
Step5: RPYS Visualization
Step6: Standard RPYS
Step7: ... |
12,946 | <ASSISTANT_TASK:>
Python Code:
import sys, os
import numpy as np
import math as math
import numpy.ma as ma
from matplotlib import cm
from matplotlib.colors import LightSource
from scipy import ndimage
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
%matplotlib inline
# import osgeo libs after 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: Define functions
Step2: Define variables for shapefiles and GeoTIFF
Step3: Import GeoTIFF
Step4: Get GeoTransformation parameters, calculate ... |
12,947 | <ASSISTANT_TASK:>
Python Code:
import helper
import problem_unittests as tests
source_path = 'data/small_vocab_en'
target_path = 'data/small_vocab_fr'
source_text = helper.load_data(source_path)
target_text = helper.load_data(target_path)
view_sentence_range = (0, 10)
import numpy as np
print('Dataset Stats')
print('R... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Explore the Data
Step3: Implement Preprocessing Function
Step4: Preprocess all the data and save it
Step5: Check Point
Step6: Check the Vers... |
12,948 | <ASSISTANT_TASK:>
Python Code:
# Run some setup code for this notebook.
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
# This is a bit of magic to make matplotlib figures appear inline in the notebook
# rather than in a new window.
%matplotlib inline
plt.rcPa... | <SYSTEM_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 would now like to classify the test data with the kNN classifier. Recall that we can break down this process into two steps
Step2: Inline Qu... |
12,949 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy.integrate import odeint
from IPython.html.widgets import interact, fixed
np.zeros?
def solve_euler(derivs, y0, x):
Solve a 1d ODE using Euler's method.
Parameters
-----... | <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: Euler's method
Step4: The midpoint method is another numerical method for solving the above differential equation. In general it is more accura... |
12,950 | <ASSISTANT_TASK:>
Python Code:
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
string1 = "hi aseem the car will be late regards company"
string2 = "hi company why will it be late I paid in advance regards aseem"
string3 = "hi aseem we don't know why will it be late regards com... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Not all words are equal
Step2: Not all unique words different
|
12,951 | <ASSISTANT_TASK:>
Python Code:
class Node (object):
def __init__ (self, data=None):
#TODO:implement me
pass
def __str__ (self):
#TODO:implement me
pass
class BinaryTree (object):
def __init__ (self):
#TODO:implement me
pass
def insert (self, newD... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unit Test
|
12,952 | <ASSISTANT_TASK:>
Python Code:
%%sh
python3 -m pip install -qU datapackage-pipelines[seedup]
%%sh
dpp version
%%writefile countries_population_flow.py
# notice that we don't import any datapackage-pipelines modules
# all the flow code is written purely with the DataFlows library
from dataflows import Flow, dump_to_pa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: This installs datapackage-pipelines with speed optimizations, if you encounter problems installing it, remove the [speedup] suffix.
Step2: Crea... |
12,953 | <ASSISTANT_TASK:>
Python Code:
documents.words()[:7]
[gram for gram in nltk.bigrams(documents.words())][:6]
[gram for gram in nltk.trigrams(documents.words())][:5]
bigram_measures = nltk.collocations.BigramAssocMeasures()
finder = nltk.collocations.BigramCollocationFinder.from_words(documents.words())
finder.nbest(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: and here are the first 6 bigrams
Step2: and the first 5 trigrams
Step3: Our task is to decide which of these N-grams are actually phrases.
Ste... |
12,954 | <ASSISTANT_TASK:>
Python Code:
files = ['clicks_2020-01-24 09:48:51_touchpad_14"_monitor.csv',
'clicks_2020-01-24 09:44:46_mouse_24"_monitor.csv',
'clicks_2020-01-23 16:00:32_mouse_24"_monitor.csv']
import csv
import numpy as np
import pandas as pd
from dataclasses import dataclass
from datetime impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Test data from the application loaded into a simple data container. One row contains the data of a click. If not changed the first file from fil... |
12,955 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import seaborn as sns
from sklearn.datasets import load_digits
digits_data = load_digits()
from IPython.display import display
display(dir(digits_data))
display(digits_data.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: We use the sklearn.datasets.load_digits method to load the MNIST data.
Step2: This dataset contains data for 1797 images. Each image is an 8*8 ... |
12,956 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import antipackage
import github.ellisonbg.misc.vizarray as va
def brownian(maxt, n):
Return one realization of a Brownian (Wiener) process with n steps and a max time of t.
t = np.linspac... | <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: Geometric Brownian motion
Step3: Call the brownian function to simulate a Wiener process with 1000 steps and max time of 1.0. Save the results ... |
12,957 | <ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
import phoebe
import numpy as np
b = phoebe.default_binary()
b.flip_constraint('mass@secondary', solve_for='q')
b.set_value(qualifier='mass', component='secondary', value=0.2)
b.set_value(qualifier='requiv', component='secondary', value=0.2)
b.set_val... | <SYSTEM_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: Let's set reasonable (although not necessarily physical) values fo... |
12,958 | <ASSISTANT_TASK:>
Python Code:
# %load example.py
def module_level_function(arg1, arg2='default', *args, **kwargs):
This function is declared in the module.
local_variable = arg1 * 2
return local_variable
class A(object):
The A class.
def __init__(self, name):
self.name = name
def get_na... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step4: The inspect module provides functions for learning about live objects, classes, instances, and methods. The functions in this module can be used... |
12,959 | <ASSISTANT_TASK:>
Python Code:
# Authors: Adonay Nunes <adonay.s.nunes@gmail.com>
# Luke Bloy <luke.bloy@gmail.com>
# License: BSD-3-Clause
import os.path as op
import mne
from mne.datasets.brainstorm import bst_auditory
from mne.io import read_raw_ctf
from mne.preprocessing import annotate_movement, compute_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: Plot continuous head position with respect to the mean recording position
Step2: Plot raw data with annotated movement
Step3: After checking t... |
12,960 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
from clipper_admin import Clipper
# Change the username if necessary
user = ""
# Set the path to the SSH key
key = ""
# Set the SSH host
host = ""
clipper = Clipper(host, user, key)
cifar_loc = ""
import cifar_utils
train_x, train_y = cifar_utils.filter_data(
*ci... | <SYSTEM_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
Step2: Train Logistic Regression Model
Step3: Deploy Logistic Regression Model
Step5: Now that you've deployed your model, go ahea... |
12,961 | <ASSISTANT_TASK:>
Python Code:
import textwrap
import time
available_clocks = [
('clock', time.clock),
('monotonic', time.monotonic),
('perf_counter', time.perf_counter),
('process_time', time.process_time),
('time', time.time),
]
for clock_name, func in available_clocks:
print(textwrap.dedent('... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Wall Clock Time
Step2: The epoch is the start of measurement for time, which for Unix systems is 0
Step3: Monotonic Clocks
Step4: Processor C... |
12,962 | <ASSISTANT_TASK:>
Python Code:
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of chars, return the first list.
Exam... | <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,963 | <ASSISTANT_TASK:>
Python Code:
def fancy_calc(a, b, c):
x1 = basic_calc(a,b)
x2 = basic_calc(b,c)
x3 = basic_calc(c,a)
z = x1 * x2 * x3
return z
def basic_calc(x, y):
result = x + y
return result
x = 1
y = 2
z = 3
result = fancy_calc(x, y, z)
print x
print z
print x1
print result
# run thi... | <SYSTEM_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) List the line numbers of the code above in the order that they will be executed. If a line will be executed more than once, list it each tim... |
12,964 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import random
import matplotlib.pyplot as plt
%matplotlib inline
from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 12, 10
np.random.seed(100)
x = np.array([i*np.pi/180 for i in range(0,360,18)])
h = lambda x: np.sin(x) + np.cos(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: In this discussion, we're going to check numerically some of the results from yesterday's lecture. Speicifically, we're going to see how bias an... |
12,965 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import mpld3
mpld3.enable_notebook()
import warnings
warnings.filterwarnings("ignore")
import numpy as N
from spectrogrism import spectrogrism as S
from spectrogrism import snifs
optcfg = snifs.SNIFS_R
print(optcfg)
simcfg = snifs.SN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the SNIFS-R channel optical configuration
Step2: Load the simulation configuration
Step3: Create a Spectrograph instance from optical con... |
12,966 | <ASSISTANT_TASK:>
Python Code:
from scipy.io import loadmat
mnist = loadmat('./datasets/mnist-original.mat')
mnist
X, y = mnist['data'], mnist['label']
X = X.T
X.shape
y = y.T
y.shape
type(y)
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
X_train, X_test, y_train, y_test = X[:60000], X[60000:], y... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Split test and training data
Step2: 3.2 Training a Random Forest Classifier for baseline
Step3: 3.3 Training a KNeighborsClassifier Classifier... |
12,967 | <ASSISTANT_TASK:>
Python Code:
name=input('请输入你的姓名,回车结束:')
print(name,'你好!')
month=int(input('请输入你的出生月份,回车结束:'))
date=int(input('请输入你的出生日期,回车结束:'))
print('你的生日是:',month,'月',date,'日')
if month == 3:
if date >= 21:
print(name,',你是白羊座。')
else:
print(name,',你是双鱼座。')
if month == 4:
if date >= 20:... | <SYSTEM_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:写程序,可由键盘读入两个整数m与n(n不等于0),询问用户意图,如果要求和则计算从m到n的和输出,如果要乘积则计算从m到n的积并输出,如果要求余数则计算m除以n的余数的值并输出,否则则计算m整除n的值并输出。
Step2: 练习 3:写程序,能够根据北京雾霾PM2.5数值给出... |
12,968 | <ASSISTANT_TASK:>
Python Code:
# Make plots appear inline (inside the Jupyter notebook).
%matplotlib inline
import datetime
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap, supported_projections
from ipywidgets import interact, interact_manual, FloatSlider
lines = supported_... | <SYSTEM_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 a list of supported projection names (no, there seems to be no single ready-made list)
Step2: Create sliders without continuous update, sin... |
12,969 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
# Set seed for reproducability
np.random.seed(42)
import matplotlib.pyplot as plt
# Supress warnings for better readability
import warnings; warnings.simplefilter('ignore')
# Load data
df = pd.read_csv('processed_bank.csv',index_col=0)
# Check that ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Decision tree
Step2: To prevent over fitting we usually need to set a maximum depth we want to allow. A common choice is 6 layers
Step3: As al... |
12,970 | <ASSISTANT_TASK:>
Python Code:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
pickle_file = 'notMNIST.pickle... | <SYSTEM_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 reload the data we generated in 1_notmnist.ipynb.
Step2: Reformat into a shape that's more adapted to the models we're going to train
Ste... |
12,971 | <ASSISTANT_TASK:>
Python Code:
########################################################
## Librerias para el trabajo
########################################################
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
data1= np.loadtxt('datos.csv',delimiter=',') #datos para regresion lineal
X1... | <SYSTEM_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- Aplique paso a paso el método de mínimos cuadrados de tal forma que le permita obtener la mejor curva lineal de ajuste de los datos anteriore... |
12,972 | <ASSISTANT_TASK:>
Python Code:
# data munging and analytical libraries
import re
import os
import numpy as np
import pandas as pd
from netCDF4 import Dataset
# graphical libraries
import matplotlib.pyplot as plt
%matplotlib inline
# set paths
outPath = "../data/globfire.csv"
driver_paths = [os.path.join(dp, f) for (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import and clean data
Step2: Define a function to extract the variable values from each netCDF4 file. Variables are flattened from a 3 dimensio... |
12,973 | <ASSISTANT_TASK:>
Python Code:
# Checking for essm version installed
import pkg_resources
pkg_resources.get_distribution("essm").version
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:150% !important; }</style>"))
from IPython.display import display
from sympy import init_printin... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: General physics variables and equations
Step2: Each of the above can also be imported one-by-one, using its Name, e.g.
Step3: Variables and eq... |
12,974 | <ASSISTANT_TASK:>
Python Code:
from pyplink import PyPlink
import zipfile
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
# Downloading the demo data from Plink webset
urlretrieve(
"http://pngu.mgh.harvard.edu/~purcell/plink/dist/hapmap_r23a.zip",
"hapmap_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Table of contents
Step2: Reading the binary file
Step3: Getting dataset information
Step4: Iterating over all markers
Step5: <a id="iteratin... |
12,975 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_blobs
X, y = make_blobs(random_state=42)
X.shape
plt.scatter(X[:, 0], X[:, 1]);
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=3, random_state=42)
labels = kmeans.fit_predict(X)
labels
all(y == labels)
plt.scatter(X[:, 0], X[:, 1], c=lab... | <SYSTEM_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 scatter plot above, we can see three separate groups of data points and we would like to recover them using clustering -- think of "disco... |
12,976 | <ASSISTANT_TASK:>
Python Code:
# Import py_entitymatching package
import py_entitymatching as em
import os
import pandas as pd
# Set the seed value
seed = 0
# Get the datasets directory
datasets_dir = em.get_install_path() + os.sep + 'datasets'
path_A = datasets_dir + os.sep + 'dblp_demo.csv'
path_B = datasets_dir + 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: Then, split the labeled data into development set and evaluation set and convert them into feature vectors
Step2: Compute accuracy of X (Decisi... |
12,977 | <ASSISTANT_TASK:>
Python Code:
ph_sel_name = "None"
data_id = "22d"
# data_id = "7d"
from fretbursts import *
init_notebook()
from IPython.display import display
data_dir = './data/singlespot/'
import os
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%s' does not exist." % data_dir... | <SYSTEM_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 software and filenames definitions
Step2: Data folder
Step3: List of data files
Step4: Data load
Step5: Load the leakage coefficient fr... |
12,978 | <ASSISTANT_TASK:>
Python Code:
import cProfile
import io
import pstats
import time
import warnings
from pstats import SortKey
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import xarray as xr
from landlab.components import FlowDirectorSteepest, NetworkSedimentTransporter
from landlab.data_recor... | <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: Part 1
Step3: Next, let's demonstrate the different sorts of grids we get with different numbers of layers. We'll look at grids with between 3 ... |
12,979 | <ASSISTANT_TASK:>
Python Code:
from tensorflow.examples.tutorials.mnist import input_data
from sklearn.datasets import fetch_mldata
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score, accuracy_score
mnist = input_data.read_data_sets("MN... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Baselines
Step2: Dense example
Step3: Sparse example
Step4: Regression example
Step5: n_features/time complexity
Step6: Logging example
Ste... |
12,980 | <ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
import pandas as pd
%matplotlib inline
from sklearn import datasets
from pandas.tools.plotting import scatter_matrix
import matplotlib.pyplot as plt
from sklearn import tree
iris = datasets.load_iris()
iris
iris.keys()
iris['target']
iris['target_names']
iris[... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 2. Redo the model with a 75% - 25% training/test split and compare the results. Are they better or worse than before? Discuss why this may be.
S... |
12,981 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from collections import Counter
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
from sklearn.neighbors import NearestCentroid
import random
import pickle
family_classification_metadata = pd.read_table('../seminar_5/data/famil... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Nearest centroid classifier
|
12,982 | <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: Quantum circuits on Pasqal devices
Step2: <img src="../../images/pasqal/Cirq_pasqal.png" width="700"/>
Step3: Create an array of qubits on a l... |
12,983 | <ASSISTANT_TASK:>
Python Code:
raw_corpus = ["Human machine interface for lab abc computer applications",
"A survey of user opinion of computer system response time",
"The EPS user interface management system",
"System and human system engineering testing of EPS",
... | <SYSTEM_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 particularly small example of a corpus for illustration purposes. Another example could be a list of all the plays written by Shakespe... |
12,984 | <ASSISTANT_TASK:>
Python Code:
# Initial import
import dcgpy
import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm
from sklearn.utils import shuffle
import timeit
%matplotlib inline
# We import the data for a classification task.
from numpy import genfromtxt
# https://archive.ics.uci.edu/ml/datasets... | <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: Data set
Step3: Encoding and training a FFNN using dCGP
Step4: Same training is done using Keras (Tensor Flow backend)
|
12,985 | <ASSISTANT_TASK:>
Python Code:
from pint import UnitRegistry
import sympy
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import sys
%matplotlib inline
from IPython.display import display
from Section import Section
ureg = UnitRegistry()
sympy.init_printing()
A, A0, t, t0, a, b, h, L, E, G =... | <SYSTEM_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 class, which contains all calculations
Step2: Initialization of sympy symbolic tool and pint for dimension analysis (not really ... |
12,986 | <ASSISTANT_TASK:>
Python Code:
!gcloud services enable ml.googleapis.com
!gcloud services enable compute.googleapis.com
BUCKET_NAME = 'your-new-bucket'
!gsutil mb gs://$BUCKET_NAME/
!mkdir census_training
!touch ./census_training/__init__.py
%%writefile ./census_training/train.py
import argparse
import pickle
impo... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Create a storage bucket
Step2: In the examples below, the BUCKET_NAME variable is referenced in the commands using $.
Step3: About the data
St... |
12,987 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
# convert to grayscale and smooth with a Gaussian
img = mpimg.imread('testimg.jpg')
gray_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
kernel_size = 5
blurred = cv2.GaussianBlur(gray_img, (kernel_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Hough transform combined with a polygonal mask
|
12,988 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from fplcplot.chromatogram import plotTraces
file_list = !ls *A.xls
file_list
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
from IPython.display import display
interact(plotTraces, file_list=fixed(file_list),
title=widgets.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Importing Excel files in current directory
Step2: To plot your figure, simply run the below cell to generate a series of iPython widgets as int... |
12,989 | <ASSISTANT_TASK:>
Python Code:
import time
import numpy as np
import tensorflow as tf
import utils
from urllib.request import urlretrieve
from os.path import isfile, isdir
from tqdm import tqdm
import zipfile
dataset_folder_path = 'data'
dataset_filename = 'text8.zip'
dataset_name = 'Text8 Dataset'
class DLProgress(tq... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load the text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ... |
12,990 | <ASSISTANT_TASK:>
Python Code:
model_def = 'example_caffe_mnist_model.prototxt'
model_weights = 'mnist.caffemodel'
net = caffe.Net(model_def, model_weights, caffe.TEST)
net.layer_dict
conv_layer = net.layer_dict['conv2d_1']
conv_layer.type, conv_layer.blobs[0].data.shape
for name, blob in net.blobs.items():
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: A Caffe net offers a layer dict that maps layer names to layer objects. These objects do not provide very much information though, but access to... |
12,991 | <ASSISTANT_TASK:>
Python Code:
# Hit shift + enter or use the run button to run this cell and see the results
print 'hello world'
# The last line of every code cell will be displayed by default,
# even if you don't print it. Run this cell to see how this works.
2 + 2 # The result of this line will not be displayed
3 +... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Nicely formatted results
Step2: Creating cells
|
12,992 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
lat=np.array([[10, 20, 30],
[20, 11, 33],
[21, 20, 10]])
lon=np.array([[100, 102, 103],
[105, 101, 102],
[100, 102, 103]])
val=np.array([[17, 2, 11],
[86, 84, 1],
[9,... | <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,993 | <ASSISTANT_TASK:>
Python Code:
import math
def nCr(n,r):
f = math.factorial
return f(n) / f(r) / f(n - r)
p, N, m, s = 0.8, 7, 4, 0
for i in range(m, N+1):
s += nCr(N, i) * p**i * (1 - p) ** (N - i)
print(s)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
def impu... | <SYSTEM_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: Напишем функцию, которая будет заменять значения NaN на медиану в каждом столбце т... |
12,994 | <ASSISTANT_TASK:>
Python Code:
cloud_name= 'apjaa4dfdt1_mrt.txt'
if not os.path.exists(cloud_name):
!wget http://iopscience.iop.org/0004-637X/834/1/57/suppdata/apjaa4dfdt1_mrt.txt
cloud_data= ascii.read(cloud_name,format='cds')
# Compute distsance and height z based on whether near of far kinematic distance is more... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: All three analytic forms capture parts of the distribution well and it's not entirely clear which would be the best fit (taking into account com... |
12,995 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-2', 'ocean')
# 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... |
12,996 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import HTML
from IPython.display import Image
import os
%pylab
%matplotlib inline
%run ../../../utils/load_notebook.py
from photometry import *
from instabilities import *
name = 'N4258'
gtype = 'SA(s)ab'
incl = 70. #(adopted by Epinat+2008)
scale = 0.092 #kpc/arcsec... | <SYSTEM_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: Данные по фотометрии
|
12,997 | <ASSISTANT_TASK:>
Python Code:
# Load pickled data
import pickle
import pandas as pd
# TODO: Fill this in based on where you saved the training and testing data
training_file = 'data/train.p'
validation_file= 'data/valid.p'
testing_file = 'data/test.p'
with open(training_file, mode='rb') as f:
train = pickle.load(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: The MNIST data that TensorFlow pre-loads comes as 28x28x1 images.
Step2: Visualize Data
Step3: Preprocess Data
Step4: Setup TensorFlow
Step5:... |
12,998 | <ASSISTANT_TASK:>
Python Code:
import arviz as az
import numpy as np
import timeit
from arviz.utils import conditional_jit, Numba
from arviz.stats.diagnostics import ks_summary
data = np.random.randn(1000000)
def variance(data, ddof=0): # Method to calculate variance without using numba
a_a, b_b = 0, 0
for i 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: That is almost 300 times faster!! Let's compare this to NumPy
Step2: In certain scenarios, Numba can even outperform NumPy!
Step3: The method... |
12,999 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import random
from IPython import display
from sklearn import datasets, preprocessing
(X, y) = datasets.make_circles(n_samples=1024, shuffle=True, noise=0.2, factor=0.4)
ind = np.logical_or(y==1, X[:,1] > X[:,0] - 0.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:
Step2: Your task starts here
Step5: The loss you should try to minimize is the Hinge Loss
Step6: Training
Step7: Implement gradient descent with mom... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.