Skip to content

Commit

Permalink
fix: Module 07 corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Mahla committed Jun 11, 2024
1 parent be0a7bb commit 82a2ef8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
2 changes: 1 addition & 1 deletion module05/usefull_ressources.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ \section*{Notions of the module}
\section*{Useful Ressources}

You are strongly advise to use the following resource:
\href{https://www.coursera.org/learn/machine-learning/home/week/1}{Machine Learning MOOC - Stanford}
\href{https://www.coursera.org/learn/machine-learning}{Machine Learning MOOC - Stanford}
These videos are available at no cost; simply log in, select "Enroll for Free", and choose "audit the course for free" in the popup window.
The following sections of the course are pertinent to today's exercises:

Expand Down
2 changes: 1 addition & 1 deletion module06/usefull_ressources.tex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ \section*{Notions of the module}
\section*{Useful Ressources}

You are strongly advise to use the following resource:
\href{https://www.coursera.org/learn/machine-learning/home/week/1}{Machine Learning MOOC - Stanford}
\href{https://www.coursera.org/learn/machine-learning}{Machine Learning MOOC - Stanford}
These videos are available at no cost; simply log in, select "Enroll for Free", and choose "audit the course for free" in the popup window.
The following sections of the course are pertinent to today's exercises:

Expand Down
3 changes: 1 addition & 2 deletions module07/en.py_proj.tex
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ \chapter*{Common Instructions}

\item Your manual is the internet.

\item You can also ask questions in the \texttt{\#bootcamps} channel in the \href{https://42-ai.slack.com}{42AI}
or \href{42born2code.slack.com}{42born2code}.
\item You can also ask questions on the {https://discord.gg/8Vvb6QMCZq}{42AI} discord.

\item If you find any issue or mistakes in the subject please create an issue on \href{https://github.com/42-AI/bootcamp_python/issues}{42AI repository on Github}.

Expand Down
38 changes: 21 additions & 17 deletions module07/en.subject.tex
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ \section*{Examples}

# Example 3:
theta3 = np.array([-1.5, 0.6, 2.3, 1.98]).reshape((-1, 1))
simple_predict(X, theta3)
simple_predict(x, theta3)
# Output:
array([[ 9.64], [24.28], [38.92], [53.56]])

Expand Down Expand Up @@ -357,7 +357,7 @@ \section*{Examples}

# Example 3:
theta3 = np.array([-1.5, 0.6, 2.3, 1.98]).reshape((-1, 1))
predict_(X, theta3)
predict_(x, theta3)
# Output:
array([[ 9.64], [24.28], [38.92], [53.56]])

Expand Down Expand Up @@ -524,7 +524,7 @@ \section*{Examples}
[ 1, -5, 11],
[ 9, -11, 8]])
y = np.array([2, 14, -13, 5, 12, 4, -19]).reshape((-1, 1))
theta1 = np.array([3,0.5,-6]).reshape((-1, 1))
theta1 = np.array([0, 3, 0.5, -6]).reshape((-1, 1))

# Example :
gradient(x, y, theta1)
Expand All @@ -533,7 +533,7 @@ \section*{Examples}


# Example :
theta2 = np.array([0,0,0]).reshape((-1, 1))
theta2 = np.array([0, 0, 0, 0]).reshape((-1, 1))
gradient(x, y, theta2)
# Output:
array([[ -0.71428571], [ 0.85714286], [23.28571429], [-26.42857143]])
Expand All @@ -549,6 +549,7 @@ \section*{Examples}
\chapter{Exercise 04}
\extitle{Multivariate Gradient Descent}
\input{en.ex04_interlude.tex}
\newpage
\turnindir{ex04}
\exnumber{04}
\exfiles{fit.py}
Expand Down Expand Up @@ -708,7 +709,7 @@ \section*{Examples}
mylr.alpha = 1.6e-4
mylr.max_iter = 200000
mylr.fit_(X, Y)
mylr.theta
mylr.thetas
# Output:
array([[18.188..], [2.767..], [-0.374..], [1.392..], [0.017..]])

Expand Down Expand Up @@ -856,13 +857,13 @@ \subsubsection*{Examples}
data = pd.read_csv("spacecraft_data.csv")
X = np.array(data[['Age']])
Y = np.array(data[['Sell_price']])
myLR_age = MyLR(theta = [[1000.0], [-1.0]], alpha = 2.5e-5, max_iter = 100000)
myLR_age.fit_(X[:,0].reshape(-1,1), Y)
myLR_age = MyLR(thetas = [[1000.0], [-1.0]], alpha = 2.5e-5, max_iter = 100000)
myLR_age.fit_(X, Y)

y_pred = myLR_age.predict_(X[:,0].reshape(-1,1))
myLR_age.mse_(y_pred,Y)
y_pred = myLR_age.predict_(X)
myLR_age.mse_(Y, y_pred)
#Output
55736.86719...
55736.867198...
\end{minted}

How accurate is your model when you only take one feature into account?
Expand Down Expand Up @@ -905,26 +906,29 @@ \subsubsection*{Examples}
data = pd.read_csv("spacecraft_data.csv")
X = np.array(data[['Age','Thrust_power','Terameters']])
Y = np.array(data[['Sell_price']])
my_lreg = MyLR(theta = [1.0, 1.0, 1.0, 1.0], , alpha = 1e-4, max_iter = 600000)
my_lreg = MyLR(thetas=[1.0, 1.0, 1.0, 1.0], alpha=9e-5, max_iter=500000)


# Example 0:
my_lreg.mse_(X,Y)
my_lreg.mse_(Y, my_lreg.predict_(X))
# Output:
144044.877...


# Example 1:
my_lreg.fit_(X,Y)
my_lreg.theta
my_lreg.fit_(X, Y)
my_lreg.thetas
# Output:
array([[334.994...],[-22.535...],[5.857...],[-2.586...]])
array([[367.28849...]
[-23.69939...]
[ 5.73622...]
[ -2.63855...]])


# Example 2:
my_lreg.mse_(X,Y)
print(my_lreg.mse_(Y, my_lreg.predict_(X)))
# Output:
586.896999...
435.9325695...
\end{minted}

% ================================= %
Expand Down
30 changes: 20 additions & 10 deletions module07/usefull_ressources.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,27 @@ \section*{Notions of the module}
\section*{Useful Ressources}

You are strongly advise to use the following resource:
\href{https://www.coursera.org/learn/machine-learning/home/week/2}{Machine Learning MOOC - Stanford}
Here are the sections of the MOOC that are relevant for today's exercises:
\href{https://www.coursera.org/learn/machine-learning}{Machine Learning MOOC - Stanford}
These videos are available at no cost; simply log in, select "Enroll for Free", and choose "audit the course for free" in the popup window.
The following sections of the course are pertinent to today's exercises:

\subsection*{Week 2}
\subsection*{Week 2: Regression with multiple input variables}

\subsubsection*{Multivariate Linear Regression}
\subsubsection*{Multiple linear regression}
\begin{itemize}
\item Multiple Features (Video + Reading)
\item Gradient Descent for Multiple Variables (Video + Reading)
\item Gradient Descent in Practice I- Feature Scaling (Video + Reading)
\item Gradient Descent in Practice II- Learning Rate (Video + Reading)
\item Features and Polynomial Regression (Video + Reading)
\item Review (Reading + Quiz)
\item Multiple features
\item Gradient descent for multiple linear regression
\end{itemize}

\subsubsection*{Gradient descent in practice}
\begin{itemize}
\item Feature scaling part 1
\item Feature scaling part 2
\item Checking gradient descent for convergence
\item Choosing the learning rate
\item Feature engineering
\item Polynomial regression
\end{itemize}


\emph{All videos above are available also on this \href{https://youtube.com/playlist?list=PLkDaE6sCZn6FNC6YRfRQc_FbeQrF8BwGI&feature=shared}{Andrew Ng's YouTube playlist}, videos \#21 and from \#24 to \#30}

0 comments on commit 82a2ef8

Please sign in to comment.