42-ai / bootcamp_machine-learning Goto Github PK
View Code? Open in Web Editor NEWBootcamp to learn basics in Machine Learning
License: Other
Bootcamp to learn basics in Machine Learning
License: Other
In the instructions the file name should be std.py, not variance.py
In the variance.py file create the following function as per the instructions given below:
fix/phase1:
Exercises :
Days: 00 & 01
General remarks:
I think that be good to naming variable, not in mathematical notation but in code environment rules. In code when we use uppercase by convention it's for Class not to naming variable. that's can be good to keep this idea ?
I think the prototype for the function when the matrice is waiting must be like that def my_function(x, mat, vec)
not def my_function(x,X,Y)
the name of the variable must help the user directly.
I hope my english is not too much uggly
add example for this exercice can be good option, that's a better view for the non-mathetical coder :)
from py_lib import *
import numpy as np
# @log
def predict(theta, mat):
col_1 = np.ones((mat.shape[0],1))
if theta.shape[0] < 2 or theta.shape[0]-1 != mat.shape[1]:
print("theta size error",theta.shape[0])
print("theta need",mat.shape[1] + 1,"elements")
return None
mat = np.concatenate((col_1,mat), axis = 1)
return np.dot(mat,theta)
if __name__ == "__main__":
theta1 = np.array([[2.], [4.]])
mat1 = np.array([[0.], [1.], [2.], [3.], [4.]])
print(predict(theta1, mat1))
# array([[2], [6], [10], [14.], [18.]])
theta2 = np.array([[2.]])
mat2 = np.array([[1], [2], [3], [5], [8]])
print(predict(theta2, mat2))
# Incompatible dimension match between 'mat' and 'theta'.
# None
theta3 = np.array([[0.05], [1.], [1.], [1.]])
mat3 = np.array([[0.2, 2., 20.], [0.4, 4., 40.], [0.6, 6., 60.], [0.8, 8., 80.]])
print(predict(theta3, mat3))
# array([[22.25], [44.45], [66.65], [88.85]])
theta3 = np.array([[0.05], [1.], [2.]])
mat3 = np.array([[0.1, 1., 10.], [0.2, 2., 20.], [0.3, 3., 30.], [0.4, 4., 40.]])
print(predict(theta3, mat3))
# Incompatible dimension match between 'mat' and 'theta'.
# None
A clear and concise description of what the problem/misunderstanding is.
Parameters x,y inversed regarding the givens examples
Examples
If applicable, add examples to help explain your problem.
print("Code example")
Screenshots
If applicable, add screenshots to help explain your problem.
Hello again, I see an error in the Examples section of mat_mat_prod, it say
Z = array([[ -6, -1, -8, 7, -8],...,[ -9, -4, -10, -3, 6]])
Instead of
Z = numpy.array([[ -6, -1, -8, 7, -8],...,[ -9, -4, -10, -3, 6]])
The formula of the gradient might be confusing, maybe a notation closer to the one of the day 00
Exercises :
In the exemples :
>>> vec_reg_logistic_grad(Y, X, Z,, 1)
array([ 6.69780169, -0.33235792, 2.71787754])
>>> vec_reg_logistic_grad(Y, X, Z,, 0.5)
array([ 6.61208741, -0.3680722, 2.74073468])
>>> vec_reg_logistic_grad(Y, X, Z,, 0.0)
array([ 6.52637312, -0.40378649, 2.76359183])
There are extras ,
after the Z variable
Here is my code for gradient
def gradient(x, y, theta):
if (len(y) == 0 or len(x) == 0 or len(theta) == 0
or y.shape[0] != x.shape[0] or x.shape[1] != theta.shape[0]):
return (None)
res = []
for j in range(len(theta)):
line = sum([(theta.dot(x[i]) - y[i]) * (x[i][j]) for i in range(len(x))]) / len(x)
res.append(line)
return (np.array(res))
and i haven't the same result than in the example
array([ -18.67857143, 91.57142857, -196.5])
mine his two time bigger
array([ -37.35714286, 183.14285714, -393. ])
(Should have I written this in English ? If so I can rewrite it if needed)
Dans l'exemple de l'exo, une fonction "mat_vec_mult" est utilisée, cependant cette fonction n'existe ni dans le sujet de l'exercice, ni dans les précédents, et semble simplement être la fonction "mat_vec_prod" (fonction que l'on doit implémenter dans l'exercice) n'ayant pas été renommée vu que celle ci donne les même résultat que l'exemple :
(ici mon test avec mon implémentation de la "bonne" fonction)
W = np.array([
[-8, 8, -6, 14, 14, -9, -4],
[2, -11, -2, -11, 14, -2, 14],
[-13, -2, -5, 3, -8, -4, 13],
[2, 13, -14, -15, -14, -15, 13],
[2, -1, 12, 3, -7, -3, -6]])
Y = np.array([2, 14, -13, 5, 12, 4, -19]).reshape((7, 1))
print(mat_vec_prod(W, Y))
Sortie:
[[ 452]
[-285]
[-333]
[-182]
[-133]]
Et en capture d'écran, l'exemple du ex05 (entouré en rouge):
Mon implémentation de la fonction (au cas où ça vienne de moi, si jamais c'est le cas, désolée):
import numpy as np
def dot(x, y):
try:
assert len(x) == len(y)
res = 0
for i in range(len(x)):
res += x[i] * y[i]
return res
except AssertionError:
return None
def mat_vec_prod(x, y):
try:
assert len(x[0]) == len(y)
return np.asarray([dot(x[i], y) for i in range(len(x))])
except AssertionError:
return None
in the example section there is
linear_mse(X, Y, Z)
but it should be
linear_mse(Y, X, Z)
because shapes doesn't match
sum
mean
variance
standard deviation
vectors dot product
matrix-vector multiplication
matrix-matrix multiplication
mean squared error - iterative
mean squared error - vectorized
mean squared error as linear cost function - iterative
mean squared error as linear cost function - vectorized
linear gradient - iterative
linear gradient - vectorized
I agree with a previous issue from bcarlier, its not so cool to do exercices twice, especially cause the vectorised one is the one that we thing of first ! So maybe do it in one exercice that ask the 2 methods ?
Otherwise, really cool day, really easy exercices, it s reeeeally conforting to do exercice in less than 5min !
We encourage you to get a look at this section of the Cross entropy Wikipedia.
--> maybe show that "this section" is a link
Would be preferable to have only one directory per day and all exercices files in that directory
Thus, we would be able to import previous exercice as it is frequently recommended in the exercices!
In order to avoid coding a function which wasn't understood, the purpose of some formula could be explained.
You must implement the following formula as a function:
$$ \sigma^2 = \frac{1}{m} \sum_{i = 1}^{m} (x_i - \frac{1}{m} \sum_{j = 1}^{m} x_j)^{2} $$
Maybe explain what is variance, why it is used (gaussian curve, std)?
Exercises :
On the Example section, you use numpy.array() on the first half then you use np.array
maybe you should precise that np is import numpy as np ?
In the 'Objectives' part it says :
The goal of this exercise is to recreate the function recall_score of sklearn.metrics and to
learn what represents the recall and how to measure it.
But it was the objectives of the previous exercice (ex08: recall_score) instead of a description of F-Score.
In order to avoid coding a function which wasn't understood, the purpose of some formula could be explained.
You must implement the following formula as a function:
$$ \frac{1}{m}\sum_{i=1}^{m}(\hat{y}_i - y_i)^2 $$
Maybe explain the purpose of mean square error?
Hello, the name of the file isn't the same than in the ressources
data = pd.read_csv("are_blue_pills_magics.csv")
and
Xpill = np.array(data[micrograms]).reshape(-1,1)
Yscore = np.array(data[Score]).reshape(-1,1)
should be
Xpill = np.array(data["micrograms"]).reshape(-1,1)
Yscore = np.array(data["Score"]).reshape(-1,1)
Hello, in the Forbidden functions it saided *.sum() isn't authorized but is it possible
to use the function sum() like that ?
Examples
def sum_(x, f):
return(sum([f(i) for i in x]))
Update all the pep8 links to:
https://pypi.org/project/pycodestyle/
Description:
Calculates all the elements 0.5M(y_pred - y)^2 of the cost function.
à la place de (0.5/M)*(y_pred - y)^2
arguments manquants de fit_
def fit_(theta, X, Y):
à la place de def fit_(theta, X, Y, alpha, n_cycle):
def fit_(theta, X, Y):
à la place de def fit_(theta, X, Y, alpha, n_cycle):
theta1
array([[2.0023..],[3.9991..]])
predict_(theta1, X1)
array([2.0023..], [6.002..], [10.0007..], [13.99988..], [17.9990..])
correspondent à self.theta -= (0.5*alpha/M)*correct
à la place de self.theta -= (alpha/M)*correct
print(linear_model1.mse_(Xpill, Yscore))
57.60304285714282
à la place de print(linear_model1.mse_(Y_model1, Yscore))
et pareil pour le model2
Exercises :
After the instructions for the function it is written :
"x width will be the number of coefficients or number of coefficients + 1 if you choose to add an intercept ..."
I think it should be:
"x width will be the number of coefficients or number of coefficients - 1 if you choose to add an intercept ..."
because if we decide to add an intercept the length of theta is the (width of X) + 1 and not the opposite.
"The graph with the data, the hypothesis
obtained via linear gradient desent versus age (see example figure 1)"
There is no legends for any figures of the exercice stipulate the nº of figures, maybe it would be preferable to use:
"Figure 1: The graph with the data (...)"
Moreover there is a typo in these sentences, "desent" -> "descent"
[...], with a large power thrust comes a risk of spacecraft crash
Exercises :
There are missing parameters in the following prototype of fit :
fit_(self, lambda=1.0, max_iter=1000, tol=0.001):
It should be composed by a training set and true results.
Example
fit_(self, x, y, alpha, lambda=1.0, max_iter=1000[, tol=0.001]):
Hello, here is a list of all the problemes I've found
pb.txt
It's a bit hard to find the vectorized form of the logistic loss function,
I think it will be easier to give it or to give a way to calculate it
Hi all! To let you know I am going to create a readme for the repo.
A clear and concise description of what the problem/misunderstanding is.
THETA is given as: "is a vector of dimension n * 1"
although the definition is given for (n+1) terms (0 until n)
Examples
If applicable, add examples to help explain your problem.
Also examples are given with the same dimension for X and THETA
The same result than the examples can be obtain using only the general formula (1...n)
print("Code example")
Screenshots
If applicable, add screenshots to help explain your problem.
import abc
class Base(abc.ABC):
@abc.abstractmethod
def __init__(self, *args):
pass
@abc.abstractmethod
def __call__(self):
pass
@abc.abstractmethod
def predict(self, data):
pass
# I let you define what is relevant.
class KMean(Base):
# the implementation for the students
Find a link for documentation: http://masnun.rocks/2017/04/15/interfaces-in-python-protocols-and-abcs/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.