markdown stringlengths 0 1.02M | code stringlengths 0 832k | output stringlengths 0 1.02M | license stringlengths 3 36 | path stringlengths 6 265 | repo_name stringlengths 6 127 |
|---|---|---|---|---|---|
As before we can access the attributes of the instance of the class by using the dot notation: | SkinnyBlueRectangle.height
SkinnyBlueRectangle.width
SkinnyBlueRectangle.color | _____no_output_____ | MIT | Basics of Python/Notebooks/Python_Objects_and_Classes.ipynb | VNSST/Hands_on_Machine_Learning_using_Python |
We can draw the object: | SkinnyBlueRectangle.drawRectangle() | _____no_output_____ | MIT | Basics of Python/Notebooks/Python_Objects_and_Classes.ipynb | VNSST/Hands_on_Machine_Learning_using_Python |
Let’s create the object “FatYellowRectangle” of type Rectangle : | FatYellowRectangle = Rectangle(20,5,'yellow') | _____no_output_____ | MIT | Basics of Python/Notebooks/Python_Objects_and_Classes.ipynb | VNSST/Hands_on_Machine_Learning_using_Python |
We can access the attributes of the instance of the class by using the dot notation: | FatYellowRectangle.height
FatYellowRectangle.width
FatYellowRectangle.color | _____no_output_____ | MIT | Basics of Python/Notebooks/Python_Objects_and_Classes.ipynb | VNSST/Hands_on_Machine_Learning_using_Python |
We can draw the object: | FatYellowRectangle.drawRectangle() | _____no_output_____ | MIT | Basics of Python/Notebooks/Python_Objects_and_Classes.ipynb | VNSST/Hands_on_Machine_Learning_using_Python |
Pytorch Rals-C-SAGAN* Ra - Relativistic Average;* Ls - Least Squares;* C - Conditional;* SA - Self-Attention;* DCGAN - Deep Convolutional Generative Adversarial NetworkReferences:* https://www.kaggle.com/speedwagon/ralsgan-dogs* https://www.kaggle.com/cdeotte/dog-breed-cgan* https://github.com/eriklindernoren/PyTorch-... | loss_calculation = 'hinge'
# loss_calculation = 'rals'
batch_size = 32
crop_dog = True #犬のアノテーションを使用するかどうか
noisy_label = True #ラベルスムージング的な
R_uni = (0.70, 0.95) #ラベルスムージングするときのrealの範囲
F_uni = (0.05, 0.15) #ラベルスムージングするときのfakeの範囲
Gcbn = False # generatorにConditionalBatchNorm2dを使うかどうか
Glrelu = True # generatorにLeakyLeLUを使う... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Helper Blocks | import math
import torch
from torch.optim import Optimizer
class AdaBound(Optimizer):
"""Implements AdaBound algorithm.
It has been proposed in `Adaptive Gradient Methods with Dynamic Bound of Learning Rate`_.
Arguments:
params (iterable): iterable of parameters to optimize or dicts defining
... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Generator and Discriminator | class UpConvBlock(nn.Module):
"""
n_cl クラス数(120),
k_s=カーネルサイズ(4),
stride=stride(2),
padding=padding(0),
bias=バイアス入れるかどうか(False),
dropout_p=dropout_p(0.0),
use_cbn=Conditional Batch Normalization使うかどうか(True)
Lrelu=LeakyReLU使うかどうか(True)(FalseはReLU)
slope=Lreluのslope(0.05)
"... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Data loader | class DataGenerator(Dataset):
def __init__(self, directory, transform=None, n_samples=np.inf, crop_dogs=True):
self.directory = directory
self.transform = transform
self.n_samples = n_samples
self.samples, self.labels = self.load_dogs_data(directory, crop_dogs)
def load_... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Training Parameters | database = '../input/all-dogs/all-dogs/'
crop_dogs = crop_dog
n_samples = np.inf
BATCH_SIZE = batch_size
epochs = n_epochs
use_soft_noisy_labels=noisy_label #ラベルスムージングするかどうか
loss_calc = loss_calculation
nz = 128
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
transform = transforms.Compose([t... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Training loop | d_loss_log = []
g_loss_log = []
dout_real_log = []
dout_fake_log = []
dout_fake_log2 = []
iter_n = len(train_loader) - 1 #最後の余ったバッチは計算されないから-1
for epoch in range(epochs):
epoch_g_loss = 0.0 # epochの損失和
epoch_d_loss = 0.0 # epochの損失和
epoch_dout_real = 0.0
epoch_dout_fake = 0.0
epoch_dout_fak... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Visualise generated results by label and submit | good_breeds = analyse_generated_by_class(6)
create_submit(good_breeds)
import matplotlib.pyplot as plt
plt.figure()
plt.title("Learning Curve")
plt.xlabel("epoch")
plt.ylabel("loss")
# Traing score と Test score をプロット
plt.plot(d_loss_log, color="r", label="d_loss")
plt.plot(g_loss_log, color="g", label="g_loss")
... | _____no_output_____ | MIT | nb/base_gan.ipynb | raxman0721/kaggle-dog_gan |
Data Analysis for Data Analyst Job Landscape 2020 GoalThere were 2 main motivations for me to do this project,* (1) Understand the current job market for data centric jobs* (2) Find out the what employers are looking for in data centric jobs BackgroundThe project data analysis occurs in the 3rd section: Exploratory ... | from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
1. PackagesThere are various data analysis packages within Python that I'll be using for my anaysis | """Data Science Packages"""
import pandas as pd
import numpy as np
from scipy.stats import norm
from pandas import DataFrame
"""Data Visualisation Packages"""
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
from matplotlib import pyplot
from matplotli... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
2. Reading DatasetsAfter performing the Data Cleaning in Part 2, I'm using my clean dataset in this data analysis portion. | print("---------------------- Job Dataset --------------------------")
df = pd.read_excel(
'/Users/james/Documents/GitHub/Exploring-the-Big-Data-and-Analytics-Job-Market-in-Singapore-2020/Job Titles CSV Files/Job_dataset.xlsx')
df.head()
# Lisiting all the columns that are in the csv file
df.columns
print("--------... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
3. Exploratory Analysis 3.1 One Important Caveat An Important Caveat I would like to make which I believe is important to address before I begin my Exploratory Analysis is how representative the salary statistics I gathered is. As I have outputted in Section 2, it can be seen that the number of respondents for the Gl... | sns.set(style="whitegrid")
fig = sns.catplot(x="Job Title", y="Average Base Pay", hue="Position Level", data=salary_df,
kind="bar", palette="muted", aspect=8/3)
fig.despine(left=True)
fig.set_ylabels("Average Base Pay")
fig.set(title="Pay Comparison for Various Job Titles")
fig.savefig("Average Base ... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** The salary plot allows us to see that the best paid position is as a Quantitative Analyst, followed closely by the Senior Data Scientist and Senior Technology Consultant. For fresh graduates, the expected pay for the Data Scientist/Engineer/Analyst role is **S\\$ 50666 /year or S\\$ 4222 /month**. 3.3 Nu... | df_jobs_available = df['Job Title'].value_counts().rename_axis(
'Job Title').reset_index(name='Number of Jobs')
sns.set(style="whitegrid")
sns_plot = sns.barplot(x="Job Title", y="Number of Jobs", data=df_jobs_available).set_title(
'Number of Jobs listed on Glassdoor')
sns.set(rc={'figure.figsize': (16, 8)})
sn... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** We found that the Data Scientist job title has the most number of jobs available by a large margin with 925 jobs. Followed by Data Analyst and Data Engineer with 477 and 440 jobs postings respectively. Surprisingly, there were more managerial positions for the Data Driven jobs compared to machine learning... | # Creating dictionary counting the number of times a particular technical skill is called
technical_skills = ['AWS', 'Excel', 'Python',
'R', 'Spark', 'Hadoop', 'Scala', 'SQL']
adict = {}
for every_skill in technical_skills:
that_sum = df[every_skill].sum()
adict[every_skill] = that_sum
prin... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** As I expected Python was the most requested skillset that employer wanted prospective hires to have, it's closely followed by SQL. Big data platforms such as Apache Spark and Hadoop alongside Scala are relatively high in demand as well. I was very surprise to see that R was not highly requested in the tec... | # Creating dictionary counting the number of times a particular academic skill is called
academic_skills = ['Calculus', 'Database Management',
'Machine Learning', 'Statistics', 'DevOps']
adict1 = {}
for every_skill in academic_skills:
that_sum = df[every_skill].sum()
adict1[every_skill] = tha... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** Unsurprinsingly, the top academic skill set looked for by employers is Machine Learning with predictive analysis. However other academic skills sets such as DevOps, Statistics and Database Management is actually rarely mention, and Calculus was not mention at all. I postulate that many employers believe ... | df.columns
df.rename({"Bachelors Degreee" : "Bachelors Degree"}, axis=1)
# Creating dictionary counting the number of times a particular Education Level is called
education_level = ['Bachelors Degreee', 'Masters','PhD', 'No Education Specified']
adict2 = {}
for every_level in education_level:
that_sum = df[every_le... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** I found that most jobs posting for data-driven jobs look for hires with Bachelors Degree. However, it can be noted that there's a sizeable numbers of employers looking for masters and PhD level of qualification. There's a sizeable portion of employers who do not specify university level of qualification ... | # We drop the rows with null values and count the number of jobs by type of ownership
df_ownership = df[df['Type of ownership'] != '-1']
df_ownership = df_ownership['Type of ownership'].value_counts(
).rename_axis('Ownership').reset_index(name='Number of Jobs')
# Specific number of jobs by the different ownership
df_ow... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** We found that by ownership, the biggest hire of data driven jobs is the private sector. Followed by public companies and government firms. This is not surprising that private and public company are the biggest players, as they are profit driven and would want to capitalise on new technology and skill set ... | # We drop the rows with null values and count the number of jobs by industry
df_industry = df[df['Industry'] != '-1']
df_industry = df_industry['Industry'].value_counts().rename_axis(
'Industry').reset_index(name='Number of Jobs')
# Specific number of jobs by the different industry
df_industry["Relative Frequency, ... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** I was surprised to find that Government Agencies was the largest employer of the data driven jobs. The second largest employer by Industry is unsurprisingly is the Internet(Technology) Industry. Other surprising results was the Banking and Asset Management Industry. 3.9 Rating DistributionWe want to inve... | # Removing null value for ratings
df_rating = df[df['Rating'] != -1]
sns.set(style="whitegrid")
n, bins, patches = plt.hist(x=df_rating['Rating'], bins='auto',
alpha=0.7, rwidth=0.85)
plt.xlabel('Company Ratings')
plt.ylabel('Frequency')
plt.title('Distribution of Company Ratings')
# Set a ... | _____no_output_____ | MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
**Findings:** We find that the average company rating in the technology sector is around 3.75/5. Word Cloud in Job DescriptionWe want to visualise what are the words that are most frequently repeated in the job description, we use a word cloud algorithm to represent the results below. | nltk.download('stopwords')
nltk.download('punkt')
words = " ".join(df['Job Description'])
def punctuation_stop(text):
"""remove punctuation and stop words"""
filtered = []
stop_words = set(stopwords.words('english'))
word_tokens = word_tokenize(text)
for w in word_tokens:
if w not in stop... | [nltk_data] Downloading package stopwords to /Users/james/nltk_data...
[nltk_data] Package stopwords is already up-to-date!
[nltk_data] Downloading package punkt to /Users/james/nltk_data...
[nltk_data] Package punkt is already up-to-date!
| MIT | Part 3. Data Analysis.ipynb | jamesgsw/Exploring-Data-and-Analytics-Job-Market-Outlook-in-Singapore-2020 |
Part 2 | def dist(A, B):
"""Taxi-driver distance"""
return abs(B[0] - A[0]) + abs(B[1] - A[1])
def move_hole(hole, G, node_grid):
Gx, Gy = G.coord
target = (Gx-1, Gy)
while hole.coord != target:
if hole.coord[0] >= Gx and hole.coord[1] > Gy:
hole = node_grid[hole.coord[0]-1... | _____no_output_____ | MIT | aoc-2016/22/22.ipynb | bsamseth/advent-of-code-2018 |
Reporting using Jupyter Book [Jupyter Book](https://jupyterbook.org/intro.html) is an open source project for building beautiful, publication-quality books and documents from computational material.In our case it will help us to export our Jupyter Notebooks into nice to look at HTML files. Installation- **If you're r... | !jupyter-book create ../reports/jupyterbook | _____no_output_____ | MIT | 06-2021-05-28/notebooks/06-01_Reporting_using_jupyterbook.ipynb | eotp/python-FU-class |
- Before we take a look at the generated files, lets copy over the jupyter notebooks we want to include in our HTML report Task:- Copy `06-00_Processing_of_Tabular_Data.ipynb` and `06-00_Temperature_anomalies.ipynb` into `../reports/jupyterbook`> Hint: you don't have to leave the Jupyter Universe to do that. Just open ... | # alternatively use this snippet to copy the desired files
!cp 06-00_Processing_of_Tabular_Data.ipynb 06-00_Temperature_anomalies.ipynb ../reports/jupyterbook/ | _____no_output_____ | MIT | 06-2021-05-28/notebooks/06-01_Reporting_using_jupyterbook.ipynb | eotp/python-FU-class |
- Now let us take a look at the files File inspection We need to change the content of two files for everything to run smoothly _config.yml- Stores configuration parameters such as the Title, Author and execution behaviour- You can change `title` and `author` to whatever you like- The **only parameter we need to chan... | !jupyter-book build ../reports/jupyterbook | _____no_output_____ | MIT | 06-2021-05-28/notebooks/06-01_Reporting_using_jupyterbook.ipynb | eotp/python-FU-class |
Safety Net- Make sure you specify the `_toc.yml` and `_config.yml` files as specified above- If it should still fail for you, try running this: | !rm -rf ../reports/jupyterbook
!jupyter-book create ../reports/jupyterbook
!cp 06-00_Processing_of_Tabular_Data.ipynb 06-00_Temperature_anomalies.ipynb ../reports/jupyterbook/
!cp ../src/_solutions/_toc.yml ../src/_solutions/_config.yml ../reports/jupyterbook/
!jupyter-book build ../reports/jupyterbook | _____no_output_____ | MIT | 06-2021-05-28/notebooks/06-01_Reporting_using_jupyterbook.ipynb | eotp/python-FU-class |
Update Logv14 : Added some new features , now local CV has climed to 0.87 just with Meta-Features and can climb even more , this is the first notebook exploring high end score with just the metafeatures.I have also removed the embedding layer because the model performs better without itv15 : Inference added About thi... | from IPython.display import IFrame, YouTubeVideo
YouTubeVideo('ysBaZO8YmX8',width=600, height=400) | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
If you want to do it the scikit learn way here is a [notebook](https://www.kaggle.com/tanulsingh077/achieving-sota-results-with-tabnet) where I explain how to that | #Installing Pytorch-Tabnet
#!pip install pytorch-tabnet
import numpy as np
import pandas as pd
import random
import os
import seaborn as sns
from tqdm.autonotebook import tqdm
from fastprogress import master_bar, progress_bar
tqdm.pandas()
from scipy.stats import skew
import pickle
import glob
#Visuals
import matplot... | /usr/local/lib/python3.6/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
import pandas.util.testing as tm
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:6: TqdmExperimentalWarning: Using `tqd... | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
UtilsSince we are writing our custom model , we need early stopping which is present in Pytorch-Tabnet's implementation as a built-in.The following Early-Stopping Implementation can monitor both minimization and maximization of quantities | class EarlyStopping:
def __init__(self, patience=7, mode="max", delta=0.001,verbose=True):
self.patience = patience
self.counter = 0
self.mode = mode
self.best_score = None
self.early_stop = False
self.delta = delta
self.verbose = verbose
if self.mode ... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
ConfigurationWe define all the configuration needed elsewhere in the notebook here | BATCH_SIZE = 1024
EPOCHS = 150
LR = 0.02
seed = 2020 # seed for reproducible results
patience = 50
device = torch.device('cuda')
FOLDS = 5 | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
Seed | def seed_everything(seed):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = False
torch.backends.cudnn.benchmark = True
seed_everything(seed) | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
Data Preparation and Feature EngineeringHere we input the data and prepare it for inputting to the model | # Defining Categorical variables and their Indexes, embedding dimensions , number of classes each have
df =pd.read_csv('/data/full/folds_13062020.csv')
df.head()
# df = pd.concat([df, pd.get_dummies(df.source)], axis=1)
# df = pd.concat([df, pd.get_dummies(df.anatom_site_general_challenge)], axis=1)
# df.head()
# df... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
ModelHere we built our Custom Tabnet model | class CustomTabnet(nn.Module):
def __init__(self, input_dim, output_dim,n_d=8, n_a=8,n_steps=3, gamma=1.3,
cat_idxs=[], cat_dims=[], cat_emb_dim=1,n_independent=2, n_shared=2,
momentum=0.02,mask_type="sparsemax"):
super(CustomTabnet, self).__init__()
self.tab... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
LossDefining SoftMarginFocal Loss which is to be used as a criterion | class SoftMarginFocalLoss(nn.Module):
def __init__(self, margin=0.2, gamma=2):
super(SoftMarginFocalLoss, self).__init__()
self.gamma = gamma
self.margin = margin
self.weight_pos = 2
self.weight_neg = 1
def forward(self, inputs, targets):
em ... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
TrainingOur Custom Training loop | def train_fn(dataloader,model,criterion,optimizer,device,scheduler,epoch):
model.train()
train_targets=[]
train_outputs=[]
for bi,d in enumerate(dataloader):
features = d['features']
target = d['target']
features = features.to(device, dtype=torch.float)
... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
EvaluationCustom Evaluation loop | def eval_fn(data_loader,model,criterion,device):
fin_targets=[]
fin_outputs=[]
model.eval()
with torch.no_grad():
for bi, d in enumerate(data_loader):
features = d["features"]
target = d["target"]
features = features.to(device, dtype=torch.... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
PlotterFunction for plotting the losses and auc_scores for each fold | def print_history(fold,history,num_epochs=EPOCHS):
plt.figure(figsize=(15,5))
plt.plot(
np.arange(num_epochs),
history['train_history_auc'],
'-o',
label='Train AUC',
color='#ff7f0e'
)
plt.plot(
np.a... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
EngineEngine where we unite everything | def run(fold):
df_train = df[df.fold != fold]
df_valid = df[df.fold == fold]
# Defining DataSet
train_dataset = MelanomaDataset(
df_train[features].values,
df_train[target].values
)
valid_dataset = MelanomaDataset(
df_valid[features].values,
df_v... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
Inference | df_test =pd.read_csv('/data/full/test.csv')
df_test['anatom_site_general_challenge'].fillna('unknown',inplace=True)
df_test['target'] = 0
# df_test.head()
# df_test['age_approx'] = (df_test.age_approx - df_test.age_approx.min()) / df_test.age_approx.max()
# df_test = pd.concat([df_test, pd.get_dummies(df_test.sex), pd... | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
Writing Submission File | pred = pred.mean(axis=-1)
pred
pred.min()
ss = pd.read_csv('/data/full/sample_submission.csv')
ss['target'] = pred
#ss.to_csv('/out/tabnet_submission.csv',index=False)
ss.head()
#!kaggle competitions submit -c siim-isic-melanoma-classification -f submission.csv -m "Tabnet One Hot" | _____no_output_____ | MIT | pl/tabnet.ipynb | ronaldokun/isic2019 |
Day 5: Poisson Distribution II https://www.hackerrank.com/challenges/s10-poisson-distribution-2 Objective In this challenge, we go further with Poisson distributions. We recommend reviewing the previous challenge's Tutorial before attempting this problem. Task The manager of a industrial plant is planning to buy a mac... | a_m, b_m = [float(i) for i in input().split(" ")]
print(round(160 + 40 * (a_m + a_m ** 2), 3))
print(round(128 + 40 * (b_m + b_m ** 2), 3)) | 0.88 1.55
226.176
286.1
| MIT | python/10daysOfStatistics/Day_5_Poisson_Distribution_II .ipynb | muatik/interactive-coding-challenges |
Build a Conditional GAN GoalsIn this notebook, you're going to make a conditional GAN in order to generate hand-written images of digits, conditioned on the digit to be generated (the class vector). This will let you choose what digit you want to generate.You'll then do some exploration of the generated images to vis... | import torch
from torch import nn
from tqdm.auto import tqdm
from torchvision import transforms
from torchvision.datasets import MNIST
from torchvision.utils import make_grid
from torch.utils.data import DataLoader
import matplotlib.pyplot as plt
torch.manual_seed(0) # Set for our testing purposes, please do not change... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Generator and Noise | class Generator(nn.Module):
'''
Generator Class
Values:
input_dim: the dimension of the input vector, a scalar
im_chan: the number of channels in the images, fitted for the dataset used, a scalar
(MNIST is black-and-white, so 1 channel is your default)
hidden_dim: the i... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Discriminator | class Discriminator(nn.Module):
'''
Discriminator Class
Values:
im_chan: the number of channels in the images, fitted for the dataset used, a scalar
(MNIST is black-and-white, so 1 channel is your default)
hidden_dim: the inner dimension, a scalar
'''
def __init__(self, im_ch... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Class InputIn conditional GANs, the input vector for the generator will also need to include the class information. The class is represented using a one-hot encoded vector where its length is the number of classes and each index represents a class. The vector is all 0's and a 1 on the chosen class. Given the labels of... | # UNQ_C1 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
# GRADED FUNCTION: get_one_hot_labels
import torch.nn.functional as F
def get_one_hot_labels(labels, n_classes):
'''
Function for creating one-hot vectors for the labels, returns a tensor of shape (?, num_classes).
Parameters:
labels: tensor of labels ... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Next, you need to be able to concatenate the one-hot class vector to the noise vector before giving it to the generator. You will also need to do this when adding the class channels to the discriminator.To do this, you will need to write a function that combines two vectors. Remember that you need to ensure that the ve... | # UNQ_C2 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
# GRADED FUNCTION: combine_vectors
def combine_vectors(x, y):
'''
Function for combining two vectors with shapes (n_samples, ?) and (n_samples, ?).
Parameters:
x: (n_samples, ?) the first vector.
In this assignment, this will be the noise vector ... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
TrainingNow you can start to put it all together!First, you will define some new parameters:* mnist_shape: the number of pixels in each MNIST image, which has dimensions 28 x 28 and one channel (because it's black-and-white) so 1 x 28 x 28* n_classes: the number of classes in MNIST (10, since there are the digits ... | mnist_shape = (1, 28, 28)
n_classes = 10 | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
And you also include the same parameters from previous assignments: * criterion: the loss function * n_epochs: the number of times you iterate through the entire dataset when training * z_dim: the dimension of the noise vector * display_step: how often to display/visualize the images * batch_size: the nu... | criterion = nn.BCEWithLogitsLoss()
n_epochs = 200
z_dim = 64
display_step = 500
batch_size = 128
lr = 0.0002
device = 'cuda'
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.5,), (0.5,)),
])
dataloader = DataLoader(
MNIST('.', download=False, transform=transform),
batch_... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Then, you can initialize your generator, discriminator, and optimizers. To do this, you will need to update the input dimensions for both models. For the generator, you will need to calculate the size of the input vector; recall that for conditional GANs, the generator's input is the noise vector concatenated with the ... | # UNQ_C3 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
# GRADED FUNCTION: get_input_dimensions
def get_input_dimensions(z_dim, mnist_shape, n_classes):
'''
Function for getting the size of the conditional input dimensions
from z_dim, the image shape, and number of classes.
Parameters:
z_dim: the dimens... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Now to train, you would like both your generator and your discriminator to know what class of image should be generated. There are a few locations where you will need to implement code.For example, if you're generating a picture of the number "1", you would need to: 1. Tell that to the generator, so that it knows it... | # UNQ_C4 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
# GRADED CELL
cur_step = 0
generator_losses = []
discriminator_losses = []
#UNIT TEST NOTE: Initializations needed for grading
noise_and_labels = False
fake = False
fake_image_and_labels = False
real_image_and_labels = False
disc_fake_pred = False
disc_real_pred = False
... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
ExplorationYou can do a bit of exploration now! | # Before you explore, you should put the generator
# in eval mode, both in general and so that batch norm
# doesn't cause you issues and is using its eval statistics
gen = gen.eval() | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Changing the Class VectorYou can generate some numbers with your new model! You can add interpolation as well to make it more interesting.So starting from a image, you will produce intermediate images that look more and more like the ending image until you get to the final image. Your're basically morphing one image i... | import math
### Change me! ###
n_interpolation = 9 # Choose the interpolation: how many intermediate images you want + 2 (for the start and end image)
interpolation_noise = get_noise(1, z_dim, device=device).repeat(n_interpolation, 1)
def interpolate_class(first_number, second_number):
first_label = get_one_hot_l... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
Changing the Noise VectorNow, what happens if you hold the class constant, but instead you change the noise vector? You can also interpolate the noise vector and generate an image at each step. | n_interpolation = 9 # How many intermediate images you want + 2 (for the start and end image)
# This time you're interpolating between the noise instead of the labels
interpolation_label = get_one_hot_labels(torch.Tensor([5]).long(), n_classes).repeat(n_interpolation, 1).float()
def interpolate_noise(first_noise, sec... | _____no_output_____ | MIT | Course1 - Build Basic Generative Adversarial Networks (GANs)/Week4/C1W4A_Build_a_Conditional_GAN_Original.ipynb | RamzanShahidkhan/Generative-Adversarial-Networks-Specialization |
tabula-py example notebooktabula-py is a tool for convert PDF tables to pandas DataFrame. tabula-py is a wrapper of [tabula-java](https://github.com/tabulapdf/tabula-java), which requires java on your machine. tabula-py also enales you to convert PDF tables into CSV/TSV files.tabula-py's PDF extraction accuracy is sa... | !java -version | openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (... | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
After confirming the java environment, install tabula-py by using pip. | # To be more precisely, it's better to use `{sys.executable} -m pip install tabula-py`
!pip install -q tabula-py | [K |████████████████████████████████| 10.4MB 4.2MB/s
[?25h | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Before trying tabula-py, check your environment via tabula-py `environment_info()` function, which shows Python version, Java version, and your OS environment. | import tabula
tabula.environment_info() | Python version:
3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
Java version:
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, s... | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Read a PDF with `read_pdf()` functionLet's read a PDF from GitHub. tabula-py can load a PDF or file like object on both local or internet by using `read_pdf()` function. | pdf_path = "https://github.com/chezou/tabula-py/raw/master/tests/resources/data.pdf"
tabula.read_pdf(pdf_path, stream=True) | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Options for `read_pdf()`Note that `read_pdf()` function reads only page 1 by default. For more details, use `?read_pdf` and `?tabula.wrapper.build_options`. | help(tabula.read_pdf)
help(tabula.wrapper.build_options) | Help on function build_options in module tabula.wrapper:
build_options(kwargs=None)
Build options for tabula-java
Args:
options (str, optional):
Raw option string for tabula-java.
pages (str, int, :obj:`list` of :obj:`int`, optional):
An optional values specifying p... | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Let's set `pages` option. Here is the extraction result of page 3: | # set pages option
tabula.read_pdf(pdf_path, pages=3, stream=True)
# pass pages as string
tabula.read_pdf(pdf_path, pages="1-2,3", stream=True) | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
You can set `pages="all"` for extration all pages. If you hit OOM error with Java, you should set appropriate `-Xmx` option for `java_options`. | # extract all pages
tabula.read_pdf(pdf_path, pages="all", stream=True) | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Read multiple tables with `multiple_tables` optiontabula-py assumes single tabule for an output by default, because of the limitation of pandas. To avoid this issue, you can set `multiple_tables` option. By using this option, `read_pdf` function returns list of DataFrames. | # extract multiple from all pages
multi_tables = tabula.read_pdf(pdf_path, pages="all", multiple_tables=True)
print(multi_tables[0].head())
print(multi_tables[1].head()) | 0 1 2 3 4 5 6 7 8 9
0 mpg cyl disp hp drat wt qsec vs am gear
1 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4
2 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4
3 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4
4 21.4 6 258.0 110 ... | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Read partial area of PDFIf you want to set a certain part of page, you can use `area` option. | # set area option
tabula.read_pdf(pdf_path, area=(126,149,212,462), pages=2) | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Extract to JSON, TSV, or CSVtabula-py has capability to convert not only DataFrame but also JSON, TSV, or CSV. You can set output format with `output_format` option. | # read pdf as JSON
tabula.read_pdf(pdf_path, output_format="json") | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Convert PDF tables into CSV, TSV, or JSON filesYou can convert files directly rather creating Python objects with `convert_into()` function. | # You can convert from pdf into JSON, CSV, TSV
tabula.convert_into(pdf_path, "test.json", output_format="json")
!cat test.json
tabula.convert_into(pdf_path, "test.tsv", output_format="tsv")
!cat test.tsv
tabula.convert_into(pdf_path, "test.csv", output_format="csv", stream=True)
!cat test.csv | "",mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb
Mazda RX4,21.0,6,160.0,110,3.90,2.620,16.46,0,1,4,4
Mazda RX4 Wag,21.0,6,160.0,110,3.90,2.875,17.02,0,1,4,4
Datsun 710,22.8,4,108.0,93,3.85,2.320,18.61,1,1,4,1
Hornet 4 Drive,21.4,6,258.0,110,3.08,3.215,19.44,1,0,3,1
Hornet Sportabout,18.7,8,360.0,175,3.15,3.440,17.0... | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Use lattice mode for more accurate extraction for spreadsheet style tablesIf your tables have lines separating cells, you can use `lattice` option. By default, tabula-py sets `guess=True`, which is the same behavior for default of tabula app. If your tables don't have separation lines, you can try `stream` option.As i... | tabula.read_pdf(pdf_path, pages="1", lattice=True) | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
Use tabula app templatetabula-py can handle tabula app template, which has area options set by GUI app to reuse. | !wget -q "https://github.com/chezou/tabula-py/raw/master/tests/resources/data.tabula-template.json"
tabula.read_pdf_with_template(pdf_path, "data.tabula-template.json") | _____no_output_____ | MIT | examples/tabula_example.ipynb | shailp52/tabula-py |
 for each function, block-by-block, as-it-is, before adjusting parameters/inputs. Once you've verified that the function is working, you are welcome to play with it, learn from manipulating inputs/parameters and even contribute in a way of bug fixing or enhancing with new f... | print("Hi {} ! Welcome to ClointFusion {}".format(cf.gui_get_any_input_from_user('your Name'),cf.show_emoji())) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Note : Executing *import ClointFusion as cf* in any Python file, would create a set of folders in C:\ClointFusion. The sub folders created are Batch_File, Config_Files, Error_Screenshots, Images, Logs, Output and StatusLogExcel. All these 7 folders would be placed in a parent folder, which has name that begins with My_... | cf.OFF_semi_automatic_mode()
outlook_url = 'https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1622187509&rver=7.0.6737.0&wp=MBI_SSL&wreply=https%3a%2f%2foutlook.live.com%2fowa%2f0%2f%3fstate%3d1%26redirectTo%3daHR0cHM6Ly9vdXRsb29rLmxpdmUuY29tL21haWwvMC9pbmJveC8%26nlp%3d1%26RpsCsrfState%3da1418c6a-2688-64b6-57... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Excel Based Functions** | import os
WORKSPACE_DIR = r"C:\Users\Hp\Desktop\Excel_Operations"
EXCEL_FILES_DIR = os.path.join(WORKSPACE_DIR,'Excel_Files')
test_xlsx_path = os.path.join(EXCEL_FILES_DIR,'Test','Test.xlsx')
new_test_xlsx_path = os.path.join(EXCEL_FILES_DIR,'Test','New_Test.xlsx') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Operations | ClointFusion- 20+ Excel Operations| Function Name | Accepted Parameters | Description || :--- | :--- | :--- ||excel_create_excel_file_in_given_folder()| fullpathToTheFodler='',excelFileName='',sheet_name='' |Creates a new excel file in the given folder|| excel_create_file() | fullPathToTheFile='',fi... | # Creates a new excel file New_Test.xlsx in Test folder
cf.excel_create_file(fullPathToTheFile=os.path.join(EXCEL_FILES_DIR,'Test'),fileName='New_Test',sheet_name='Sheet1')
# Creating a new excel file Test.xlsx
cf.excel_create_excel_file_in_given_folder(fullPathToTheFolder=os.path.dirname(test_xlsx_path),excelFileName=... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Add some data into it with Excel set single Cell | # Adding some data into the Test.xlsx file
'''
Output:
|Name | Age |
|-----|-----|
|A | 5 |
|B | 4 |
|C | 3 |
|D | 2 |
|E | 1 |
'''
cf.excel_set_single_cell(excel_path=test_xlsx_path,columnName='Name',cellNumber=0,setText='A')
cf.excel_set_single_cell(excel_path=test_xlsx_path,columnName='Na... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Get All sheet names | # Get all the sheet names of Test.xlsx
cf.excel_get_all_sheet_names(excelFilePath=test_xlsx_path) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Get all Header Columns | cf.excel_get_all_header_columns(excel_path=test_xlsx_path,sheet_name='Sheet1') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Get Row Column Count | cf.excel_get_row_column_count(excel_path=test_xlsx_path,sheet_name='Sheet1') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Split by ColumnName | # Splitting the column into different excel files according to the columnName
cf.excel_split_by_column(excel_path=test_xlsx_path, columnName='Age') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Split by row count | # Divide the excel file based on the row count
cf.excel_split_the_file_on_row_count(excel_path=test_xlsx_path, rowSplitLimit=3, outputFolderPath=EXCEL_FILES_DIR) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Merge Files | merge_folder = os.path.join(EXCEL_FILES_DIR,'Test')
cf.excel_merge_all_files(input_folder_path=EXCEL_FILES_DIR, output_folder_path=merge_folder) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel sort Columns | cf.excel_sort_columns(excel_path=test_xlsx_path, firstColumnToBeSorted='Name', secondColumnToBeSorted='Age') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Drop Columns | split_excel_file1 = os.path.join(EXCEL_FILES_DIR, "Split-1.xlsx")
split_excel_file2 = os.path.join(EXCEL_FILES_DIR, "Split-2.xlsx")
cf.excel_drop_columns(excel_path=split_excel_file1, sheet_name='Sheet1', columnsToBeDropped='Age') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Clear Sheet | cf.excel_clear_sheet(excel_path=split_excel_file2, sheet_name='Sheet1') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Get Single Cell | cf.excel_get_single_cell(excel_path=test_xlsx_path, columnName='Name', cellNumber=0) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Remove Duplicates | cf.excel_remove_duplicates(excel_path=test_xlsx_path, columnName='Name') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel vlook-up | cf.excel_vlook_up(filepath_1=split_excel_file1, filepath_2=test_xlsx_path, match_column_name='Name') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Describe Data | cf.excel_describe_data(excel_path=test_xlsx_path,sheet_name='Sheet1') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Check if data exists | cf.excel_if_value_exists(excel_path=test_xlsx_path, usecols=['Name'], value='A') | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Copy Range from Sheet | copied_data = cf.excel_copy_range_from_sheet(excel_path=test_xlsx_path, startCol=1, startRow=1, endRow=5, endCol=2) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Excel Copy Paste Range From To | cf.excel_copy_paste_range_from_to_sheet(excel_path=new_test_xlsx_path, startCol=1, startRow=1, endRow=5, endCol=2, copiedData=copied_data) | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Tip: In any case, if **ClointFusion-Labs**, stops responding, then just refresh this page and go to Connect and click **CONNECT** (no need to run jupyter commands again) and execute **import ClointFusion as cf** block again. Now, you can resume with your functions. **Mouse Operations** | # Moves the cursor to the given X Y Co-ordinates.
cf.mouse_move(1766,8)
# Clicks at the given X Y Co-ordinates on the screen using ingle / double / tripple click(s).
# Optionally copies selected data to clipboard (works for double / triple clicks).
cf.mouse_click(x=1100, y=777, left_or_right="left", no_of_clicks=1)
# ... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Simple Bot** | path = r"C:\Users\Avinash Chodavarapu\Desktop\Demo\avinash.xlsx"
row, column = cf.excel_get_row_column_count(excel_path=path)
for i in range(row-1):
unit_price = cf.excel_get_single_cell(excel_path=path,columnName="Unit price",cellNumber=i)
quantity = cf.excel_get_single_cell(excel_path=path,columnName="Quanti... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Window Operations**We have 5 functions to control a Window Application. | # Use this function, when you want to minimize all open windows and see the desktop.
# This function doesnot have GUI mode and does not take any parameters.
cf.window_show_desktop()
# Lets see all window operations via a small application.
# This application opens a notepad (automatically maximises), then minimizes, t... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Windows Objects - The High Level Automation** | # Open Calculator
app, main_dlg = cf.win_obj_open_app(title="Calculator", program_path_with_name="C:\Windows\System32\calc.exe")
# Print all objects
cf.win_obj_get_all_objects(main_dlg)
# Open Standard Calc
cf.win_obj_mouse_click(main_dlg, auto_id="TogglePaneButton", control_type="button")
cf.win_obj_mouse_click(main_... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Folder Operations** | # Here you may pass any folder path separated by \. This folder structure would be created, when you run this function.
#NON GUI Mode
cf.folder_create('C:\Test\Test12')
#GUI Mode
# cf.folder_create()
# Notice, 2 ways of using the functions ! This feature is true for almost all functions of ClointFusion.
# Use this f... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Keyboard functions** Lets understand Keyboard functions by buidling a small application.Here, we shall launch a Notepad, type something, close & exit the notepad.. All using keyboard functions. | # Demonstrating keyboard functions.
# Launch notepad
cf.launch_any_exe_bat_application("notepad")
# Enter specified text into newly opened notepad
cf.key_write_enter(write_to_window="notepad",text_to_write="ClointFusion is Awesome")
cf.key_hit_enter(write_to_window="notepad")
# Exit notepad
cf.key_press(write_to_wi... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**String operations (GUI mode)** |
# GUI mode
cf.OFF_semi_automatic_mode()
cf.string_extract_only_numbers()
cf.string_extract_only_alphabets()
cf.string_remove_special_characters() | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**String operations (Non-GUI mode)** | # Function to extract numbers from a given string
num = cf.string_extract_only_numbers(inputString="C1l2o3i4n5t6F7u8i9o0n")
print("Returned value:",num)
print(type(num))
# Function to extract letters from a given string
print(cf.string_extract_only_alphabets(inputString="C1l2o#%^int&*Fus12i5on"))
# Function to remove a... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
**Screenscraping functions** | # Clears previously found text (crtl+f highlight)
cf.screen_clear_search(delay=0.5)
# Copy pastes all the available text on the launched website to notepad and saves it in 'notepad-contents.txt'
cf.browser_activate(url="https://en.wikipedia.org/wiki/Robotic_process_automation")
cf.scrape_save_contents_to_notepad(fol... | _____no_output_____ | BSD-4-Clause | ClointFusion_Labs.ipynb | JAY-007-TRIVEDI/ClointFusion |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.