[Solved] CSE143 Assignment0- Testout Sample

$25

File Name: CSE143_Assignment0-_Testout_Sample.zip
File Size: 320.28 KB

SKU: [Solved] CSE143 Assignment0- Testout Sample Category: Tag:
5/5 - (1 vote)

This testout aims to self-assess your python skill as for you to be successful in this course.Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select KernelRestart) and then run all cells (in the menubar, select CellRunAll).Make sure you fill in any place that says YOUR CODE HERE. Even if your code work on the given test cases, you can also come up with your own test cases. You can write out print statements in your code, to help you test/debug it.Some of the materials are borrowed from Luca de Alfaro CSE 201.1 PreliminariesNose. The line below works on colab.research.google.com. If it does not work on your laptop, do: pip install nose if you use pip to install packages, and conda install nose if you use conda[1]: from nose.tools import assert_equal, assert_true, assert_false# We check that you are running Python 3. You need to use Python 3.import sysassert_equal(sys.version_info.major, 3)1.2 Question 1Write a function ziplist that, given two lists, produces a list of pairs, with the first element of the pair coming from the first list, and the second from the second list. The output list of pairs must be as long as the longest of the input lists, and the missing elements from the shorter input list give rise to None in the output list.

1.3 Question 2Write a function threeormore that, given an input list, outputs the set of list elements that occur 3 or more times.

1.4 Question 3

1.5 Question 4Implement a function olympic_average that, given a list of numbers, if the list is of length at least 3, excludes the minimum and maximum elements and returns the average of the other elements. If the list is shorter than 3, it just returns the average of the elements. If the list is empty, it returns None.

1.6 Question 5Implement a function is_anagram that takes as input two strings, and returns True if and only if the strings are anagrams of each other. This means that the both strings are permutations of each other. You can assume that string will only have lowercase letters.[12]: def is_anagram(w1, w2): return sorted(w1)== sorted(w2)[13]: # First, lets assume that the word does not contain repeated letters.assert_true(is_anagram(home, hemo)) assert_true(is_anagram(, )) assert_true(is_anagram(figure, refugi)) assert_false(is_anagram(seal, coal))[14]: # General case, where there can be repeated characters.assert_true(is_anagram(banana, ananab)) assert_false(is_anagram(hello, helo)) assert_false(is_anagram(banana, bnana))1.7 Question 6Read from file sample_text.txt and save each line as a list of words. Return a list of list as the content of the input file.

1.8 Question 7You dont need to know anything about word vector but you need to be able to read documentation and figure out how to use other library/module. You need to use pip or conda to install these libraries before you could use them. 1. Use gensim library to train a word vector model using sample_text you created above. Read more about the fucntion here https://radimrehurek.com/gensim/models/word2vec.html. 2. Implement a function to get the vector of a given word. Pass size=10, min_count=1 to as parameters to train the model. Return None if the word is not in the vocabulary. 3. Use Sklearn library to implement a function to calculate the cosine similarity (round to two precision) and euclidean distance between two vectors (round to two precision). Return none if any word is not in the vocabulary. Read here https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.cosine_similarity.html

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE143 Assignment0- Testout Sample
$25