This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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'), |
NewerOlder