Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91212531
homework.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 00:53
Size
995 B
Mime Type
text/x-python
Expires
Mon, Nov 11, 00:53 (2 d)
Engine
blob
Format
Raw Data
Handle
22221408
Attached To
R10130 EE311
homework.py
View Options
"""
EE-311
======
Lab 2: NumPy, Matplotlib and Scikit-learn (linear regression example)
---------------------------------------------------------------------
created by François Marelli on 03.03.2021
"""
from
sklearn
import
linear_model
def
mean_odd
(
array
):
"""
Compute the mean of all the odd elements in an array
Parameters:
array: ndarray (int), the array we want to process (it contains at least 1 odd number)
Returns:
result: float, the mean of all the odd elements in the input array
"""
return
def
train
(
data_X
,
data_y
):
"""
Create and train a linear regression model given the input data
Parameters:
data_X : ndarray of shape (N, 1) with N the number of samples, containing the input points
data_y: ndarray of shape (N) containing the labels of the dataset
Returns:
model: sklearn.linear_model.LinearRegression, the linear regression model object trained on the input data
"""
return
Event Timeline
Log In to Comment