Skip to content

Instantly share code, notes, and snippets.

View Joelfranklin96's full-sized avatar

S Joel Franklin Joelfranklin96

View GitHub Profile
from transformers import BertTokenizer, BertForTokenClassification, Trainer, TrainingArguments
from datasets import load_dataset
# Load pre-trained BERT tokenizer
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
# Tokenize the text and align the labels
def tokenize_and_align_labels(examples):
tokenized_inputs = tokenizer(examples['tokens'], truncation=True, is_split_into_words=True, padding='max_length')
labels = []
{
"public_identifier": "eden-marco",
"profile_pic_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/eden-marco/profile?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230513%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230513T080203Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=864f0b1147bf2957e077b949cb3d81b0fa5503317519b8444e2ec4960c744f1c",
"background_cover_image_url": null,
"first_name": "Eden",
"last_name": "Marco",
"full_name": "Eden Marco",
"follower_count": null,
"occupation": "Customer Engineer at Google",
"headline": "Customer Engineer @ Google Cloud | Best-selling Udemy Instructor",
@Joelfranklin96
Joelfranklin96 / class6.py
Created May 27, 2020 01:49
magic methods output
# Defining the objects
guassian_one = guassian(3,7)
guassian_two = guassian(4,8)
# __add__ method
guassian_three = guassian_one + guassian_two
# Printing the mean and standard deviation
@Joelfranklin96
Joelfranklin96 / class5.py
Created May 27, 2020 01:22
magic methods
def __add__(self,other):
result = guassian()
result.mean = self.mean + other.mean
result.stdev = math.sqrt((self.stdev)**2 + (other.stdev)**2)
return result
def __repr__(self):
return "mean {}, standard deviation {}".format(self.mean, self.stdev)
@Joelfranklin96
Joelfranklin96 / class4.py
Last active May 27, 2020 01:05
defining an object - 2
# Defining an object of guassian class
guassian_two = guassian()
# Reading the data from text file
guassian_two.read_text('sample.txt')
# Calculating the mean and standard deviation
@Joelfranklin96
Joelfranklin96 / class3.py
Created May 27, 2020 00:29
defining an object of guassian class
# Defining an object of guassian class with 'mean' = 3 and 'standard deviation' = 5
guassian_one = guassian(3,5)
# Prints the mean and standard deviation
print(guassian_one.mean)
print(guassian_one.stdev)
# Defining the Class guassian
class guassian():
def __init__(self,mean=0,stdev=0):
self.mean = mean
self.stdev = stdev
# If dataset is passed as parameter rather than the 'mean' and 'stdev',
# we first read the data and then find the 'mean' and 'stdev'.
# Defining the class 'shirts'
class shirts:
# Initializing the attributes of the class
def __init__(self,color,size,price):
self.color = color
self.size = size
self.price = price
@Joelfranklin96
Joelfranklin96 / Display_cv_score.py
Created December 13, 2019 20:02
Display_cv_score
# Creating a list of model names
model_names = ['K Nearest Neighbors','Neural Net','Decision Tree','Random Forest','AdaBoost','Naive Bayes','SVM Linear','SVM rbf','SVM Sigmoid']
# Cross validation scores of the models
for i in range(len(models)):
print('The cross validation score of {} is {}'.format(model_names[i],cv_result[i]))
@Joelfranklin96
Joelfranklin96 / Cross_validation_score.py
Created December 13, 2019 19:17
Cross_validation_score
# Defining the models
models = [KNeighborsClassifier(n_neighbors = 3),
MLPClassifier(alpha = 1),
DecisionTreeClassifier(max_depth = 5),
RandomForestClassifier(max_depth=5,n_estimators=10,max_features=1),
AdaBoostClassifier(),
GaussianNB(),
SVC(kernel = 'linear'),
SVC(kernel = 'rbf'),