Assignment2_pdf_merged
.pdf
keyboard_arrow_up
School
University of California, San Diego *
*We aren’t endorsed by this school
Course
176
Subject
Computer Science
Date
May 14, 2024
Type
Pages
26
Uploaded by MasterJellyfish4274
logistic_regression
January 28, 2024
1
ECE 285 Assignment 2: Logistic Regression
For this part of assignment, you are tasked to implement a logistic regression algorithm for multi-
class classification and test it on the CIFAR10 dataset.
You sould run the whole notebook and answer the questions in the notebook.
TO SUBMIT: PDF of this notebook with all the required outputs and answers.
[1]:
# Prepare Packages
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
utils.data_processing
import
get_cifar10_data
# Use a subset of CIFAR10 for KNN assignments
dataset
=
get_cifar10_data(
subset_train
=5000
,
subset_val
=250
,
subset_test
=500
,
)
print
(dataset
.
keys())
print
(
"Training Set Data
Shape: "
, dataset[
"x_train"
]
.
shape)
print
(
"Training Set Label Shape: "
, dataset[
"y_train"
]
.
shape)
print
(
"Validation Set Data
Shape: "
, dataset[
"x_val"
]
.
shape)
print
(
"Validation Set Label Shape: "
, dataset[
"y_val"
]
.
shape)
print
(
"Test Set Data
Shape: "
, dataset[
"x_test"
]
.
shape)
print
(
"Test Set Label Shape: "
, dataset[
"y_test"
]
.
shape)
dict_keys(['x_train', 'y_train', 'x_val', 'y_val', 'x_test', 'y_test'])
Training Set Data
Shape:
(5000, 3072)
Training Set Label Shape:
(5000,)
Validation Set Data
Shape:
(250, 3072)
Validation Set Label Shape:
(250,)
Test Set Data
Shape:
(500, 3072)
Test Set Label Shape:
(500,)
1
2
Logistic Regression for multi-class classification
A Logistic Regression Algorithm has these hyperparameters:
•
Learning rate
- controls how much we change the current weights of the classifier during
each update. We set it at a default value of 0.5, and later you are asked to experiment with
different values. We recommend looking at the graphs and observing how the performance of
the classifier changes with different learning rate.
•
Number of Epochs
- An epoch is a complete iterative pass over all of the data in the
dataset. During an epoch we predict a label using the classifier and then update the weights
of the classifier according the linear classifier update rule for each sample in the training set.
We evaluate our models after every 10 epochs and save the accuracies, which are later used
to plot the training, validation and test VS epoch curves.
•
Weight Decay
- Regularization can be used to constrain the weights of the classifier and
prevent their values from blowing up. Regularization helps in combatting overfitting. You
will be using the ‘weight_decay’ term to introduce regularization in the classifier.
The only way how a Logistic Regression based classification algorithm is different from a Linear
Regression algorithm is that in the former we additionally pass the classifier outputs into a sigmoid
function which squashes the output in the (0,1) range. Essentially these values then represent the
probabilities of that sample belonging to class particular classes
2.0.1
Implementation (40%)
You need to implement the Linear Regression method in
algorithms/logistic_regression.py
.
The formulations follow the lecture (consider binary classification for each of the 10 classes, with
labels -1 / 1 for not belonging / belonging to the class). You need to fill in the training function as
well as the prediction function. You need to fill in the sigmoid function, training function as well
as the prediction function.
[2]:
# Import the algorithm implementation (TODO: Complete the Logistic Regression
␣
↪
in algorithms/logistic_regression.py)
from
algorithms
import
Logistic
from
utils.evaluation
import
get_classification_accuracy
num_classes
= 10
# Cifar10 dataset has 10 different classes
# Initialize hyper-parameters
learning_rate
= 0.01
# You will be later asked to experiment with different
␣
↪
learning rates and report results
num_epochs_total
= 200
# Total number of epochs to train the classifier
epochs_per_evaluation
= 10
# Epochs per step of evaluation; We will evaluate
␣
↪
our model regularly during training
N, D
=
dataset[
"x_train"
]
.
shape
# Get training data shape, N: Number of examples, D:Dimensionality of
␣
↪
the data
weight_decay
= 0.00002
2
x_train
=
dataset[
"x_train"
]
.
copy()
y_train
=
dataset[
"y_train"
]
.
copy()
x_val
=
dataset[
"x_val"
]
.
copy()
y_val
=
dataset[
"y_val"
]
.
copy()
x_test
=
dataset[
"x_test"
]
.
copy()
y_test
=
dataset[
"y_test"
]
.
copy()
# Insert additional scalar term 1 in the samples to account for the bias as
␣
↪
discussed in class
x_train
=
np
.
insert(x_train, D, values
=1
, axis
=1
)
x_val
=
np
.
insert(x_val, D, values
=1
, axis
=1
)
x_test
=
np
.
insert(x_test, D, values
=1
, axis
=1
)
[3]:
# Training and evaluation function -> Outputs accuracy data
def
train
(learning_rate_, weight_decay_):
# Create a linear regression object
logistic_regression
=
Logistic(
num_classes, learning_rate_, epochs_per_evaluation, weight_decay_
)
# Randomly initialize the weights and biases
weights
=
np
.
random
.
randn(num_classes, D
+ 1
)
* 0.0001
train_accuracies, val_accuracies, test_accuracies
=
[], [], []
# Train the classifier
for
_
in
range
(
int
(num_epochs_total
/
epochs_per_evaluation)):
# Train the classifier on the training data
weights
=
logistic_regression
.
train(x_train, y_train, weights)
# Evaluate the trained classifier on the training dataset
y_pred_train
=
logistic_regression
.
predict(x_train)
train_accuracies
.
append(get_classification_accuracy(y_pred_train,
␣
↪
y_train))
# Evaluate the trained classifier on the validation dataset
y_pred_val
=
logistic_regression
.
predict(x_val)
val_accuracies
.
append(get_classification_accuracy(y_pred_val, y_val))
# Evaluate the trained classifier on the test dataset
y_pred_test
=
logistic_regression
.
predict(x_test)
test_accuracies
.
append(get_classification_accuracy(y_pred_test, y_test))
return
train_accuracies, val_accuracies, test_accuracies, weights
3
[4]:
import
matplotlib.pyplot
as
plt
def
plot_accuracies
(train_acc, val_acc, test_acc):
# Plot Accuracies vs Epochs graph for all the three
epochs
=
np
.
arange(
0
,
int
(num_epochs_total
/
epochs_per_evaluation))
plt
.
ylabel(
"Accuracy"
)
plt
.
xlabel(
"Epoch/10"
)
plt
.
plot(epochs, train_acc, epochs, val_acc, epochs, test_acc)
plt
.
legend([
"Training"
,
"Validation"
,
"Testing"
])
plt
.
show()
[5]:
# Run training and plotting for default parameter values as mentioned above
t_ac, v_ac, te_ac, weights
=
train(learning_rate, weight_decay)
[6]:
plot_accuracies(t_ac, v_ac, te_ac)
print
(
"Logistic Regression"
)
Logistic Regression
4
2.0.2
Try different learning rates and plot graphs for all (20%)
[7]:
# Initialize the best values
best_weights
=
weights
best_learning_rate
=
learning_rate
best_weight_decay
=
weight_decay
# TODO
# Repeat the above training and evaluation steps for the following learning
␣
↪
rates and plot graphs
# You need to try 3 learning rates and submit all 3 graphs along with this
␣
↪
notebook pdf to show your learning rate experiments
learning_rates
=
[
0.01
,
0.1
,
1
]
weight_decay
= 0.0
# No regularization for now
# FEEL FREE TO EXPERIMENT WITH OTHER VALUES. REPORT OTHER VALUES IF THEY
␣
↪
ACHIEVE A BETTER PERFORMANCE
# for lr in learning_rates: Train the classifier and plot data
# Step 1. train_accu, val_accu, test_accu = train(lr, weight_decay)
# Step 2. plot_accuracies(train_accu, val_accu, test_accu)
max_test_accu
= 0
max_val_accu
=0
for
learning_rate
in
learning_rates:
train_accu, val_accu, test_accu, weights
=
train(learning_rate, weight_decay)
plot_accuracies(train_accu, val_accu, test_accu)
if
max_val_accu
<
max
(val_accu):
max_val_accu
=
max
(val_accu)
max_test_accu
=
max
(test_accu)
best_learning_rate
=
learning_rate
best_weights
=
weights
print
(
f"maximum validation accuracy:
{
max_val_accu
}
and test accuracy :
␣
↪
{
max_test_accu
}
at Learning Rate:
{
best_learning_rate
}
"
)
5
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
KNN is a technique used to estimate new values based on the similarity of known ones.
In this assignment, your company wants you to estimate the selling price of a customer's building
The price you calculate will be given to the customer as the company selling price recommendation.
You decide to use Data Science techniques such as the K-Nearest Neighbor.(KNN)
You will need to:
Import the necessary libraries from your program. (You can use the model class sklearn.neighbors.KNeighborsClassifier, part of the package sci-kit-learn 1.1.1 (Links to an external site) or any other.
Train/test the model with the data included in the module (cal_housing.tgz).
The house you need to estimate the value for has the following properties:
longitude: 120.75latitude: 39.34housingMedianAge: 35.5total rooms: 260totalBedrooms:120 population:540households: 12medianIncome:1.8 K BuildingValue: ?
What is the recommended price?
You need to provide the code, properly commented.
You could use…
arrow_forward
9. Packages outside of base Python never come with any Python installation.
True
False
10. ANOVA is an omnibus test
True
False
11. OLS can be used for regression and ANOVA
True
False
12.The following will compare differences in traffic across days
mulicomp.pairwise_turkeyhsd(df.day, df.trafic)
True
False
13. Statsmodels generally requires ___ matrices
statsmodels doesn't require matrices
4
2
3
14. Match the following
Independent/predictor variables
Dependent/response variables
1.
Endogenous
2.
Exogenous
15. Boxplots are useful in comparing mean differences across groups
True
False
16. Scatterplots are useful for comparing mean differences across groups
True
False
arrow_forward
Using Pandas library in python - Calculate student grades project
Pandas is a data analysis library built in Python. Pandas can be used in a Python script, a Jupyter Notebook, or even as part of a web application. In this pandas project, you’re going to create a Python script that loads grade data of 5 to 10 students (a .csv file) and calculates their letter grades in the course. The CSV file contains 5 column students' names, score in-class participation (5% of final grade), score in assignments (20% of final grade), score in discussions (20% of final grade), score in the mid term (20% of final grade), score in final (25% of final grade). Create the .csv file as part of the project submission
Program Output
This will happen when the program runs
Enter the CSV file
Student 1 named Brian Tomas has a letter grade of B+
Student 2 named Tom Blank has a letter grade of C
Student 3 named Margo True has a letter grade of A
Student 4 named David Atkin has a letter grade of B+
Student 5 named…
arrow_forward
Sorting objects in the real world https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html
There are 5000 people living in the town. Every day they have new COVID-19 cases.
When people show symptom, they go to the hospital and put themselves in the waiting list for testing. A new person is added at the end of the list. Due to the lack of testing kit, all in the list cannot be tested. Hospital has to sort them and select a few. Since the elderly is very weak to the COVID-19, every midnight the doctors sort the people in the list by their age to decide who is taking the test for the next day depending on the availability of testing kit.
Input to the program has the form where the first line indicates how many days they will do the operation. For each day, the input starts with the day number, along with the following patient list where each element represents the name of patients and the age. The input ends with the number of available testing kits.
The output display, at…
arrow_forward
link to csv : https://www.dropbox.com/s/umxdnzxsp44gg5g/ex32_data.csv?dl=0
arrow_forward
Python Machine Learning
Can you tell me what are the outliners in this dataset?
from sklearn.datasets import load_wine
print(load_wine().DESCR)
X = load_wine().data
y = load_wine().target
f_names = load_wine().feature_names
import pandas as pd
df = pd.DataFrame(X, columns=f_names)
df['TARGET'] = y
df.head()
df['Type'] = y
df.head()
df.info()
df.isna().sum().sum()
df.describe()
import matplotlib.pyplot as plt
df.hist(figsize=(20,12), layout=(4,8))
plt.tight_layout
arrow_forward
Pandas is a software library written for the Python programming language for data manipulation and analysis. In particular, it offers data structures and operations for manipulating numerical tables and time series. In this
section, we will be looking at some of the preprocessing steps involved with analysing data.
We will be using the 'cars.csv' dataset [ this csv file is provided inside your lab zipfile download ]
Dataset resource: https://www.kaggle.com/abineshkumark/carsdata
About the dataset: Cars Data has Information about 3 brands/make of cars. Namely US, Japan, Europe. Target of the data set to find the brand of a car using the parameters such as horsepower, Cubic inches, Make year,
etc.
Look out for the 'YOUR CODE HERE:' comment in the following cells
3.a) Loading a .csv file ( 2 points)
# Loading a .csv file
# Use a pandas fuction to read a csv file (cars.csv)
# Store the csv file as a pandas dataframe called 'df'
# YOUR CODE HERE
Python
# Viewing a sample of the dataframe…
arrow_forward
Implement the code for below assignment
Map (the mapper function) EmitIntermediate(the intermediate key,value pairs emitted by the mapper functions) Reduce (the reducer function) Emit (the final output, after summarization from the Reduce functions)We provide you with a single system, single thread version of a basic MapReduce implementation.
Task
The input is a number of test cases with two matrices each. A single test case will look like:
The required output is to print the product of the two matrices in the format shown. The code for the MapReduce class, parts related to IO etc. has already been provided. However, the mapper and reducer functions are incomplete. Your task is to fill up the mapper and reducer functions appropriately, such that the program works, and outputs the product of the two matrices, in row-wise manner.
Also, this program outputs certain information to the error stream. This information has been logged to help beginners gain a better understanding of the the…
arrow_forward
In The Readline Technique, on page 179, you learned how to read somefiles from the Time Series Data Library. In particular, you learned aboutthe Hopedale data set, which describes the number of colored fox fur peltsproduced from 1834 to 1842. This file contains one value per year perline.a. Write an outline in English of the algorithm you would use to readthe values from this data set to compute the average number of peltsproduced per year.b. Translate your algorithm into Python by writing a function namedhopedale_average that takes a filename as a parameter and returns theaverage number of pelts produced per year.
arrow_forward
There is a famous dataset in R called "iris." It should already be loaded# in R for you. If you type in > ?iris you can see some documentation. Familiarize# yourself with this dataset.
# Now obtain the mean of the first 4 variables, by species, but# using only one function call.
#use R studio
arrow_forward
The purpose of this project is to assess your ability to (JAVA):
Implement a hash table
Utilize a hash table to efficiently locate data
Analyze and compare algorithms for efficiency using Big-O notation
For this project, you will implement a hash table and use it to store words in a large text file in JAVA. Your hash table should use chaining for collision resolution. You may design any hash function you wish.
Your program will read a JAVA file and insert each word into a hash table. Once the table is populated, allow the user to enter words to search for. For each word entered, your program should report the number of elements inspected and whether or not the word was located.
Provide an analysis of your insert and search algorithms using Big-O notation. Be sure to provide justification for your claims.
arrow_forward
Using a Generic class that implements the Comparator interface, write a workingprogram that compares the performance of any two IPL teams in terms of the following:1) Points per match= PTS/PLD2) Form= (# of Ws)/33) Net Run Rare= Net RRYou can use the following data to make comparisons between any two teams of yourchoice:
You can hard code the data associated with the two teams you have chosen. Hence, no needto take any inputs from the user. Upon running the program, the program should simplyoutput the three comparison results.Additionally, please mention the names of the two chosen teams in the beginning of theprogram in a comment.
arrow_forward
Design and implement a service that simulates PHP loops. Each of the three loop variants should be encapsulated in an object. The service can be controlled via a parameter and execute three different simulations. The result is returned as JSON.
The input is an array consisting of the letters $characters = [A-Z].
-The For loop should store all even letters in an array.-The Foreach loop simulation is to create a backward sorted array by For loop, i.e. [Z-A] .-The While loop should write all characters into an array until the desired character is found.
Interface:-GET Parameter String: loopType ( possible values: REVERSE, EVEN, UNTIL )-GET parameter String: until (up to which character)
Output:JSON Object: {loopName: <string>, result: <array> }
arrow_forward
Insertion
db.books.insertMany([{"_id": "78945612","Title": "The Hobbit","Author": "J.R.R. Tolkien"},{"_id": "65432187","Title": "DaVinci Code","Author": "Daneil Brown"},{"_id": "your id","Title": "DBS311","Author": "your name"} ])
write a mongodb code to add the ‘Publication_Year’ to the whole coe ,iwith value ‘1932’.
arrow_forward
Please help me with the assignment below
The assignment:
Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The driver class needs to have only 5 or 7 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.
arrow_forward
Final output should be like sample runs shown in ques and attached images. Please solve.
arrow_forward
QUESTION 2
You don't have to plot the points as characters; you can use different colors/shapes as long as you include a legend.
USE PYTHON AND HANDWRITE BOTH METHODS
Data: https://archive.ics.uci.edu/ml/datasets/Wine
Take the wine dataset from the UC Irvine machine learning data repository at https://archive.ics.uci.edu/ml/datasets/Wine
(a) Plot the eigenvalues of the covariance matrix in sorted order. How many principal components should be used to represent this dataset? Why?
(c) Compute the first two principal components of this dataset, and project it onto those components. Now produce a scatter plot of this two dimensional dataset, where data items of class 1 are plotted as a '1', class 2 as a '2', and so on.
arrow_forward
importing the necessary library import pandas as pd import statsmodels.api as sm # In[2]: # Read the dataset df = pd.read_csv('fastfood.csv') # In[3]: # getting the necessary columns for the prediction of calories. df = df[['total_fat', 'sat_fat', 'cholesterol', 'sodium','calories']] # In[4]: df.head() # display few rows. # In[5]: # Get X and Y as ndarray using .values X = df[['total_fat', 'sat_fat', 'cholesterol', 'sodium']].values Y = df[['calories']].values # In[6]: # Adding the constant X = sm.add_constant(X) # In[7]: # Create and fit OLS model on X and Y sm_model = sm.OLS(Y,X) model = sm_model.fit() # In[8]: # print the desired output. print(model.mse_total.round(2)) print(model.rsquared.round(2)) print(model.params.round(2)) print(model.pvalues.round(2))
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- KNN is a technique used to estimate new values based on the similarity of known ones. In this assignment, your company wants you to estimate the selling price of a customer's building The price you calculate will be given to the customer as the company selling price recommendation. You decide to use Data Science techniques such as the K-Nearest Neighbor.(KNN) You will need to: Import the necessary libraries from your program. (You can use the model class sklearn.neighbors.KNeighborsClassifier, part of the package sci-kit-learn 1.1.1 (Links to an external site) or any other. Train/test the model with the data included in the module (cal_housing.tgz). The house you need to estimate the value for has the following properties: longitude: 120.75latitude: 39.34housingMedianAge: 35.5total rooms: 260totalBedrooms:120 population:540households: 12medianIncome:1.8 K BuildingValue: ? What is the recommended price? You need to provide the code, properly commented. You could use…arrow_forward9. Packages outside of base Python never come with any Python installation. True False 10. ANOVA is an omnibus test True False 11. OLS can be used for regression and ANOVA True False 12.The following will compare differences in traffic across days mulicomp.pairwise_turkeyhsd(df.day, df.trafic) True False 13. Statsmodels generally requires ___ matrices statsmodels doesn't require matrices 4 2 3 14. Match the following Independent/predictor variables Dependent/response variables 1. Endogenous 2. Exogenous 15. Boxplots are useful in comparing mean differences across groups True False 16. Scatterplots are useful for comparing mean differences across groups True Falsearrow_forwardUsing Pandas library in python - Calculate student grades project Pandas is a data analysis library built in Python. Pandas can be used in a Python script, a Jupyter Notebook, or even as part of a web application. In this pandas project, you’re going to create a Python script that loads grade data of 5 to 10 students (a .csv file) and calculates their letter grades in the course. The CSV file contains 5 column students' names, score in-class participation (5% of final grade), score in assignments (20% of final grade), score in discussions (20% of final grade), score in the mid term (20% of final grade), score in final (25% of final grade). Create the .csv file as part of the project submission Program Output This will happen when the program runs Enter the CSV file Student 1 named Brian Tomas has a letter grade of B+ Student 2 named Tom Blank has a letter grade of C Student 3 named Margo True has a letter grade of A Student 4 named David Atkin has a letter grade of B+ Student 5 named…arrow_forward
- Sorting objects in the real world https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html There are 5000 people living in the town. Every day they have new COVID-19 cases. When people show symptom, they go to the hospital and put themselves in the waiting list for testing. A new person is added at the end of the list. Due to the lack of testing kit, all in the list cannot be tested. Hospital has to sort them and select a few. Since the elderly is very weak to the COVID-19, every midnight the doctors sort the people in the list by their age to decide who is taking the test for the next day depending on the availability of testing kit. Input to the program has the form where the first line indicates how many days they will do the operation. For each day, the input starts with the day number, along with the following patient list where each element represents the name of patients and the age. The input ends with the number of available testing kits. The output display, at…arrow_forwardlink to csv : https://www.dropbox.com/s/umxdnzxsp44gg5g/ex32_data.csv?dl=0arrow_forwardPython Machine Learning Can you tell me what are the outliners in this dataset? from sklearn.datasets import load_wine print(load_wine().DESCR) X = load_wine().data y = load_wine().target f_names = load_wine().feature_names import pandas as pd df = pd.DataFrame(X, columns=f_names) df['TARGET'] = y df.head() df['Type'] = y df.head() df.info() df.isna().sum().sum() df.describe() import matplotlib.pyplot as plt df.hist(figsize=(20,12), layout=(4,8)) plt.tight_layoutarrow_forward
- Pandas is a software library written for the Python programming language for data manipulation and analysis. In particular, it offers data structures and operations for manipulating numerical tables and time series. In this section, we will be looking at some of the preprocessing steps involved with analysing data. We will be using the 'cars.csv' dataset [ this csv file is provided inside your lab zipfile download ] Dataset resource: https://www.kaggle.com/abineshkumark/carsdata About the dataset: Cars Data has Information about 3 brands/make of cars. Namely US, Japan, Europe. Target of the data set to find the brand of a car using the parameters such as horsepower, Cubic inches, Make year, etc. Look out for the 'YOUR CODE HERE:' comment in the following cells 3.a) Loading a .csv file ( 2 points) # Loading a .csv file # Use a pandas fuction to read a csv file (cars.csv) # Store the csv file as a pandas dataframe called 'df' # YOUR CODE HERE Python # Viewing a sample of the dataframe…arrow_forwardImplement the code for below assignment Map (the mapper function) EmitIntermediate(the intermediate key,value pairs emitted by the mapper functions) Reduce (the reducer function) Emit (the final output, after summarization from the Reduce functions)We provide you with a single system, single thread version of a basic MapReduce implementation. Task The input is a number of test cases with two matrices each. A single test case will look like: The required output is to print the product of the two matrices in the format shown. The code for the MapReduce class, parts related to IO etc. has already been provided. However, the mapper and reducer functions are incomplete. Your task is to fill up the mapper and reducer functions appropriately, such that the program works, and outputs the product of the two matrices, in row-wise manner. Also, this program outputs certain information to the error stream. This information has been logged to help beginners gain a better understanding of the the…arrow_forwardIn The Readline Technique, on page 179, you learned how to read somefiles from the Time Series Data Library. In particular, you learned aboutthe Hopedale data set, which describes the number of colored fox fur peltsproduced from 1834 to 1842. This file contains one value per year perline.a. Write an outline in English of the algorithm you would use to readthe values from this data set to compute the average number of peltsproduced per year.b. Translate your algorithm into Python by writing a function namedhopedale_average that takes a filename as a parameter and returns theaverage number of pelts produced per year.arrow_forward
- There is a famous dataset in R called "iris." It should already be loaded# in R for you. If you type in > ?iris you can see some documentation. Familiarize# yourself with this dataset. # Now obtain the mean of the first 4 variables, by species, but# using only one function call. #use R studioarrow_forwardThe purpose of this project is to assess your ability to (JAVA): Implement a hash table Utilize a hash table to efficiently locate data Analyze and compare algorithms for efficiency using Big-O notation For this project, you will implement a hash table and use it to store words in a large text file in JAVA. Your hash table should use chaining for collision resolution. You may design any hash function you wish. Your program will read a JAVA file and insert each word into a hash table. Once the table is populated, allow the user to enter words to search for. For each word entered, your program should report the number of elements inspected and whether or not the word was located. Provide an analysis of your insert and search algorithms using Big-O notation. Be sure to provide justification for your claims.arrow_forwardUsing a Generic class that implements the Comparator interface, write a workingprogram that compares the performance of any two IPL teams in terms of the following:1) Points per match= PTS/PLD2) Form= (# of Ws)/33) Net Run Rare= Net RRYou can use the following data to make comparisons between any two teams of yourchoice: You can hard code the data associated with the two teams you have chosen. Hence, no needto take any inputs from the user. Upon running the program, the program should simplyoutput the three comparison results.Additionally, please mention the names of the two chosen teams in the beginning of theprogram in a comment.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education