Unnamed: 0 int64 0 16k | text_prompt stringlengths 110 62.1k | code_prompt stringlengths 37 152k |
|---|---|---|
6,500 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Pandas-Jupyter labor
2019. március 26.
Név (neptun)
Step1: A MovieLens adatsorral fogunk dolgozni, de először le kell töltenünk. http
Step2: Kicsomagoljuk
Step3: Adat betöltése és normali... | Python Code:
import pandas as pd # konvenció szerint pd aliast használunk
%matplotlib inline
import matplotlib
import numpy as np
# tegyük szebbé a grafikonokat
matplotlib.style.use('ggplot')
matplotlib.pyplot.rcParams['figure.figsize'] = (15, 3)
matplotlib.pyplot.rcParams['font.family'] = 'sans-serif'
Explanation: Pa... |
6,501 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Stopword Removal from Media Unit & Annotation
In this tutorial, we will show how dimensionality reduction can be applied over both the media units and the annotations of a crowdsourcing task... | Python Code:
import pandas as pd
test_data = pd.read_csv("../data/person-video-highlight.csv")
test_data["taggedinsubtitles"][0:30]
Explanation: Stopword Removal from Media Unit & Annotation
In this tutorial, we will show how dimensionality reduction can be applied over both the media units and the annotations of a cro... |
6,502 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Taken in part from the course Creative applications of deep learning with tensorflow
Regression to a noisy sine wave
L1 minimization with SGD
Linear regression iterations
Regression by a cub... | Python Code:
# imports
%matplotlib inline
# %pylab osx
import os
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
plt.style.use('ggplot')
Explanation: Taken in part from the course Creative applications of deep learning with tensor... |
6,503 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sessionize
The MADlib sessionize function performs time-oriented session reconstruction on a data set comprising a sequence of events. A defined period of inactivity indicates the end of one... | Python Code:
%load_ext sql
# %sql postgresql://gpdbchina@10.194.10.68:55000/madlib
%sql postgresql://fmcquillan@localhost:5432/madlib
%sql select madlib.version();
Explanation: Sessionize
The MADlib sessionize function performs time-oriented session reconstruction on a data set comprising a sequence of events. A define... |
6,504 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Author
Step1: First let's check if there are new or deleted files (only matching by file names).
Step2: Cool, no new nor deleted files.
Now let's set up a dataset that, for each table, lin... | Python Code:
import collections
import glob
import os
from os import path
import matplotlib_venn
import pandas as pd
rome_path = path.join(os.getenv('DATA_FOLDER'), 'rome/csv')
OLD_VERSION = '343'
NEW_VERSION = '344'
old_version_files = frozenset(glob.glob(rome_path + '/*{}*'.format(OLD_VERSION)))
new_version_files = f... |
6,505 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Statistical Thinking in Python (Part 1)
Exploratory Data Analysis
Step1: Bee Sworm plot
Step2: Empirical cumulative distribution function (ECDF)
Step3: Summary Statistics
mean - avg value... | Python Code:
# import
import pandas as pd
import numpy as np
import seaborn as sns
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
%matplotlib inline
# reading excel file
fh = pd.ExcelFile("dataset/EAVS.xlsx")
fh
print(fh.sheet_names)
data = fh.parse("SectionC")
data.head()
## Loading the IRIS d... |
6,506 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Maximizing the profit of an oil company
This tutorial includes everything you need to set up the decision optimization engines and build mathematical programming models.
When you finish this... | Python Code:
import sys
try:
import docplex.mp
except:
raise Exception('Please install docplex. See https://pypi.org/project/docplex/')
Explanation: Maximizing the profit of an oil company
This tutorial includes everything you need to set up the decision optimization engines and build mathematical programming m... |
6,507 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<center>
Go back to the Index
</center>
Chapter 1
Step1: We start by importing several classes from the skymap module and setting a few constants that we will use in this example.
Step3:... | Python Code:
# Basic notebook imports
%matplotlib inline
import matplotlib
import pylab as plt
import numpy as np
import healpy as hp
Explanation: <center>
Go back to the Index
</center>
Chapter 1: Skymap Base Class
In this chapter we introduce the skymap.Skymap base class and some of it's features.
End of explanati... |
6,508 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Benchmarking your code
Step1: Using magic functions of Jupyter and timeit
https
Step3: Exercises
What is the fastest way to download 100 pages from index.hu?
How to calculate the factors o... | Python Code:
def fun():
max(range(1000))
Explanation: Benchmarking your code
End of explanation
%%timeit
fun()
%%time
fun()
Explanation: Using magic functions of Jupyter and timeit
https://docs.python.org/3.5/library/timeit.html
https://ipython.org/ipython-doc/3/interactive/magics.html#magic-time
End of explanation... |
6,509 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
IPython.parallel
To start the cluster, you can use notebook GUI or command line $ipcluster start
Step1: Check a number of cores
Step2: Simple parallel summation
First the input array is in... | Python Code:
from IPython import parallel
c=parallel.Client()
dview=c.direct_view()
dview.block=True
Explanation: IPython.parallel
To start the cluster, you can use notebook GUI or command line $ipcluster start
End of explanation
c.ids
Explanation: Check a number of cores
End of explanation
import numpy as np
x=np.aran... |
6,510 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Toplevel
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specif... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cccr-iitm', 'sandbox-3', 'toplevel')
Explanation: ES-DOC CMIP6 Model Properties - Toplevel
MIP Era: CMIP6
Institute: CCCR-IITM
Source ID: SANDBOX-3
Sub-Topics: Radiative Forcings.
Pr... |
6,511 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Regression model—sound exposure level
This notebook explores and models the data collected from recordings of the natural acoustic environment over the urban-rural gradient near Innsbruck, A... | Python Code:
import warnings
warnings.filterwarnings('ignore')
import pandas
import numpy
from os import path
%matplotlib inline
from matplotlib import pyplot
from matplotlib.patches import Rectangle
import seaborn
from pymc3 import glm, Model, NUTS, sample, stats, \
forestplot, traceplot, plot_poster... |
6,512 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Everyone's favorite nerdy comic, XKCD, ranked colors by best tasting. I thought I would use the WTB dataset to compare and see if the data agrees.
Step1: Let's add a color column.
Step2: N... | Python Code:
# Import libraries
import numpy as np
import pandas as pd
# Import the data
import WTBLoad
wtb = WTBLoad.load_frame()
pink = ["watermelon", "cranberry"]
red = ["cherry","apple","raspberry","strawberry", "rose hips", "hibiscus",'rhubarb', "red wine"]
blue = ["blueberry","juniper berries"]
green = ["green te... |
6,513 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2018 The TensorFlow Hub Authors.
Licensed under the Apache License, Version 2.0 (the "License");
Step1: ユニバーサルセンテンスエンコーダー
<table class="tfo-notebook-buttons" align="left">
<td> ... | Python Code:
# Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless re... |
6,514 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
numbers on a plane
Numbers can be a lot more interesting than just a value if you're just willing to shift your perspective a bit.
integers
When we are dealing with integers we are dealing ... | Python Code:
def plot_rect(ax, p, fmt='b'):
x, y = p
ax.plot([0, x], [y, y], fmt) # horizontal line
ax.plot([x, x], [0, y], fmt) # vertical line
with plt.xkcd():
fig, axes = plt.subplots(1, figsize=(4, 4))
pu.setup_axes(axes, xlim=(-1, 4), ylim=(-1, 4))
for x in [1,2,3]: plot_rect(axes, (x,... |
6,515 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2021 Google LLC. All Rights Reserved.
Step1: RLDS
Step2: Import Modules
Step3: Load dataset
We can load an RLDS dataset using TFDS. See the available datasets in the TFDS catalo... | 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 writing, software
# dist... |
6,516 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Accessing Data
As pandas is built on Python, any means available in Python can be used to retrieve data from outside source. This really makes the possibility of the data that can be accesse... | Python Code:
# import pandas and numpy
import numpy as np
import pandas as pd
# set some pandas options for controlling output
pd.set_option('display.notebook_repr_html', False)
pd.set_option('display.max_columns',10)
pd.set_option('display.max_rows',10)
Explanation: Accessing Data
As pandas is built on Python, any mea... |
6,517 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
1 Finding Patterns in Text
Step1: 2 Compiling Expressions
Step2: 3 Multiple Matches
Step4: 4 Repetition
Step5: When processing a repetition instruction, re will usually consume as much o... | Python Code:
import re
pattern = 'this'
text = 'Does this text match the pattern'
match = re.search(pattern, text)
s = match.start()
e = match.end()
print('Found "{}" \n in "{}" from {} to {} ("{}")'.format(match.re.pattern,match.string, s, e, text[s:e]))
Explanation: 1 Finding Patterns in Text
End of explanation
impor... |
6,518 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Collecting and Using Data in Python
Laila A. Wahedi
Massive Data Institute Postdoctoral Fellow <br>McCourt School of Public Policy<br>
Follow along
Step1: Other Useful Packages (not used to... | Python Code:
import pandas as pd
import numpy as np
import pickle
import statsmodels.api as sm
from sklearn import cluster
import matplotlib.pyplot as plt
%matplotlib inline
from bs4 import BeautifulSoup as bs
import requests
import time
# from ggplot import *
Explanation: Collecting and Using Data in Python
Laila A. W... |
6,519 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Linear Algebra Tutorial
Based on Chapter 4 for Data Science from Scratch Book by Joel Grus with code from https
Step1: Simple vector operations
Vectors can be thought of a as representation... | Python Code:
# resources for the rest of the page
from __future__ import division # want 3 / 2 == 1.5
import re, math, random # regexes, math functions, random numbers
import matplotlib.pyplot as plt # pyplot
from collections import defaultdict, Counter
from functools import partial
Explanation: Linear Algebra Tutorial... |
6,520 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
1. Geocoding no Geopandas
O Geocoding é o processo de transformar um endereço em coordenadas geográficas (formato numérico). Em contrapartida a geocodificação reversa transforma coordenadas ... | Python Code:
# Import necessary modules
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
# Filepath
fp = r"data/roubos.csv"
# Read the data
data = pd.read_csv(fp, sep=',')
data
Explanation: 1. Geocoding no Geopandas
O Geocoding é o processo de transformar um endereço em coordenadas geográf... |
6,521 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
k-Nearest Neighbor (kNN) exercise
Complete and hand in this completed worksheet (including its outputs and any supporting code outside of the worksheet) with your assignment submission. For ... | Python Code:
%matplotlib
# 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.rcParams['... |
6,522 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
We show a CT scan and overlay the PET scan
Step1: Zoom
Zoom in by clicking the magnifying icon, or keep the alt/option key pressed. After zooming in, the higher resolution verion cutout wil... | Python Code:
full_scan = {k: v.swapaxes(0, 1)[::-1] for k,v in np.load('petct.npz').items()}
print(list(full_scan.keys()))
table_ct = cm.gray_r(np.linspace(0, 1, 255))
table_ct[:50, 3] = 0 # make the lower values transparent
table_ct[50:, 3] = np.linspace(0, 0.05, table_ct[50:].shape[0])
tf_ct = ipv.TransferFunction(rg... |
6,523 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Remap MEG channel types
In this example, MEG data are remapped from one channel type to another.
This is useful to
Step1: First, let's call remap gradiometers to magnometers, and plot
the o... | Python Code:
# Author: Mainak Jas <mainak.jas@telecom-paristech.fr>
# License: BSD-3-Clause
import mne
from mne.datasets import sample
print(__doc__)
# read the evoked
data_path = sample.data_path()
meg_path = data_path / 'MEG' / 'sample'
fname = meg_path / 'sample_audvis-ave.fif'
evoked = mne.read_evokeds(fname, condi... |
6,524 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href='http
Step1: Create some Data
Step2: Visualize Data
Step3: Creating the Clusters | Python Code:
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
Explanation: <a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>
K Means Clustering with Python
This notebook is just a code reference for the video lecture and reading.
Method Used
K Means Clustering is a... |
6,525 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2019 The TensorFlow Authors.
Step1: Mandelbrot set
<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="https
Step3: Now you'll define a function... | 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 writing, software
# dist... |
6,526 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
==============================================
Compute effect-matched-spatial filtering (EMS)
==============================================
This example computes the EMS to reconstruct the ... | Python Code:
# Author: Denis Engemann <denis.engemann@gmail.com>
# Jean-Remi King <jeanremi.king@gmail.com>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne import io, EvokedArray
from mne.datasets import sample
from mne.decoding import EMS, compute_ems
from skl... |
6,527 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Tutorial
Step1: Loading MNIST data
This little helper function loads the MNIST data available here.
Step2: Definition of the layers
So let us define the layers for the convolutional net. I... | Python Code:
import os
import matplotlib.pyplot as plt
%pylab inline
import numpy as np
from lasagne.layers import DenseLayer
from lasagne.layers import InputLayer
from lasagne.layers import DropoutLayer
from lasagne.layers import Conv2DLayer
from lasagne.layers import MaxPool2DLayer
from lasagne.nonlinearities import ... |
6,528 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Scaling analysis of Nexa on Wall Street
Here I will present a scaling analysis of Nexa wall street with regards to the number of clusters in the sensors space and the number of clusters in ... | Python Code:
import numpy as np
import h5py
from sklearn import svm, cross_validation
Explanation: Scaling analysis of Nexa on Wall Street
Here I will present a scaling analysis of Nexa wall street with regards to the number of clusters in the sensors space and the number of clusters in the data space.
Load the librar... |
6,529 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Title
Step1: Create Data
Step2: Fit Imputer
Step3: Apply Imputer
Step4: View Data | Python Code:
import pandas as pd
import numpy as np
from sklearn.preprocessing import Imputer
Explanation: Title: Impute Missing Values With Means
Slug: impute_missing_values_with_means
Summary: Impute Missing Values With Means.
Date: 2016-11-28 12:00
Category: Machine Learning
Tags: Preprocessing Structured Data... |
6,530 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Outline
Glossary
5. Imaging
Previous
Step1: Import section specific modules
Step2: 5.5 The Break Down of the Small Angle Approximation and the W-Term
Up to this point we used a resampling ... | Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
Explanation: Outline
Glossary
5. Imaging
Previous: 5.4 Imaging weights
Next: 5.5 References and further reading
Import standard modules:
End of explanation... |
6,531 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Gini coefficient
Gini coefficient is a measure of statistical dispersion. For the Kaggle competition, the normalized Gini coefficient is used as a measure of comparing how much the ordering... | Python Code:
target=array([1,4,8,5])
output=array([1,8,4,5])
Explanation: Gini coefficient
Gini coefficient is a measure of statistical dispersion. For the Kaggle competition, the normalized Gini coefficient is used as a measure of comparing how much the ordering of the model prediction matches the actual output. The... |
6,532 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Let's see if we can get Aaron's delay network to recognize two different patterns. First, let's create the patterns. For this simple test, we'll just use a 1Hz sine wave and a 0.5Hz sine w... | Python Code:
s_pattern = 2000 # number of data points in the pattern
t = np.arange(s_pattern)*0.001 # time points for the elements in the patter
pattern1 = np.sin(t*np.pi*2)
pattern2 = np.sin(0.5*t*np.pi*2)
plt.plot(t, pattern1, label='pattern1')
plt.plot(t, pattern2, label='pattern2')
plt.legend(loc='b... |
6,533 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Goal
simulating amplicon fragments for genomes in non-singleton OTUs
Setting variables
Step1: Init
Step2: gradient params
Step3: Get GC distribution info
Step4: Combining info table with... | Python Code:
import os
workDir = '/var/seq_data/ncbi_db/genome/Jan2016/ampFragsGC/'
ampFragFile = '/var/seq_data/ncbi_db/genome/Jan2016/ampFrags_KDE.pkl'
otuFile = '/var/seq_data/ncbi_db/genome/Jan2016/rnammer_aln/otusn_map_nonSingle.txt'
Explanation: Goal
simulating amplicon fragments for genomes in non-singleton OTUs... |
6,534 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<img align="right" src="../img/square_240.png" />
Exercise
Step1: 3. Program
The code is structured in three parts
Step2: Solution
Step3: The trajectory is | Python Code:
import packages.initialization
import pioneer3dx as p3dx
p3dx.init()
Explanation: <img align="right" src="../img/square_240.png" />
Exercise: Square Test.
You are going to make a program for describing a square trajectory with the robot.
Instead of starting to code from scratch, you are going to reuse the ... |
6,535 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
TB Model
We pick the following parameters
Step1: d Wave
Instantiation
Step2: Modification
Step3: MC Driver
Instantiation
Step4: Modification | Python Code:
Tc_mf = meV_to_K(0.5*250)
print meV_to_K(pi/2.0)
print 1.0/0.89
print cst.physical_constants["Boltzmann constant"]
print '$T_c^{MF} = $', Tc_mf, "K"
T_KT = meV_to_K(0.1*250)
print r"$T_{KT} = $", T_KT, "K"
Explanation: TB Model
We pick the following parameters:
+ hopping constant $ t= 250$ meV
+ $\Delta =... |
6,536 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Model16
Step1: Right, now, you can use those module.
GMM
Classifying questions
features
Step3: B. Modeling
Select model
Step4: n_iter=10 | Python Code:
from utils import load_buzz, select, write_result
from features import featurize, get_pos
from containers import Questions, Users, Categories
Explanation: Model16: Extract common functions
Now, we know what kind of common functions we need. So, I have make some functions which we used as files. So, you can... |
6,537 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Uniquely Identifying Particles With Hashes
In many cases, one can just identify particles by their position in the particle array, e.g. using sim.particles[5]. However, in cases where partic... | Python Code:
import rebound
sim = rebound.Simulation()
sim.add(m=1., hash=999)
sim.add(a=0.4, hash="mercury")
sim.add(a=1., hash="earth")
sim.add(a=5., hash="jupiter")
Explanation: Uniquely Identifying Particles With Hashes
In many cases, one can just identify particles by their position in the particle array, e.g. usi... |
6,538 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
모형 하이퍼 파라미터 튜닝
머신 러닝 모형이 완성된 후에는 성능을 향상시키기 위한 하이퍼 파라미터 최적화 등의 모형 최적화 과정을 통해 예측 성능을 향상시킨다.
Scikit-Learn 의 모형 하이퍼 파라미터 튜닝 도구
Scikit-Learn에서는 다음과 같은 모형 최적화 도구를 지원한다.
validation_curve
단일 하이퍼 파라미... | Python Code:
from sklearn.datasets import load_digits
from sklearn.svm import SVC
from sklearn.learning_curve import validation_curve
digits = load_digits()
X, y = digits.data, digits.target
param_range = np.logspace(-6, -1, 10)
%%time
train_scores, test_scores = \
validation_curve(SVC(), X, y,
... |
6,539 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Getting started with TensorFlow
Learning Objectives
1. Practice defining and performing basic operations on constant Tensors
1. Use Tensorflow's automatic differentiation capability
1.... | Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
# Ensure the right version of Tensorflow is installed.
!pip freeze | grep tensorflow==2.5
import numpy as np
from matplotlib import pyplot as plt
import tensorflow as tf
print(tf.__version__)
Explanation: Getting started with TensorFlow
Lea... |
6,540 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Filtering and resampling data
Some artifacts are restricted to certain frequencies and can therefore
be fixed by filtering. An artifact that typically affects only some
frequencies is due to... | Python Code:
import numpy as np
import mne
from mne.datasets import sample
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
proj_fname = data_path + '/MEG/sample/sample_audvis_eog_proj.fif'
tmin, tmax = 0, 20 # use the first 20s of data
# Setup for reading the raw data (save m... |
6,541 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Feature
Step1: Config
Automatically discover the paths to various data folders and compose the project structure.
Step2: Identifier for storing these features on disk and referring to them... | Python Code:
from pygoose import *
from gensim.models.wrappers.fasttext import FastText
Explanation: Feature: Word Mover's Distance
Based on the pre-trained word embeddings, we'll compute the Word Mover's Distance between each tokenized question pair.
Imports
This utility package imports numpy, pandas, matplotlib and a... |
6,542 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction
In this blog post, I want to show you how you can visualize the contributions of developers to your code base over time. I came across the Stream Graph visualization and it look... | Python Code:
PROJECT = "intellij-community"
SOURCE_CODE_FILE_EXTENSION = ".java"
TIME_FREQUENCY = "Q" # how should data be grouped? 'Q' means quarterly
FILENAME_PREFIX = "vis/interactive_streamgraph/"
FILENAME_SUFFIX = "_" + PROJECT + "_" + TIME_FREQUENCY
Explanation: Introduction
In this blog post, I want to show you ... |
6,543 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
linear algebra
Most of these notes correspond to the video lectures by Professor Gilbert Strang of MIT.
the geometry of linear equations
The fundamental problem of linear algebra is to solve... | Python Code:
f1 = lambda x: 2*x
f2 = lambda x: (1/2*x) + 1 + (1/2)
x = np.linspace(0, 3, 100)
plt.plot(x, f1(x), label=r'$y = 2x$')
plt.plot(x, f2(x), label=r'$y = \frac{1}{2}x + 1\frac{1}{2}$')
plt.legend(loc=4)
Explanation: linear algebra
Most of these notes correspond to the video lectures by Professor Gilbert Stran... |
6,544 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Table of Contents
<p><div class="lev1"><a href="#Function-Optimization"><span class="toc-item-num">1 </span>Function Optimization</a></div><div class="lev2"><a href="#scipy.optimi... | Python Code:
from IPython.display import display
import pandas as pd
# data
data = pd.DataFrame([
[10, 300],
[20, 200],
[30, 100],
[40, 400]
], columns=['QTY', 'UNIT.V'],
index=['A', 'B', 'C', 'D'])
display(data)
def gain(unit_v, qty):
return unit_v*qty*0.1
data['GAIN'] = data.apply(lamb... |
6,545 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Outline
Glossary
8. Calibration
Previous
Step1: Import section specific modules
Step2: 8.1 Calibration as a Least Squares Problem <a id='cal
Step3: We first need to set the hour angle ra... | Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
Explanation: Outline
Glossary
8. Calibration
Previous: 8. Calibration
Next: 8.2 1GC calibration
Import standard modules:
End of explanation
from scipy impo... |
6,546 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Python API for Table Display
In addition to APIs for creating and formatting BeakerX's interactive table widget, the Python runtime configures pandas to display tables with the interactive w... | Python Code:
import pandas as pd
from beakerx import *
pd.read_csv('../resources/data/interest-rates.csv')
table = TableDisplay(pd.read_csv('../resources/data/interest-rates.csv'))
table.setAlignmentProviderForColumn('m3', TableDisplayAlignmentProvider.CENTER_ALIGNMENT)
table.setRendererForColumn("y10", TableDisplayCel... |
6,547 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Algorithmic Complexity
Notes by J. S. Oishi
Step1: How long will my code take to run?
Today, we will be concerned solely with time complexity.
Formally, we want to know $T(d)$, where $d$ i... | Python Code:
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
Explanation: Algorithmic Complexity
Notes by J. S. Oishi
End of explanation
def mini(x):
n = len(x)
mini = x[0]
for i in range(n):
if x[i] < mini:
mini= x[i]
return mini
Explanation: How long will my... |
6,548 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a name="top"></a>
<div style="width
Step1: Let's Import Some Data through NOAA
Step2: Turn list of urls into one large, combined (concatenated) dataset based on time
Step3: Take a peak t... | Python Code:
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import netCDF4 as nc
from mpl_toolkits.basemap import Basemap
from datetime import datetime
from dask.diagnostics import ProgressBar
%matplotlib inline
from dask.distributed import Client
import xarray as xr
Exp... |
6,549 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Brainstorm auditory tutorial dataset
Here we compute the evoked from raw for the auditory Brainstorm
tutorial dataset. For comparison, see [1] and the associated
brainstorm site <http
Ste... | Python Code:
# Authors: Mainak Jas <mainak.jas@telecom-paristech.fr>
# Eric Larson <larson.eric.d@gmail.com>
# Jaakko Leppakangas <jaeilepp@student.jyu.fi>
#
# License: BSD (3-clause)
import os.path as op
import pandas as pd
import numpy as np
import mne
from mne import combine_evoked
from mne.minimum... |
6,550 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Title
Step1: Create Data
Step2: Calculate Pearson's Correlation Coefficient
There are a number of equivalent expression ways to calculate Pearson's correlation coefficient (also called Pea... | Python Code:
import statistics as stats
Explanation: Title: Pearson's Correlation Coefficient
Slug: pearsons_correlation_coefficient
Summary: Pearson's Correlation Coefficient in Python.
Date: 2016-02-08 12:00
Category: Statistics
Tags: Basics
Authors: Chris Albon
Based on this StackOverflow answer by cbare.
Prel... |
6,551 |
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
Problem:
plot a distribution plot using seaborn library in pyhton
| Python Code::
sns.distplot(dataset[columns], kde = False, bins = 30, color = 'red', hist_kws=dict(edgecolor="k", linewidth=1) )
|
6,552 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Let's take a look at the original images that you took
Step1: This image is not science-ready yet...
Dark image
Step2: Why is this?
Another interesting feature of CCD cameras is that the c... | Python Code:
science_image_path_g = 'data/seo_m66_g-band_180s_apagul_1.fits' #Type the path to your image
sci_g = fits.open(science_image_path_g)
sci_im_g = fits.open(science_image_path_g)[0].data
plt.imshow(sci_im_g,cmap='gray', vmax=1800, norm=matplotlib.colors.LogNorm())
plt.colorbar()
Explanation: Let's take a look... |
6,553 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<!--TITLE
Step1: Step 2 - Define Model
To illustrate the effect of augmentation, we'll just add a couple of simple transformations to the model from Tutorial 1.
Step2: Step 3 - Train and E... | Python Code:
#$HIDE_INPUT$
# Imports
import os, warnings
import matplotlib.pyplot as plt
from matplotlib import gridspec
import numpy as np
import tensorflow as tf
from tensorflow.keras.preprocessing import image_dataset_from_directory
# Reproducability
def set_seed(seed=31415):
np.random.seed(seed)
tf.random.s... |
6,554 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Digital Text Analysis
Present-day society is flooded with digital texts
Step1: Here we define a string of text by enclosing it with quotations marks and assigning it to a variable or contai... | Python Code:
text = 'It is a truth, universally acknowledged.'
Explanation: Digital Text Analysis
Present-day society is flooded with digital texts: never before, humankind has produced more text than now. To efficiently cope with the vast amounts of text that are published nowadays, industry and academia alike increas... |
6,555 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Supernova Example
Introduction
In this toy example we compare ABC and MCMC as methods of estimating cosmological parameters from supernovae data. The following model describes the distance ... | Python Code:
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
import numpy as np
from scipy.stats import skewnorm
import math
import astroabc
from distance_calc import DistanceCalc
from bin_data import *
Explanation: Supernova Example
Introduction
I... |
6,556 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Examples of pyesgf download usage
Obtain MyProxy credentials to allow downloading files
Step1: Now download a file using the ESGF wget script extracted from the server
Step2: … and the fil... | Python Code:
from pyesgf.logon import LogonManager
lm = LogonManager()
lm.logoff()
lm.is_logged_on()
myproxy_host = 'esgf-data.dkrz.de'
lm.logon(username=None, password=None, hostname=myproxy_host)
lm.is_logged_on()
Explanation: Examples of pyesgf download usage
Obtain MyProxy credentials to allow downloading files:
En... |
6,557 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction to Python Workshop Part 1
Welcome again!
We want to thank the many people that have made this workshop possible.
First, the generosity of our sponsors have provided facilities f... | Python Code:
2 + 2
1.4 + 2.25
4 - 2
2 * 3
4 / 2
0.5/2
Explanation: Introduction to Python Workshop Part 1
Welcome again!
We want to thank the many people that have made this workshop possible.
First, the generosity of our sponsors have provided facilities for the workshop, food and refreshments, and travel assistance f... |
6,558 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Neural Networks for Classification
In this project, you'll be working with one of the most well-known machine learning datasets - the Iris Data Set hosted at the UCI Machine Learning Reposit... | Python Code:
import pandas as pd
iris = pd.read_csv('data/iris.csv')
# Display the first few rows of the dataframe
iris.head()
Explanation: Neural Networks for Classification
In this project, you'll be working with one of the most well-known machine learning datasets - the Iris Data Set hosted at the UCI Machine Learni... |
6,559 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
We can find the number of decision nodes in the dBG by counting unique hashes...
Step1: We'll make a new column for total degree, for convenience.
Step2: Let's start with the overal degree... | Python Code:
k27_df.hash.nunique(), k35_df.hash.nunique()
Explanation: We can find the number of decision nodes in the dBG by counting unique hashes...
End of explanation
k35_df['degree'] = k35_df['l_degree'] + k35_df['r_degree']
k27_df['degree'] = k27_df['l_degree'] + k27_df['r_degree']
Explanation: We'll make a new c... |
6,560 | Given the following text problem statement, write Python code to implement the functionality described below in problem statement
Problem:
I have a csv file without headers which I'm importing into python using pandas. The last column is the target class, while the rest of the columns are pixel values for images. How c... | Problem:
import numpy as np
import pandas as pd
dataset = load_data()
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(dataset.iloc[:, :-1], dataset.iloc[:, -1], test_size=0.2,
random_state=42) |
6,561 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Basic Coding With SHARPpy
Written by
Step1: All of the SHARPpy routines (parcel lifting, composite indices, etc.) reside within the SHARPTAB module.
SHARPTAB contains 6 modules
Step2: Step... | Python Code:
%matplotlib inline
spc_file = open('14061619.OAX', 'r').read()
Explanation: Basic Coding With SHARPpy
Written by: Greg Blumberg (OU/CIMMS)
This IPython Notebook tutorial is meant to teach the user how to directly interact with the SHARPpy libraries using the Python interpreter. This tutorial will cover re... |
6,562 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Lists
<img src= img/aboutDataStructures.png>
Step1: Unpacking
Step2: List Comprehensions
Step3: A list comprehension consists of brackets containing an expression followed by a for clause... | Python Code:
list1 = ['apple', 'banana', 'orange']
list1
list2 = [7, 11, 13, 17, 19]
list2
list3 = ['text', 23, 66, -1, [0, 1]]
list3
empty = []
empty
list1[0]
list1[-1]
list1[-2]
'orange' in list1
'pineapple' in list1
0 in list3
0 in list3[-1]
None in empty
66 in list3
len(list2)
len(list3)
del list2[2]
list2
new_list... |
6,563 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
The seasonal cycle of surface temperature
Look at the observed seasonal cycle in the NCEP reanalysis data.
Read in the necessary data from the online server courtesy of the NOAA Physical Sci... | Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
import climlab
from climlab import constants as const
import cartopy.crs as ccrs # use cartopy to make some maps
ncep_url = "http://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis.derived/"
ncep_Ts = xr.open_data... |
6,564 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<img src="../../../images/qiskit-heading.gif" alt="Note
Step1: Step one
Step2: Let us assume that qubits qr[0] and qr[1] belong to Alice and Bob respetively.
In classical bits cr[0] and cr... | Python Code:
# useful additional packages
import numpy as np
import random
# regular expressions module
import re
# importing the QISKit
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
# import basic plot tools
from qiskit.tools.visualization import circuit_drawer, plot_histogram
Ex... |
6,565 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Tutorial em Tensorflow
Step1: Vamos usar um dataset bem simples
Step2: Antes de montar o modelo vamos definir todos os Hyper parametros
Step3: Graph e Session são duas classes centrais no... | Python Code:
import numpy as np
import tensorflow as tf
import pandas as pd
import util
%matplotlib inline
Explanation: Tutorial em Tensorflow: Regressão Linear
Nesse tutorial vamos montar um modelo de regressão linear usando a biblioteca Tensorflow.
End of explanation
# Podemos olhar o começo dessa tabela
df = pd.read... |
6,566 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Code Testing and CI
Version 0.1
The notebook contains problems about code testing and continuous integration.
E Tollerud (STScI)
Problem 1
Step1: 1b
Step2: 1d
Step3: 1e
Step4: 1f
Step5: ... | Python Code:
!conda install pytest pytest-cov
Explanation: Code Testing and CI
Version 0.1
The notebook contains problems about code testing and continuous integration.
E Tollerud (STScI)
Problem 1: Set up py.test in you repo
In this problem we'll aim to get the py.test testing framework up and running in the code repo... |
6,567 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2019 The TensorFlow Authors.
Step1: Classifying CIFAR-10 with XLA
<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="https
Step2: We define the... | 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 writing, software
# dist... |
6,568 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Experiment objects filters - the rationale
A common transformation on experiment objects are those that apply some sort of filtering of subsetting of data. A syntactic sugar API is thus prov... | Python Code:
%load_ext autoreload
%autoreload 2
#Load our data
from omicexperiment.experiment.microbiome import MicrobiomeExperiment
mapping = "example_map.tsv"
biom = "example_fungal.biom"
tax = "blast_tax_assignments.txt"
exp = MicrobiomeExperiment(biom, mapping,tax)
Explanation: Experiment objects filters - the rati... |
6,569 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
From https
Step1: There is a clear issue here that $y=x^2$ loses the negative when applied so that the result is peaks at both -2 and 2.
Try doing this again with better constraints on the... | Python Code:
xtrue = 2 # this value is unknown in the real application
x = pymc.rnormal(0, 0.01, size=10000) # initial guess
for i in range(5):
X = pymc.Normal('X', x.mean(), 1./x.var())
Y = X*X # f(x) = x*x
OBS = pymc.Normal('OBS', Y, 0.1, value=xtrue*xtrue+pym... |
6,570 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Explore ambivalent is_harassment_or_attack labels
It is incorrect to give a revision a label an attack label and a not attack label. Lets see how often this occurs and who makes this error.
... | Python Code:
df['is_harassment_or_attack'].value_counts(dropna=False)
def attack_and_not_attack(s):
return 'not_attack' in s and s!= 'not_attack'
df[df['is_harassment_or_attack'].apply(attack_and_not_attack)]['_worker_id'].value_counts().head()
Explanation: Explore ambivalent is_harassment_or_attack labels
It is in... |
6,571 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Processing Raw Text
Accessing Text from the Web and from Disk
Step1: downloading Crime and Punishment**
Step2: number of characters
Step3: Create a Text object from tokens
Step4: find co... | Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import nltk
import re
import pprint
from nltk import word_tokenize
Explanation: Processing Raw Text
Accessing Text from the Web and from Disk
End of explanation
from urllib import request
url = 'http://www.gutenberg.org/files/2554/2554.txt'
response = requ... |
6,572 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
This notebook is a brief sketch of how to use the Deutsch-Jozsa algorithm.
We start by declaring all necessary imports.
Step1: The Deutsch-Jozsa Algorithm can be used to determine if a bina... | Python Code:
from itertools import product
from mock import patch
from grove.deutsch_jozsa.deutsch_jozsa import DeutschJosza
Explanation: This notebook is a brief sketch of how to use the Deutsch-Jozsa algorithm.
We start by declaring all necessary imports.
End of explanation
bit_value = '0'
bit = ("0", "1")
constant_b... |
6,573 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
DistArray
Step1: Software Versions
Step2: Set a RandomState
Set a RandomState so random numpy arrays don't change between runs.
Step3: NumPy Arrays
DistArray is built on NumPy and provide... | Python Code:
# some utility imports
from __future__ import print_function
from pprint import pprint
from matplotlib import pyplot as plt
# main imports
import numpy
import distarray
# reduce precision on printed array values
numpy.set_printoptions(precision=2)
# display figures inline
%matplotlib inline
Explanation: Di... |
6,574 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Using Convolutional Neural Networks
Welcome to the first week of the first deep learning certificate! We're going to use convolutional neural networks (CNNs) to allow our computer to see - s... | Python Code:
%matplotlib inline
Explanation: Using Convolutional Neural Networks
Welcome to the first week of the first deep learning certificate! We're going to use convolutional neural networks (CNNs) to allow our computer to see - something that is only possible thanks to deep learning.
Introduction to this week's t... |
6,575 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
SciPy 2016 Scikit-learn Tutorial
Training and Testing Data
To evaluate how well our supervised models generalize, we can split our data into a training and a test set
Step1: Thinking about ... | Python Code:
from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier
iris = load_iris()
X, y = iris.data, iris.target
classifier = KNeighborsClassifier()
Explanation: SciPy 2016 Scikit-learn Tutorial
Training and Testing Data
To evaluate how well our supervised models generalize, we ca... |
6,576 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href="https
Step1: Creating and filling arrays
Matrix filled with zeros.
Step2: Vector filled with random number.
Step3: Matrix filled with constant.
Step4: Identity matrix.
Step5: C... | Python Code:
import numpy as np
Explanation: <a href="https://colab.research.google.com/github/OSGeoLabBp/tutorials/blob/master/english/python/numpy_tutor.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
Numpy in a Nutshell
Numpy is a very popular Pyt... |
6,577 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Name
Submitting a Cloud Machine Learning Engine training job as a pipeline step
Label
GCP, Cloud ML Engine, Machine Learning, pipeline, component, Kubeflow, Kubeflow Pipeline
Summary
A Kubef... | Python Code:
%%capture --no-stderr
KFP_PACKAGE = 'https://storage.googleapis.com/ml-pipeline/release/0.1.14/kfp.tar.gz'
!pip3 install $KFP_PACKAGE --upgrade
Explanation: Name
Submitting a Cloud Machine Learning Engine training job as a pipeline step
Label
GCP, Cloud ML Engine, Machine Learning, pipeline, component, Kub... |
6,578 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Basic PowerShell Execution
Metadata
| | |
|
Step1: Download & Process Mordor Dataset
Step2: Analytic I
Within the classic PowerShell log, event ID 400 indicates when a... | Python Code:
from openhunt.mordorutils import *
spark = get_spark()
Explanation: Basic PowerShell Execution
Metadata
| | |
|:------------------|:---|
| collaborators | ['@Cyb3rWard0g', '@Cyb3rPandaH'] |
| creation date | 2019/04/10 |
| modification date | 2020/09/20 |
| playbook related | ... |
6,579 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Now it's your turn to test your new knowledge of missing values handling. You'll probably find it makes a big difference.
Setup
The questions will give you feedback on your work. Run the fol... | Python Code:
# Set up code checking
import os
if not os.path.exists("../input/train.csv"):
os.symlink("../input/home-data-for-ml-course/train.csv", "../input/train.csv")
os.symlink("../input/home-data-for-ml-course/test.csv", "../input/test.csv")
from learntools.core import binder
binder.bind(globals())
from... |
6,580 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<table width="100%" border="0">
<tr>
<td><img src="./images/ing.png" alt="" align="left" /></td>
<td><img src="./images/ucv.png" alt="" align="center" height="100" width="100" /></... | Python Code:
# ¿qué hace esta línea? La respuesta mas adelante
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.display import Image
Explanation: <table width="100%" border="0">
<tr>
<td><img src="./images/ing.png" alt="" align="left" /></td>
<td><img src="./images/ucv.png" alt="" align="center... |
6,581 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
LeNet Lab Solution
Source
Step1: The MNIST data that TensorFlow pre-loads comes as 28x28x1 images.
However, the LeNet architecture only accepts 32x32xC images, where C is the number of colo... | Python Code:
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("./MNIST_data/", reshape=False)
X_train, y_train = mnist.train.images, mnist.train.labels
X_validation, y_validation = mnist.validation.images, mnist.validation.labels
X_test, y_test = mnist.t... |
6,582 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Installation Instructions
Download and install miniconda
Step1: Parameters to change for the run
Step2: Download files
Step3: Use the data to generate a GSSHA model | Python Code:
from datetime import datetime, timedelta
import os
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
from gsshapy.modeling import GSSHAModel
Explanation: Installation Instructions
Download and install miniconda: https://conda.io/miniconda.html
Make sure... |
6,583 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Using find_MAP on models with discrete variables
Maximum a posterior(MAP) estimation, can be difficult in models which have discrete stochastic variables. Here we demonstrate the problem wit... | Python Code:
import pymc3 as mc
Explanation: Using find_MAP on models with discrete variables
Maximum a posterior(MAP) estimation, can be difficult in models which have discrete stochastic variables. Here we demonstrate the problem with a simple model, and present a few possible work arounds.
End of explanation
alpha =... |
6,584 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
GA4GH 1000 Genomes Reference Service Example
This example illustrates how to access the available reference sequences offered by a GA4GH instance.
Initialize the client
In this step we crea... | Python Code:
import ga4gh_client.client as client
c = client.HttpClient("http://1kgenomes.ga4gh.org")
Explanation: GA4GH 1000 Genomes Reference Service Example
This example illustrates how to access the available reference sequences offered by a GA4GH instance.
Initialize the client
In this step we create a client obj... |
6,585 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Exercises
Timothy Helton
<br>
<font color="red">
NOTE
Step1: Data Prep
Step2: 1. What was the average age in male and female athletes?
Step3: 2. What are the most common Dates of Birt... | Python Code:
from k2datascience import olympics
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline
Explanation: Exercises
Timothy Helton
<br>
<font color="red">
NOTE:
<br>
This notebook uses code found in the
<a href="https://git... |
6,586 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Regression
In regression we try to predict a continuous output variable. This can be most easily visualized in one dimension.
We will start with a very simple toy example. We will create a d... | Python Code:
x = np.linspace(-3, 3, 100)
print(x)
y = np.sin(4 * x) + x + np.random.uniform(size=len(x))
plt.plot(x, y, 'o')
Explanation: Regression
In regression we try to predict a continuous output variable. This can be most easily visualized in one dimension.
We will start with a very simple toy example. We will cr... |
6,587 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Numbers of Patients Registered at a GP Practice
21/2/17
Number of patients registred with a particular GP who live in a particular LSOA (/via Carl Baker, HoC Library)
Demo sketch of opening ... | Python Code:
#Original data source
#http:§§//www.content.digital.nhs.uk/catalogue/PUB23139
#Get the datafile
!wget -P data http://www.content.digital.nhs.uk/catalogue/PUB23139/gp-reg-patients-LSOA-alt-tall.csv
#Import best ever data handling package
import pandas as pd
#Load downloaded CSV file
df=pd.read_csv('data/gp-... |
6,588 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Train ML model on Cloud AI Platform
This notebook shows how to
Step1: Try out model file
<b>Note</b> Once the training starts, Interrupt the Kernel (from the notebook ribbon bar above). Bec... | Python Code:
import logging
import nbformat
import sys
import yaml
def write_parameters(cell_source, params_yaml, outfp):
with open(params_yaml, 'r') as ifp:
y = yaml.safe_load(ifp)
# print out all the lines in notebook
write_code(cell_source, 'PARAMS from notebook', outfp)
# print o... |
6,589 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
WDigest Downgrade
Metadata
| | |
|
Step1: Download & Process Mordor Dataset
Step2: Analytic I
Look for any process updating UseLogonCredential registry key value
| Dat... | Python Code:
from openhunt.mordorutils import *
spark = get_spark()
Explanation: WDigest Downgrade
Metadata
| | |
|:------------------|:---|
| collaborators | ['@Cyb3rWard0g', '@Cyb3rPandaH'] |
| creation date | 2019/05/10 |
| modification date | 2020/09/20 |
| playbook related | [] |
Hypo... |
6,590 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Numpy Exercise 2
Imports
Step2: Factorial
Write a function that computes the factorial of small numbers using np.arange and np.cumprod.
Step4: Write a function that computes the factorial ... | Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
Explanation: Numpy Exercise 2
Imports
End of explanation
n=10
a=np.arange(1,n+1,1)
a.cumprod()
def np_fact(n):
Compute n! = n*(n-1)*...*1 using Numpy.
if n==0: #0! is 1
return 1
elif n==1: #1! is... |
6,591 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: TV Script Generation
In this project, you'll generate your own Simpsons TV scripts using RNNs. You'll be using part of the Simpsons dataset of scripts from 27 seasons. The Neural Ne... | Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
Explanation: TV Script Generation
In this project, you'll generate your own Simpsons TV script... |
6,592 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ChemSpiPy
Step1: Then connect to ChemSpider by creating a ChemSpider instance using your security token
Step2: All your interaction with the ChemSpider database should now happen through t... | Python Code:
from chemspipy import ChemSpider
Explanation: ChemSpiPy: Getting Started
Before we start:
Make sure you have installed ChemSpiPy.
Obtain a security token from the ChemSpider web site.
First Steps
Start by importing ChemSpider:
End of explanation
# Tip: Store your security token as an environment variable t... |
6,593 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Smith Sphere
The smith chart is a nomogram used frequently in RF/Microwave Engineering. Since its inception it has been recognised that projecting the chart onto the reimen sphere [1].
[1]H.... | Python Code:
#from IPython.display import SVG
#SVG('pics/smith_sphere.svg')
from galgebra.printer import Format, Fmt
from galgebra import ga
from galgebra.ga import Ga
from sympy import *
Format()
(o3d,er,ex,es) = Ga.build('e_r e_x e_s',g=[1,1,1])
(o2d,zr,zx) = Ga.build('z_r z_x',g=[1,1])
Bz = er^ex # impedance plance ... |
6,594 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
1. Import the necessary packages to read in the data, plot, and create a linear regression model
Step1: 2. Read in the hanford.csv file
Step2: <img src="images/hanford_variables.png">
3. C... | Python Code:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
Explanation: 1. Import the necessary packages to read in the data, plot, and create a linear regression model
End of explanation
df = pd.read_csv("hanford.csv")
df.head()
Explanation: 2. Read in the... |
6,595 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
A Marte con Python usando poliastro
<img src="http
Step1: Primero
Step2: Segundo
Step3: Tercero
Step5: ...y es Python puro!
Truco
Step6: Quinto | Python Code:
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import astropy.units as u
from astropy import time
from poliastro import iod
from poliastro.plotting import plot
from poliastro.bodies import Sun, Earth
from poliastro.twobody import State
from p... |
6,596 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Exploring Label Relations
Multi-label classification tends to have problems with overfitting and underfitting classifiers when the label space is large, especially in problem transformation ... | Python Code:
from skmultilearn.dataset import load_dataset
X_train, y_train, feature_names, label_names = load_dataset('emotions', 'train')
X_test, y_test, _, _ = load_dataset('emotions', 'test')
Explanation: Exploring Label Relations
Multi-label classification tends to have problems with overfitting and underfitting c... |
6,597 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction
Problem Description
Data-driven approaches are now used in many fields from business to science. Since data storage and computational power has become cheap, machine learning ha... | Python Code:
from itertools import combinations
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
from sklearn.model_selection import train_test_split, KFold, GridSearchCV
from sklearn.metrics import r2_score
from sklearn.linear_model import LinearRegression
# Startup settings can not suppress a war... |
6,598 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
2018-11-24 02
Step1: let's say for a hypothetical network with 3 layer groups (conv_group_1, conv_group_2, linear_group).
Step2: Interesting, so if you have multiple trainable layer groups... | Python Code:
import numpy as np
# from fastai.core
def even_mults(start:float, stop:float, n:int)->np.ndarray:
"Build evenly stepped schedule from `star` to `stop` in `n` steps."
mult = stop/start
step = mult**(1/(n-1))
return np.array([start*(step**i) for i in range(n)])
Explanation: 2018-11-24 02:12:2... |
6,599 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Land
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify do... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-1', 'land')
Explanation: ES-DOC CMIP6 Model Properties - Land
MIP Era: CMIP6
Institute: NCAR
Source ID: SANDBOX-1
Topic: Land
Sub-Topics: Soil, Snow, Vegetation, Energ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.