code stringlengths 2.5k 6.36M | kind stringclasses 2
values | parsed_code stringlengths 0 404k | quality_prob float64 0 0.98 | learning_prob float64 0.03 1 |
|---|---|---|---|---|
# EA Assignment 00 - Project Definition
__Authored by: Álvaro Bartolomé del Canto (alvarobartt @ GitHub)__
---
<img src="https://media-exp1.licdn.com/dms/image/C561BAQFjp6F5hjzDhg/company-background_10000/0?e=2159024400&v=beta&t=OfpXJFCHCqdhcTu7Ud-lediwihm0cANad1Kc_8JcMpA">
## Project Overview
__The goal of the tes... | github_jupyter | # EA Assignment 00 - Project Definition
__Authored by: Álvaro Bartolomé del Canto (alvarobartt @ GitHub)__
---
<img src="https://media-exp1.licdn.com/dms/image/C561BAQFjp6F5hjzDhg/company-background_10000/0?e=2159024400&v=beta&t=OfpXJFCHCqdhcTu7Ud-lediwihm0cANad1Kc_8JcMpA">
## Project Overview
__The goal of the tes... | 0.768993 | 0.76176 |
# File Input and Output
This brief tutorial focuses on the different pyGSTi objects that can be converted to & from text files. Currently, `Model`, `DataSet`, and `MultiDataSet` objects, as well as lists and dictionaries of `Circuit` objects, can be saved to and loaded from text files. All text-based input and outpu... | github_jupyter | import pygsti
#Models ------------------------------------------------------------
model_txt = \
"""
# Example text file describing a model
# State prepared, specified as a state in the Pauli basis (I,X,Y,Z)
PREP: rho0
LiouvilleVec
1/sqrt(2) 0 0 1/sqrt(2)
POVM: Mdefault
# State measured as yes (zero) outcome, also... | 0.464659 | 0.953449 |
# Simple Demo - Reviewing WEC Laptime Data
For many forms of motorsport, timing data in the form of laptime data is often made available at the end of the race. This data can be used by fans and sports data journalists alike, as well as teams and drivers, for getting a *post hoc* insight into what actuall went on in a... | github_jupyter | #Enable inline plots
%matplotlib inline
# pandas is a python package for working with tabular datasets
import pandas as pd
# Add the parent dir to the import path
# This lets us load files in from child directories of the parent directory
# that this notebook is in.
import sys
sys.path.append("../py")
#Import content... | 0.36557 | 0.938011 |
# Name
Deploying a trained model to Cloud Machine Learning Engine
# Label
Cloud Storage, Cloud ML Engine, Kubeflow, Pipeline
# Summary
A Kubeflow Pipeline component to deploy a trained model from a Cloud Storage location to Cloud ML Engine.
# Details
## Intended use
Use the component to deploy a trained mo... | github_jupyter | %%capture --no-stderr
KFP_PACKAGE = 'https://storage.googleapis.com/ml-pipeline/release/0.1.14/kfp.tar.gz'
!pip3 install $KFP_PACKAGE --upgrade
import kfp.components as comp
mlengine_deploy_op = comp.load_component_from_url(
'https://raw.githubusercontent.com/kubeflow/pipelines/ff116b6f1a0f0cdaafb64fcd04214c1690... | 0.47244 | 0.947624 |
# RNN, GRU, LSTM
reference : https://www.youtube.com/watch?v=Gl2WXLIMvKA&list=PLhhyoLH6IjfxeoooqP9rhU3HJIAVAJ3Vz&index=5
```
import torch
import torchvision
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import DataLoader
import torchvision.datasets as datasets... | github_jupyter | import torch
import torchvision
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import DataLoader
import torchvision.datasets as datasets
import torchvision.transforms as transforms
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
input_size ... | 0.942009 | 0.938435 |
```
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
import scipy.optimize as opt
%matplotlib inline
data = pd.read_csv('C:\\Users\\Owner\\Napa\\results_model_data_8.csv')
def result_assign(win_margin):
# This function converts the win_marg... | github_jupyter | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
import scipy.optimize as opt
%matplotlib inline
data = pd.read_csv('C:\\Users\\Owner\\Napa\\results_model_data_8.csv')
def result_assign(win_margin):
# This function converts the win_margin c... | 0.825343 | 0.806472 |
```
%reset
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
# These are some parameters to make figures nice (and big)
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
plt.rcParams['figure.figsize'] = 16,8
params = {'legend.fontsize': 'x-large',
... | github_jupyter | %reset
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
# These are some parameters to make figures nice (and big)
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
plt.rcParams['figure.figsize'] = 16,8
params = {'legend.fontsize': 'x-large',
'... | 0.448426 | 0.952662 |
# Class Notes
## Helping with the Assignment 1
```
import app
person_instance = app.Person('Metin', 'Senturk', 1989)
person_instance.birth_year
person_instance.first_name
person_instance.last_name
app.find_age(person_instance.birth_year)
```
### Decorator Syntax
```
def print_my_name(name):
print('Your name is'... | github_jupyter | import app
person_instance = app.Person('Metin', 'Senturk', 1989)
person_instance.birth_year
person_instance.first_name
person_instance.last_name
app.find_age(person_instance.birth_year)
def print_my_name(name):
print('Your name is', name)
print_my_name('Metin')
Sugar syntax version
Without sugar syntax
### D... | 0.422743 | 0.704351 |
```
import numpy as np
a = np.arange(15).reshape(3,5)
print(a)
a.shape
a.size
a.dtype.itemsize
a.dtype
```
a.itemsize
###### ndarray.itemsize
the size in bytes of each element of the array. For example, an array of elements of type float64 has itemsize 8 (=64/8), while one of type complex32 has itemsize 4 (=32/8). It... | github_jupyter | import numpy as np
a = np.arange(15).reshape(3,5)
print(a)
a.shape
a.size
a.dtype.itemsize
a.dtype
a.ndim
a.data
type(a)
import numpy as np
s = np.array([2,3,4,3,22,34,56])
print(s)
type(s)
st = np.array((1,2,3,5,66,75,44))
st
type(st)
st.dtype
ss = np.arange(20, dtype=np.float32)
ss
ss.dtype #by default the numpy ... | 0.256832 | 0.938124 |
<a href="https://colab.research.google.com/github/Norod/my-colab-experiments/blob/master/EvgenyKashin_Animal_conditional_generation.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
```
%cd /content/
!mkdir pretrained
!wget 'https://github.com/Evgeny... | github_jupyter | %cd /content/
!mkdir pretrained
!wget 'https://github.com/EvgenyKashin/stylegan2/releases/download/v1.0.0/network-snapshot-005532.pkl' -O ./pretrained/network.pkl
!ls -latr ./pretrained
!mkdir animations
!apt-get install imagemagick
%cd /content/
%tensorflow_version 1.x
import tensorflow as tf
# Download the code
... | 0.333395 | 0.800458 |
# Sampling RDDs
So far we have introduced RDD creation together with some basic transformations such as `map` and `filter` and some actions such as `count`, `take`, and `collect`.
This notebook will show how to sample RDDs. Regarding transformations, `sample` will be introduced since it will be useful in many statist... | github_jupyter | from __future__ import print_function
import sys
if sys.version[0] == 3:
xrange = range
data_file = "/KDD/kddcup.data_10_percent.gz"
raw_data = sc.textFile(data_file)
raw_data_sample = raw_data.sample(False, 0.1, 1234)
sample_size = raw_data_sample.count()
total_size = raw_data.count()
print("Sample size is {} of... | 0.358016 | 0.991456 |
<div>
<img src="attachment:qgssqml2021wordmark.png"/>
</div>
In this lab, you will see how noise affects a typical parameterized quantum circuit used in machine learning using quantum process tomography.
<div class="alert alert-danger" role="alert">
For grading purposes, please specify all simulator arguments (<i>noi... | github_jupyter | # General tools
import numpy as np
import matplotlib.pyplot as plt
# Qiskit Circuit Functions
from qiskit import execute,QuantumCircuit, QuantumRegister, ClassicalRegister, Aer, transpile
import qiskit.quantum_info as qi
# Tomography functions
from qiskit.ignis.verification.tomography import process_tomography_circu... | 0.581422 | 0.990006 |
# Knihovna CtiOSDb
Nejdrive naimportujeme knihovny:
```
import os
import sys
# Moduly jsou v jinem adresari, je tedy nutne tento adresar pridat do sys.path
module_path = os.path.abspath(os.path.join('../../'))
if module_path not in sys.path:
sys.path.append(module_path)
from pywsdp.modules import CtiOS
from pyws... | github_jupyter | import os
import sys
# Moduly jsou v jinem adresari, je tedy nutne tento adresar pridat do sys.path
module_path = os.path.abspath(os.path.join('../../'))
if module_path not in sys.path:
sys.path.append(module_path)
from pywsdp.modules import CtiOS
from pywsdp import OutputFormat
import sqlite3
from shutil import ... | 0.084731 | 0.590455 |
```
!wget https://raw.githubusercontent.com/UniversalDependencies/UD_English-EWT/master/en_ewt-ud-dev.conllu
!wget https://raw.githubusercontent.com/UniversalDependencies/UD_English-EWT/master/en_ewt-ud-train.conllu
!wget https://raw.githubusercontent.com/UniversalDependencies/UD_English-EWT/master/en_ewt-ud-test.conll... | github_jupyter | !wget https://raw.githubusercontent.com/UniversalDependencies/UD_English-EWT/master/en_ewt-ud-dev.conllu
!wget https://raw.githubusercontent.com/UniversalDependencies/UD_English-EWT/master/en_ewt-ud-train.conllu
!wget https://raw.githubusercontent.com/UniversalDependencies/UD_English-EWT/master/en_ewt-ud-test.conllu
!p... | 0.342681 | 0.220217 |
# Hierarchical Partial Pooling
Suppose you are tasked with estimating baseball batting skills for several players. One such performance metric is batting average. Since players play a different number of games and bat in different positions in the order, each player has a different number of at-bats. However, you want... | github_jupyter | %matplotlib inline
import pymc3 as pm
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import theano.tensor as tt
data = pd.read_table(pm.get_data('efron-morris-75-data.tsv'), sep="\t")
at_bats, hits = data[['At-Bats', 'Hits']].values.T
N = len(hits)
with pm.Model() as baseball_model:
... | 0.389547 | 0.992626 |
# ITK in Python
### Learning Objectives
* Learn how to write simple Python code with ITK
* Become familiar with the functional and object-oriented interfaces to ITK in Python
* Understand how to bridge ITK with machine learning libraries with [NumPy](https://numpy.org/)
# Working with NumPy and friends
* ITK is gre... | github_jupyter | import itk
from itkwidgets import view
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
image = itk.imread("data/KitwareITK.jpg")
view(image, ui_collapsed=True)
array = itk.array_from_image(image)
print(array[1,1])
def make_gaussian(size, fwhm=3, center=None):
""" Make a square gaussian kern... | 0.505371 | 0.988657 |
### Get googld cloud project id
```
!gcloud config list project
```
### Set googld cloud config
```
gcloud config set compute/region $REGION
gcloud config set ai_platform/region global
```
### Create bucket
```
%%bash
if ! gsutil ls | grep -q gs://${BUCKET}; then
gsutil mb -l ${REGION} gs://${BUCKET}
fi
```
#... | github_jupyter | !gcloud config list project
gcloud config set compute/region $REGION
gcloud config set ai_platform/region global
%%bash
if ! gsutil ls | grep -q gs://${BUCKET}; then
gsutil mb -l ${REGION} gs://${BUCKET}
fi
# https://docs.python.org/ko/3/library/argparse.html
import argparse
parser = argparse.ArgumentParser()
p... | 0.325842 | 0.689698 |
```
import logging
import importlib
importlib.reload(logging) # see https://stackoverflow.com/a/21475297/1469195
log = logging.getLogger()
log.setLevel('INFO')
import sys
logging.basicConfig(format='%(asctime)s %(levelname)s : %(message)s',
level=logging.INFO, stream=sys.stdout)
%%capture
import o... | github_jupyter | import logging
import importlib
importlib.reload(logging) # see https://stackoverflow.com/a/21475297/1469195
log = logging.getLogger()
log.setLevel('INFO')
import sys
logging.basicConfig(format='%(asctime)s %(levelname)s : %(message)s',
level=logging.INFO, stream=sys.stdout)
%%capture
import os
im... | 0.451568 | 0.340506 |
# © Dr. Arkaprabha Sau
### MBBS, MD(Gold Medalist), DPH, Dip. Geriatric Medicine, PhD(Research Scholar)
## Deputy Director (Medical), Group-A Central Civil Cervices
## Directorate General of Factory Advice Service and Labour Institutes
## Ministry of labour and Employment
## Govt. of India
# Install and Import package... | github_jupyter | import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
from matplotlib.patches import PathPatch
import numpy as np
import matplotlib.cm
import matplotlib.patches as mpatches
fig, ax=plt.... | 0.302185 | 0.864597 |
<a href="https://colab.research.google.com/github/manuelP88/text_classification/blob/main/newspaper_vs_propaganda_text_classification.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
```
!pip install datasets
!pip install transformers
!pip install to... | github_jupyter | !pip install datasets
!pip install transformers
!pip install torch
import warnings
from datasets import load_dataset, DatasetDict
import pandas as pd
import torch
import torch.utils.data as torch_data
from transformers import DistilBertModel, DistilBertTokenizer, AdamW, DistilBertForSequenceClassification
from dataset... | 0.826292 | 0.781205 |
# Introduction to TensorFlow Core APIs
This a notebook following the guide https://www.tensorflow.org/guide/low_level_intro
Recall that
* computations in TensorFlows happen by executing a ``tf.Graph``,
* the graph can be defined but not necessarily run,
* run is performed via a ``tf.Session`` object.
```
from __futur... | github_jupyter | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import tensorflow as tf
t = np.asarray([0,-1, np.pi, 0.99])
c = tf.constant([[1.0, 2.0], [3.0, 4.0]])
d = tf.constant([[1.0, 1.0], [0.0, 1.0]])
e = tf.matmul(c, d)
sess = tf.compat.v1.Sessi... | 0.627267 | 0.985909 |
# Formating the Yrbss file
Small file I created to format and prepare the excel files, change the names and order of the columns, drop the empty cells and export them in csv
Needs the excel name file at **In [2]** and the csv output name at **In[33]**
```
import pandas as pd
import numpy as np
df = pd.read_excel('..... | github_jupyter | import pandas as pd
import numpy as np
df = pd.read_excel('../Dataset/yrbss_2011.xlsx')
#Raw dataframe
df.head()
df.info()
df.dropna(inplace=True)
df.head()
df.info()
# We go from 13583 observations to 11388 non-null observations
df.columns = ['age','gender','grade','height','weight','active','helmet','lifting']
df.... | 0.233269 | 0.926103 |
```
import tensorflow as tf
from tensorflow import keras
import numpy as np
keras.backend.clear_session()
np.random.seed(42)
tf.random.set_seed(42)
(train_data, train_label), (test_data, test_label) = keras.datasets.fashion_mnist.load_data()
train_data = train_data / 255
test_data = test_data / 255
l2_reg = keras.reg... | github_jupyter | import tensorflow as tf
from tensorflow import keras
import numpy as np
keras.backend.clear_session()
np.random.seed(42)
tf.random.set_seed(42)
(train_data, train_label), (test_data, test_label) = keras.datasets.fashion_mnist.load_data()
train_data = train_data / 255
test_data = test_data / 255
l2_reg = keras.regular... | 0.909406 | 0.567967 |
# STUMPY Basics
## Analyzing Motifs and Anomalies with STUMP
This tutorial utilizes the main takeaways from the research papers: [Matrix Profile I](http://www.cs.ucr.edu/~eamonn/PID4481997_extend_Matrix%20Profile_I.pdf) & [Matrix Profile II](http://www.cs.ucr.edu/~eamonn/STOMP_GPU_final_submission_camera_ready.pdf).
... | github_jupyter | %matplotlib inline
import pandas as pd
import stumpy
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as dates
from matplotlib.patches import Rectangle
import datetime as dt
plt.rcParams["figure.figsize"] = [20, 6] # width, height
plt.rcParams['xtick.direction'] = 'out'
steam_df = pd.read_... | 0.557725 | 0.991764 |
```
!pip install spacy-syllables
!python -m spacy download en_core_web_sm
!pip3 install wordfreq
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
import pandas as pd
from wordfreq import word_frequency
from scipy import stats
import csv
import spacy
from ... | github_jupyter | !pip install spacy-syllables
!python -m spacy download en_core_web_sm
!pip3 install wordfreq
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
import pandas as pd
from wordfreq import word_frequency
from scipy import stats
import csv
import spacy
from spac... | 0.877765 | 0.517571 |
# 6 - Transformers for Sentiment Analysis
In this notebook we will be using the transformer model, first introduced in [this](https://arxiv.org/abs/1706.03762) paper. Specifically, we will be using the BERT (Bidirectional Encoder Representations from Transformers) model from [this](https://arxiv.org/abs/1810.04805) pa... | github_jupyter | import torch
import random
import numpy as np
SEED = 1234
random.seed(SEED)
np.random.seed(SEED)
torch.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
!pip install transformers
from transformers import BertTokenizer
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
len(tokenizer.vocab)
t... | 0.841858 | 0.985257 |
# Parse and prepare a dataset of abc music notations
Download the [Nottingham Dataset](https://github.com/jukedeck/nottingham-dataset) or this [dataset of abc music notation from Henrik Norbeck ](http://norbeck.nu/abc/download.asp) select the 'one big zip file (549 kilobytes).' at the end of the page.
If we use the ... | github_jupyter | $ sudo apt-get install abcmidi timidity
$ brew install abcmidi timidity
X: 1
T:"Hello world in abc notation"
M:4/4
K:C
"Am" C, D, E, F,|"F" G, A, B, C|"C"D E F G|"G" A B e c
$ abc2midi hello.abc -o hello.mid && timidity hello.mid
import os
# input_folder_fp = '/home/gu-ma/Downloads/hn201809'
input_folder_fp = '/Us... | 0.240239 | 0.859664 |
# Intro
It's the last time we meet in class for exercises! And to celebrate this mile-stone, we've put together an amazing set of exercises.
* We'll start with looking at communities and their words in two exercise
- Part A1: First we finish up the work on TF-IDF from last week.
- Part A2: Second, we play around ... | github_jupyter | from IPython.display import YouTubeVideo, HTML, display
YouTubeVideo("mbQHqFnqAqw",width=800, height=450)
YouTubeVideo("JMVCVY8LB54",width=800, height=450)
from IPython.display import YouTubeVideo
YouTubeVideo("JuYcaYYlfrI",width=800, height=450)
# There's also this one from 2010
YouTubeVideo("hY0UCD5UiiY",width=800,... | 0.426799 | 0.9357 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.