<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Machine Learning</title>
	<atom:link href="https://renanmf.com/category/machine-learning/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Software development, machine learning</description>
	<lastBuildDate>Tue, 27 Jul 2021 12:03:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://renanmf.com/wp-content/uploads/2020/03/cropped-android-chrome-512x512-2-32x32.png</url>
	<title>Machine Learning</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>State of Data Science 2021: Popularity of Python</title>
		<link>https://renanmf.com/state-of-data-science-2021-popularity-of-python/</link>
		
		<dc:creator><![CDATA[Renan Moura]]></dc:creator>
		<pubDate>Tue, 27 Jul 2021 12:03:55 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[data science]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">https://renanmf.com/?p=3747</guid>

					<description><![CDATA[<p>Python continues to be an excellent choice if you are entering the data science field. Python still dominates and is the most popular language, particularly among younger generations. 88% of students surveyed are learning Python in preparation for a data science career. 63% of the respondents said they use it frequently or always. 71% of [&#8230;]</p>
<p>The content <a href="https://renanmf.com/state-of-data-science-2021-popularity-of-python/">State of Data Science 2021: Popularity of Python</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Python continues to be an excellent choice if you are entering the data science field.</p>
<p>Python still dominates and is the most popular language, particularly among younger generations.</p>
<p>88% of students surveyed are learning Python in preparation for a data science career.</p>
<p>63% of the respondents said they use it frequently or always.</p>
<p>71% of educators are teaching Python.</p>
<p><img decoding="async" src="https://renanmf.com/wp-content/uploads/2021/07/most_used_language_data.jpeg" alt="" /></p>
<p>It is also interesting to notice SQL raking 2nd place right after Python.</p>
<p>Most structured data is still in relational databases, so a good knowledge of both Python and SQL are a must to deal with data.</p>
<p>The good news is that they are both very accessible and good to begin working with code.</p>
<h2>Comments about the other languages</h2>
<p>R is an alternative to Python, but I don&#8217;t see any advantage in learning it if you are already in the Python path since R won&#8217;t bring anything to the table that Python doesn&#8217;t.</p>
<p>Then we have JavaScript and HTML/CSS, which makes sense since your results won&#8217;t live in a Word document on your computer, a good way to display them is on the web with nice interactivity.</p>
<p>Bash/Shell are super useful, the command line is one of the most powerful tools in a coder&#8217;s tool belt, not only that, but many tools that deal with data engineering like Hadoop rely heavily on the command line interfaces that can be easily automated with a nice shell script.</p>
<p>If you are wondering why Java ranks so high in this list, Hadoop, Hive, HDFS, etc. are made in Java, for instance, and many data pipelines depend on JVM powered tools like Kafka.</p>
<p>So while you may never touch Java as a Data Scientist, you will most probably have to deal with it as Data Engineer at some point.</p>
<p>C/C++ ranks high due to the number of libraries coded in these languages for high performance.</p>
<p>Python&#8217;s most used Machine Learning frameworks and libraries like Pandas are implemented in C/C++ while Python just provides a nicer API to work with.</p>
<p>The other languages (C#, TypeScript, PHP, Rust, Julia and Go), although they have their place, of course, would not be the subject of further studies from my point of view at the moment.</p>
<p>They are used for more specific use cases or simply fall into &quot;that&#8217;s what I and my team knows best&quot;.</p>
<p>The best contender here would be Julia to replace Python, but it still has ways to go before deserving the time and energy to learn it.</p>
<p>Go would be the high level performant alternative to Java, but it doesn&#8217;t have the ecosystem with as many tools behind it yet.</p>
<p>So, out of this list, the ones I think will pay you the most dividends for your investment in time and effort are Python, SQL, JavaScript, HTML/CSS, Bash/Shell, and Java.</p>
<p>These languages are more than enough to put you in any stage of a Data Science project or pipeline.</p>
<p>You can read the full report on <a href="https://www.anaconda.com/state-of-data-science-2021">State of Data Science 2021</a></p>
<p>The content <a href="https://renanmf.com/state-of-data-science-2021-popularity-of-python/">State of Data Science 2021: Popularity of Python</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Data Science and Machine Learning Project: House Prices Dataset</title>
		<link>https://renanmf.com/data-science-machine-learning-house-prices/</link>
		
		<dc:creator><![CDATA[Renan Moura]]></dc:creator>
		<pubDate>Tue, 23 Feb 2021 13:26:03 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[data science]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">https://renanmf.com/?p=3016</guid>

					<description><![CDATA[<p>This is a series on Data Science and Machine Learning applied to a House Prices dataset from the Kaggle competition House Prices: Advanced Regression Techniques. You can download a PDF version of this Data Science and Machine Learning Project with the full source code repository linked in the book. In this series we begin with [&#8230;]</p>
<p>The content <a href="https://renanmf.com/data-science-machine-learning-house-prices/">Data Science and Machine Learning Project: House Prices Dataset</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a series on Data Science and Machine Learning applied to a House Prices dataset from the Kaggle competition <a href="https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data">House Prices: Advanced Regression Techniques</a>.</p>
<p><a href="https://renanmf.com/book-ds-ml-project-house-prices/">You can download a PDF version of this Data Science and Machine Learning Project with the full source code repository linked in the book.</a></p>
<p>In this series we begin with the EDA (Exploratory Data Analysis) of the data, we create a script to clean the data, then we use the cleaned data to create a Machine Learning Model, and finally we use the Machine Learning model to implement a prediction API:</p>
<ul>
<li><a href="https://renanmf.com/exploratory-data-analysis-house-prices-part-one/">Exploratory Data Analysis – House Prices – Part 1</a></li>
<li><a href="https://renanmf.com/exploratory-data-analysis-house-prices-part-two/">Exploratory Data Analysis – House Prices – Part 2</a></li>
<li><a href="https://renanmf.com/data-science-project-data-cleaning-house-prices-dataset/">Data Science Project: Data Cleaning Script – House Prices DataSet</a></li>
<li><a href="https://renanmf.com/data-science-project-machine-learning-model-house-prices-dataset/">Data Science Project: Machine Learning Model – House Prices Dataset</a></li>
<li><a href="https://renanmf.com/data-science-project-house-prices-dataset-api/">Data Science Project: House Prices Dataset &#8211; API</a></li>
</ul>
<p>You can download the complete code in the <a href="https://github.com/renanmouraf/data-science-house-prices">Github Repository</a> with clear instructions to execute this end-to-end project.</p>
<p><strong>&gt;&gt;&gt;You can also watch how to run this project on Youtube&lt;&lt;&lt;</strong></p>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/xEfCyb-0Wsk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p>The content <a href="https://renanmf.com/data-science-machine-learning-house-prices/">Data Science and Machine Learning Project: House Prices Dataset</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Data Science Project: House Prices Dataset &#8211; API</title>
		<link>https://renanmf.com/data-science-project-house-prices-dataset-api/</link>
		
		<dc:creator><![CDATA[Renan Moura]]></dc:creator>
		<pubDate>Tue, 16 Feb 2021 20:41:21 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[FastAPI]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[data science]]></category>
		<category><![CDATA[fastapi]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">https://renanmf.com/?p=3014</guid>

					<description><![CDATA[<p>This is the 5th and final article in a series on Data Science and Machine Learning applied to a House Prices dataset from the Kaggle competition House Prices: Advanced Regression Techniques. The first four articles were the Exploratory Data Analysis (EDA), Cleaning of the dataset, and the Machine Learning model: Exploratory Data Analysis – House [&#8230;]</p>
<p>The content <a href="https://renanmf.com/data-science-project-house-prices-dataset-api/">Data Science Project: House Prices Dataset &#8211; API</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is the 5th and final article in a series on Data Science and Machine Learning applied to a House Prices dataset from the Kaggle competition <a href="https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data">House Prices: Advanced Regression Techniques</a>.</p>
<p>The first four articles were the Exploratory Data Analysis (EDA), Cleaning of the dataset, and the Machine Learning model:</p>
<ul>
<li><a href="https://renanmf.com/exploratory-data-analysis-house-prices-part-one/">Exploratory Data Analysis – House Prices – Part 1</a></li>
<li><a href="https://renanmf.com/exploratory-data-analysis-house-prices-part-two/">Exploratory Data Analysis – House Prices – Part 2</a></li>
<li><a href="https://renanmf.com/data-science-project-data-cleaning-house-prices-dataset/">Data Science Project: Data Cleaning Script – House Prices DataSet</a></li>
<li><a href="https://renanmf.com/data-science-project-machine-learning-model-house-prices-dataset/">Data Science Project: Machine Learning Model – House Prices Dataset</a></li>
<li><strong><a href="https://renanmf.com/data-science-project-house-prices-dataset-api/">Data Science Project: House Prices Dataset &#8211; API</a></strong></li>
<li><a href="https://renanmf.com/data-science-machine-learning-house-prices/">Data Science and Machine Learning Project: House Prices Dataset</a></li>
</ul>
<p>The output of the fourth article is the <a href="https://renanmf.com/wp-content/uploads/2021/02/model.zip" title="model">Machine Learning Model</a> (you have to unzip the file) that we are going to use in the API.</p>
<h2>Class HousePriceModel</h2>
<p>Save this script on a file named <code>predict.py</code>.</p>
<p>This file has the class <code>HousePriceModel</code> and is used to load the Machine Learning model and make the predictions.</p>
<pre><code class="language-python"># the pickle lib is used to load the machine learning model
import pickle
import pandas as pd

class HousePriceModel():

    def __init__(self):
        self.model = self.load_model()
        self.preds = None

    def load_model(self):
        # uses the file model.pkl
        pkl_filename = &#039;model.pkl&#039;

        try:
            with open(pkl_filename, &#039;rb&#039;) as file:
                pickle_model = pickle.load(file)
        except:
            print(f&#039;Error loading the model at {pkl_filename}&#039;)
            return None

        return pickle_model

    def predict(self, data):

        if not isinstance(data, pd.DataFrame):
            data = pd.DataFrame(data, index=[0])

        # makes the predictions using the loaded model
        self.preds = self.model.predict(data)
        return self.preds</code></pre>
<h2>The API with FastAPI</h2>
<p>To run the API:</p>
<pre><code>uvicorn api:app</code></pre>
<p>Expected output:</p>
<pre><code>INFO:     Started server process [56652]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)</code></pre>
<p>The was API created with the framework <a href="https://fastapi.tiangolo.com/">FastAPI</a>.</p>
<p>The &quot;/predict&quot; endpoint will give you a prediction based on a sample.</p>
<pre><code class="language-python">from fastapi import FastAPI
from datetime import datetime
from predict import HousePriceModel

app = FastAPI()

@app.get(&quot;/&quot;)
def root():
    return {&quot;status&quot;: &quot;online&quot;}

@app.post(&quot;/predict&quot;)
def predict(inputs: dict):

    model = HousePriceModel()

    start = datetime.today()
    pred = model.predict(inputs)[0]
    dur = (datetime.today() - start).total_seconds()

    return pred</code></pre>
<h2>Testing the API</h2>
<p>You can save the script on a file <code>test_api.py</code> and execute it directly with <code>python3 test_api.py</code> or <code>python test_api.py</code>, depending on your installation.</p>
<p>Remember to execute this test on a second terminal while the first one runs the server for the actual API.</p>
<p>Expected output:</p>
<pre><code>The actual Sale Price: 109000
The predicted Sale Price: 109000.01144237864</code></pre>
<p>The code to test the API:</p>
<pre><code class="language-python"># import requests library to make API calls
import requests
from predict import HousePriceModel

# a sample input with all the features we 
# used to train the model
sample_input = {&#039;MSSubClass&#039;: 20, &#039;MSZoning&#039;: &#039;RL&#039;, 
&#039;LotArea&#039;: 7922, &#039;Street&#039;: &#039;Pave&#039;, 
&#039;LotShape&#039;: &#039;Reg&#039;, &#039;LandContour&#039;: &#039;Lvl&#039;, 
&#039;Utilities&#039;: &#039;AllPub&#039;, &#039;LotConfig&#039;: &#039;Inside&#039;, 
&#039;LandSlope&#039;: &#039;Gtl&#039;, &#039;Neighborhood&#039;: &#039;NAmes&#039;, 
&#039;Condition1&#039;: &#039;Norm&#039;, &#039;Condition2&#039;: &#039;Norm&#039;, 
&#039;BldgType&#039;: &#039;1Fam&#039;, &#039;HouseStyle&#039;: &#039;1Story&#039;, 
&#039;OverallQual&#039;: 5, &#039;OverallCond&#039;: 7, 
&#039;YearBuilt&#039;: 1953, &#039;YearRemodAdd&#039;: 2007, 
&#039;RoofStyle&#039;: &#039;Gable&#039;, &#039;RoofMatl&#039;: &#039;CompShg&#039;, 
&#039;Exterior1st&#039;: &#039;VinylSd&#039;, &#039;Exterior2nd&#039;: &#039;VinylSd&#039;, 
&#039;MasVnrType&#039;: &#039;None&#039;, &#039;ExterQual&#039;: 3,
&#039;ExterCond&#039;: 4, &#039;Foundation&#039;: &#039;CBlock&#039;, 
&#039;BsmtQual&#039;: 3, &#039;BsmtCond&#039;: 3, 
&#039;BsmtExposure&#039;: &#039;No&#039;, &#039;BsmtFinType1&#039;: &#039;GLQ&#039;, 
&#039;BsmtFinSF1&#039;: 731, &#039;BsmtFinType2&#039;: &#039;Unf&#039;, 
&#039;BsmtFinSF2&#039;: 0, &#039;BsmtUnfSF&#039;: 326, 
&#039;TotalBsmtSF&#039;: 1057, &#039;Heating&#039;: &#039;GasA&#039;, 
&#039;HeatingQC&#039;: 3, &#039;CentralAir&#039;: &#039;Y&#039;, 
&#039;Electrical&#039;: &#039;SBrkr&#039;, &#039;1stFlrSF&#039;: 1057, 
&#039;2ndFlrSF&#039;: 0, &#039;LowQualFinSF&#039;: 0, 
&#039;GrLivArea&#039;: 1057, &#039;BsmtFullBath&#039;: 1, 
&#039;BsmtHalfBath&#039;: 0, &#039;FullBath&#039;: 1, 
&#039;HalfBath&#039;: 0, &#039;BedroomAbvGr&#039;: 3, 
&#039;KitchenAbvGr&#039;: 1, &#039;KitchenQual&#039;: 4, 
&#039;TotRmsAbvGrd&#039;: 5, &#039;Functional&#039;: &#039;Typ&#039;, 
&#039;Fireplaces&#039;: 0, &#039;FireplaceQu&#039;: 0, 
&#039;GarageType&#039;: &#039;Detchd&#039;, &#039;GarageFinish&#039;: &#039;Unf&#039;,
&#039;GarageCars&#039;: 1, &#039;GarageArea&#039;: 246, 
&#039;GarageQual&#039;: 3, &#039;GarageCond&#039;: 3, 
&#039;PavedDrive&#039;: &#039;Y&#039;, &#039;WoodDeckSF&#039;: 0, 
&#039;OpenPorchSF&#039;: 52, &#039;EnclosedPorch&#039;: 0, 
&#039;3SsnPorch&#039;: 0, &#039;ScreenPorch&#039;: 0, 
&#039;PoolArea&#039;: 0, &#039;MiscVal&#039;: 0, &#039;MoSold&#039;: 1,
&#039;YrSold&#039;: 2010, &#039;SaleType&#039;: &#039;WD&#039;, 
&#039;SaleCondition&#039;: &#039;Abnorml&#039;}

def run_prediction_from_sample():

    url=&quot;http://127.0.0.1:8000/predict&quot;
    headers = {&quot;Content-Type&quot;: &quot;application/json&quot;, \
    &quot;Accept&quot;:&quot;text/plain&quot;}

    response = requests.post(url, headers=headers, \
    json=sample_input)
    print(&quot;The actual Sale Price: 109000&quot;)
    print(f&quot;The predicted Sale Price: {response.text}&quot;)

if __name__ == &quot;__main__&quot;:
    run_prediction_from_sample()</code></pre>
<p>The content <a href="https://renanmf.com/data-science-project-house-prices-dataset-api/">Data Science Project: House Prices Dataset &#8211; API</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Data Science Project: Machine Learning Model &#8211; House Prices Dataset</title>
		<link>https://renanmf.com/data-science-project-machine-learning-model-house-prices-dataset/</link>
		
		<dc:creator><![CDATA[Renan Moura]]></dc:creator>
		<pubDate>Wed, 10 Feb 2021 14:34:50 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[data science]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">https://renanmf.com/?p=2992</guid>

					<description><![CDATA[<p>This is the fourth article in a series on Data Science and Machine Learning applied to a House Prices dataset from the Kaggle competition House Prices: Advanced Regression Techniques. The first three articles were the Exploratory Data Analysis (EDA) and cleaning of the dataset: Exploratory Data Analysis – House Prices – Part 1 Exploratory Data [&#8230;]</p>
<p>The content <a href="https://renanmf.com/data-science-project-machine-learning-model-house-prices-dataset/">Data Science Project: Machine Learning Model &#8211; House Prices Dataset</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is the fourth article in a series on Data Science and Machine Learning applied to a House Prices dataset from the Kaggle competition <a href="https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data">House Prices: Advanced Regression Techniques</a>.</p>
<p>The first three articles were the Exploratory Data Analysis (EDA) and cleaning of the dataset:</p>
<ul>
<li><a href="https://renanmf.com/exploratory-data-analysis-house-prices-part-one/">Exploratory Data Analysis – House Prices – Part 1</a></li>
<li><a href="https://renanmf.com/exploratory-data-analysis-house-prices-part-two/">Exploratory Data Analysis – House Prices – Part 2</a></li>
<li><a href="https://renanmf.com/data-science-project-data-cleaning-house-prices-dataset/">Data Science Project: Data Cleaning Script – House Prices DataSet</a></li>
<li><strong><a href="https://renanmf.com/data-science-project-machine-learning-model-house-prices-dataset/">Data Science Project: Machine Learning Model – House Prices Dataset</a></strong></li>
<li><a href="https://renanmf.com/data-science-project-house-prices-dataset-api/">Data Science Project: House Prices Dataset &#8211; API</a></li>
<li><a href="https://renanmf.com/data-science-machine-learning-house-prices/">Data Science and Machine Learning Project: House Prices Dataset</a></li>
</ul>
<p>The output of the first three articles is the <a href="https://renanmf.com/wp-content/uploads/2021/02/cleaned_data.zip">cleaned_dataset</a> (you have to unzip the file to use the CSV) that we are going to use to generate the Machine Learning Model.</p>
<h2>Training the Machine Learning Model</h2>
<p>You can save the script on a file <code>train_model.py</code> and execute it directly with <code>python3 train_model.py</code> or <code>python train_model.py</code>, depending on your installation.</p>
<p>It expects you to have a file called &#8216;cleaned_data.csv&#8217; (you can download it on the link above in ZIP format) on the same folder and will output three other files:</p>
<ul>
<li>model.pkl: the model in binary format generated by pickle that we can reuse later</li>
<li>train.csv: the <strong>train</strong> data after the split of the original data into train and test</li>
<li>test.csv: the <strong>test</strong> data after the split of the original data into train and test</li>
</ul>
<p>The output on the terminal will be similar to this:</p>
<pre><code>Train data for modeling: (934, 74)
Test data for predictions: (234, 74)
Training the model ...
Testing the model ...
Average Price Test: 175652.0128205128
RMSE: 10552.188828855931
Model saved at model.pkl</code></pre>
<p>It means the models used 934 data point to train and 234 data points to test.</p>
<p>The average Sale Price in the test set is 175k dollars.</p>
<p>The RMSE (root-mean-square error) is a good metric to understand the output because in you can read it using the same scale of you dependent variable, which is Sale Price in this case.</p>
<p>A RMSE of 10552 means that, on average, we missed the correct Sale Prices by a bit over 10k dollars.</p>
<p>Considering an average if 175k, missing the mark, on average, by 10k, is not too bad.</p>
<h2>The Training Script</h2>
<pre><code class="language-python">import numpy as np
import pandas as pd
from sklearn.preprocessing import OneHotEncoder
from sklearn.metrics import mean_squared_error
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import Pipeline
import pickle

def create_train_test_data(dataset):
    # load and split the data
    data_train = dataset.sample(frac=0.8, random_state=30).reset_index(drop=True)
    data_test = dataset.drop(data_train.index).reset_index(drop=True)

    # save the data
    data_train.to_csv(&#039;train.csv&#039;, index=False)
    data_test.to_csv(&#039;test.csv&#039;, index=False)

    print(f&quot;Train data for modeling: {data_train.shape}&quot;)
    print(f&quot;Test data for predictions: {data_test.shape}&quot;)

def train_model(x_train, y_train):

    print(&quot;Training the model ...&quot;)

    model = Pipeline(steps=[
        (&quot;label encoding&quot;, OneHotEncoder(handle_unknown=&#039;ignore&#039;)),
        (&quot;tree model&quot;, LinearRegression())
    ])
    model.fit(x_train, y_train)

    return model

def accuracy(model, x_test, y_test):
    print(&quot;Testing the model ...&quot;)
    predictions = model.predict(x_test)
    tree_mse = mean_squared_error(y_test, predictions)
    tree_rmse = np.sqrt(tree_mse)
    return tree_rmse

def export_model(model):
    # Save the model
    pkl_path = &#039;model.pkl&#039;
    with open(pkl_path, &#039;wb&#039;) as file:
        pickle.dump(model, file)
        print(f&quot;Model saved at {pkl_path}&quot;)

def main():
    # Load the whole data
    data = pd.read_csv(&#039;cleaned_data.csv&#039;, keep_default_na=False, index_col=0)

    # Split train/test
    # Creates train.csv and test.csv
    create_train_test_data(data)

    # Loads the data for the model training
    train = pd.read_csv(&#039;train.csv&#039;, keep_default_na=False)
    x_train = train.drop(columns=[&#039;SalePrice&#039;])
    y_train = train[&#039;SalePrice&#039;]

    # Loads the data for the model testing
    test = pd.read_csv(&#039;test.csv&#039;, keep_default_na=False)
    x_test = test.drop(columns=[&#039;SalePrice&#039;])
    y_test = test[&#039;SalePrice&#039;]

    # Train and Test
    model = train_model(x_train, y_train)
    rmse_test = accuracy(model, x_test, y_test)

    print(f&quot;Average Price Test: {y_test.mean()}&quot;)
    print(f&quot;RMSE: {rmse_test}&quot;)

    # Save the model
    export_model(model)

if __name__ == &#039;__main__&#039;:
    main()</code></pre>
<p>The content <a href="https://renanmf.com/data-science-project-machine-learning-model-house-prices-dataset/">Data Science Project: Machine Learning Model &#8211; House Prices Dataset</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Computer Science or Computer Engineering for Machine Learning/AI</title>
		<link>https://renanmf.com/computer-science-or-computer-engineering-for-machine-learning-ai/</link>
		
		<dc:creator><![CDATA[Renan Moura]]></dc:creator>
		<pubDate>Wed, 30 Sep 2020 22:30:06 +0000</pubDate>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[lab]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">https://renanmf.com/?p=2047</guid>

					<description><![CDATA[<p>I received a question from a reader directly on my e-mail about which degree to pursue to get into Machine Learning/Artificial Intelligence. This is the e-mail Jeremy sent me. Hi I will start by saying sorry for the intrusive direct e-mail. I got your e-mail address from being one of your twitter followers and reading [&#8230;]</p>
<p>The content <a href="https://renanmf.com/computer-science-or-computer-engineering-for-machine-learning-ai/">Computer Science or Computer Engineering for Machine Learning/AI</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I received a question from a reader directly on my e-mail about which degree to pursue to get into Machine Learning/Artificial Intelligence.</p>
<p>This is the e-mail Jeremy sent me.</p>
<blockquote>
<p>Hi I will start by saying sorry for the intrusive direct e-mail. I got your e-mail address from being one of your twitter followers and reading you great book on python. Please could you help me answer this question&#8230;? Computer science or computer engineering for a career in machine learning/Ai. I work full time in another industry ( which I dislike with a passion) so need to focus all my spare time on the right path for me. I’m in my forties now so wish to chase my dream, which I should of done years ago but due to circumstances I was unable. Kind Regards Jeremy</p>
</blockquote>
<p>My personal opinion on this question:</p>
<p>For starters, you should focus on becoming a good programmer, not an expert, but a good one.</p>
<p>Programming is a skill that will make your life much easier in all the steps of the machine learning pipeline.</p>
<p>If you have no experience with programming, I have a free <a href="https://renanmf.com/the-python-guide-for-beginners/">Python Guide For Beginners</a>.</p>
<p>Python is the main language to work with Machine Learning today.</p>
<p>Then you should try to learn Machine Learning on your own with some courses online to see how you like it.</p>
<p>It will take you a couple of months to finish an intro course on Machine Learning and then you can work on some projects on your own.</p>
<p>Here is a guide with resources to learn ML online: <a href="https://renanmf.com/machine-learning-and-deep-learning-software-engineers/">How to Learn Machine Learning and Deep Learning: a guide for Software Engineers</a>.</p>
<p>That said, If you want to work on AI and want a more formal education, the choice of CS vs. CE depends a lot on the university you are attending, the overall curriculum changes a lot from one to another.</p>
<p>Pretty much all CS and CE courses have AI classes, so that is not an issue.</p>
<p>But to give you a final answer, I would say Computer Science because, usually, Computer Engineering has lots of classes related to electronics/hardware which are not inline with your initial focus, so go with CS.</p>
<p>The content <a href="https://renanmf.com/computer-science-or-computer-engineering-for-machine-learning-ai/">Computer Science or Computer Engineering for Machine Learning/AI</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Learn Machine Learning and Deep Learning: a guide for Software Engineers</title>
		<link>https://renanmf.com/machine-learning-and-deep-learning-software-engineers/</link>
					<comments>https://renanmf.com/machine-learning-and-deep-learning-software-engineers/#comments</comments>
		
		<dc:creator><![CDATA[Renan Moura]]></dc:creator>
		<pubDate>Tue, 28 Jan 2020 17:48:33 +0000</pubDate>
				<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[deep learning]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">https://renanmf.com/?p=348</guid>

					<description><![CDATA[<p>Introduction The subject of Artificial Intelligence piques my interest and I&#8217;m constantly studying and trying new things in this field. It is notorious how the technologies related to Natural Language Processing, Computer Vision and such have emerged and evolved into solutions used by millions of users every day. Even though people use the term &#34;Artificial [&#8230;]</p>
<p>The content <a href="https://renanmf.com/machine-learning-and-deep-learning-software-engineers/">How to Learn Machine Learning and Deep Learning: a guide for Software Engineers</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p>The subject of Artificial Intelligence piques my interest and I&#8217;m constantly studying and trying new things in this field.</p>
<p>It is notorious how the technologies related to Natural Language Processing, Computer Vision and such have emerged and evolved into solutions used by millions of users every day.</p>
<p>Even though people use the term &quot;Artificial Intelligence&quot;, we are still far away from something as advanced as a Skynet from the Terminator movies.</p>
<p>The most common subfield of AI used today is the one called Machine Learning, which, in its turn, has Deep Learning as subfield steeply growing every day for quite some time now.</p>
<p>In this guide, I aim to describe a path to follow for software engineers to begin understanding how Machine Learning works and how to apply it to your projects.</p>
<p>Yeah, you can just go to Google API&#8217;s or Amazon and pick some magical API to do Speech Recognition for you, but the value of knowing how it works, why it works and even more, how to make your own API as a Service and tune it to your specific needs is incredible.</p>
<p>Remember, as a developer, every tool is a new power.</p>
<p>I&#8217;ve read, watched and gone through all these resources until the end, even got a paid certification for some, even though it is not necessary to learn, I find myself more engaged to finish when I have some deadline and assessment to prove I actually learned the material.</p>
<p>Let&#8217;s dive into the topics.</p>
<h2>Python</h2>
<p>Python is the main language these days when working with Data Science, Machine Learning, and Deep Learning.</p>
<p>If you need a crash course on Python, here is your guide: <a href="https://renanmf.com/the-python-guide-for-beginners/">The Python Guide for Beginners</a>.</p>
<h2>The Basics: Math!</h2>
<p>Maybe you never had the chance to study some college-level math, or you did study it but you can&#8217;t remember most of the stuff because JavaScript and CSS took all the memory of those topics away.</p>
<p>There are 3 topics you must know beforehand, or at least have a decent grasp of to follow any good material on ML and DL: Linear Algebra, Calculus and Statistics.</p>
<p>If you&#8217;d like to go deep in learning the math needed to ML and DL, you can look for MIT OpenCourseWare classes like Professor Strang&#8217;s renowned <a href="https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/">Linear Algebra</a> class.</p>
<p>I&#8217;ve watched it in college in parallel with my regular class and it is very good.</p>
<p>But, let&#8217;s face it, most people have no time for that or the patience.</p>
<p>So I will give you the crash course for the 3 topics mentioned above.</p>
<h3>Linear Algebra</h3>
<p>Just watch the whole series <a href="https://www.youtube.com/watch?v=fNk_zzaMoSs&amp;list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab">Essence of Linear Algebra</a> from the Youtube channel 3Blue1Brown.</p>
<p>The guy makes visual explanations of once hard concepts incredibly easy!</p>
<p>It is very far in terms of content compared to Professor Strang&#8217;s, but it&#8217;s enough, to begin with, and you can go after other topics as you advance in ML and DL.</p>
<h3>Calculus</h3>
<p>Guess what?</p>
<p>3Blue1Brown also has a whole series on Calculus on Youtube for you to watch for free: <a href="https://www.youtube.com/watch?v=WUvTyaaNkzM&amp;list=PLZHQObOWTQDMsr9K-rj53DwVRMYO3t5Yr">Essence of Calculus</a>.</p>
<p>Again, he is very good at giving you the intuition of why and how rather than just throw some random equations on your face.</p>
<h3>Statistics</h3>
<p>This is a whole field that, in my opinion, you can learn as needed, a good reference is <a href="https://www.amazon.com/Practical-Statistics-Data-Scientists-Essential/dp/1491952962">Practical Statistics for Data Scientists: 50 Essential Concepts</a>.</p>
<p>An objective book with some good examples for every concept.</p>
<p>Fast to read too.</p>
<p>As the title implies, it is more suitable for Data Scientists, but understanding some basics of statistics is always good and this is what this is book is for.</p>
<p>You won&#8217;t become a statistician after reading it, but you will learn some good stuff.</p>
<h2>The Bypassed: Machine Learning</h2>
<p>Everybody wants to jump straight into Deep Learning and be the cool guy training a single model for a week on a 12GB GPU.</p>
<p>But to get Deep Learning right, you need to go through Machine Learning first!</p>
<h3>Start from the beginning</h3>
<p>The concepts, the train of thought, the &quot;feeling&quot; of how things work start here and there is no one else more capable of teaching those concepts than Professor Andrew Ng in his course <a href="https://www.coursera.org/learn/machine-learning">Machine Learning</a>.</p>
<p>You may think this course is old and outdated, well, technology-wise, maybe, but conceptually-wise, it is better than anything else out there.</p>
<p>Professor Ng makes it easy to understand the math applied in every technique he teaches and gives you a solid understanding of what happens underneath in a very short and concise course.</p>
<p>All the exercises are made in Octave, a free version of Matlab of sorts, and you finish the course implementing your own Neural Network!</p>
<p>The syntax in Octave is easy to grasp for any programmer, so don&#8217;t let that be a barrier for you.</p>
<p>Once you finish the course, you will have implemented all the major algorithms and will be able to solve several prediction problems.</p>
<h3>Random Forests</h3>
<p>I said all the major algorithms, right?</p>
<p>Actually, there is but one flaw in Andrew Ng&#8217;s course, he doesn&#8217;t cover Random Forests.</p>
<p>An awesome complement to his course is fast.ai&#8217;s <a href="http://course18.fast.ai/ml">Introduction to Machine Learning for Coders</a>.</p>
<p>Jeremy Howard goes super practical on the missing piece in Ng&#8217;s course covering a topic that is, for many classical problems, the best solution out there.</p>
<p>Fast.ai&#8217;s approach is what is called Top-Down, meaning they show you how to solve the problem and then explain why it worked, which is the total opposite of what we are used to in school.</p>
<p>Jeremy also uses real-world tools and libraries, so you learn by coding in industry-tested solutions.</p>
<h2>Deep Learning</h2>
<p>Finally!</p>
<p>The reason why we are all here, Deep Learning!</p>
<p>Again, the best resource for it is Professor Ng&#8217;s course, actually, a series of courses.</p>
<p>The <a href="https://www.deeplearning.ai/deep-learning-specialization/">Deep Learning Specialization</a> is composed of 5 courses total going from the basics and evolving on specific topics such as language, images, and time-series data.</p>
<p>One nice thing is that he continues from the very end of his classical Machine Learning course, so it just feels like an extension of the first course.</p>
<p>The math, the concepts, the notion of how and why it works, he delivers it all very concisely like few I&#8217;ve seen.</p>
<p><del>The only drawback is that he uses <a href="https://www.tensorflow.org/">Tensorflow</a> 1.x (Google&#8217;s DL Framework) in this course, but that&#8217;s minimal detail in my opinion since the explanations and exercises are so well delivered.</del></p>
<p><del>You can pick up the most recent version of the framework relatively easy and to do so there is the final piece of this guide, a book.</del></p>
<p><strong>UPDATE APRIL 2021</strong>: The course was updated and now features <a href="https://www.tensorflow.org/">Tensorflow</a> 2 and some extra topics.</p>
<h3>Too much stuff, give me something faster</h3>
<p>This book might be the only thing you need to start, it is Aurélien Géron&#8217;s <a href="https://www.amazon.com.br/Hands-Machine-Learning-Scikit-Learn-TensorFlow-ebook/dp/B07XGF2G87">Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems</a>.</p>
<p>It covers a lot, from classical Machine Learning to the most recent Deep Learning topics. Good examples and exercises using industry-grade frameworks and libraries.</p>
<p>I dare say that, if you are really in a rush, you can skip everything I said before and just go for the book.</p>
<p>You will miss a good amount of information contained on the other resources mentioned, but the practical and actionable knowledge from Géron&#8217;s book is enough to work on many ideas for your next project.</p>
<p>If you feel limited after only reading the book, go back and study the rest of the material, it will fill in the gaps you might have and give you a more solid understanding.</p>
<h2>What about Framework X or Y?</h2>
<p>&quot;Hey, I&#8217;ve heard about PyTorch and that other framework or library X everybody talks about&quot;.</p>
<p>As a Software Engineer, you know better than anyone how fast technology evolves.</p>
<p>Don&#8217;t go crazy for that, after you learn the basics in this guide, you can easily go, for instance, on <a href="https://pytorch.org/">PyTorch</a> documentation or any other library or framework of sorts and learn how to use it in a week or two.</p>
<p>The techniques, the concepts, are all the same, it is only a matter of syntax and application or even tastes that you might have for any given tool.</p>
<h2>Conclusion</h2>
<p>To wrap it up, I want to say that, even though it might seem a lot, I tried to remove all the noise and at the end of the process, you will feel confident that you understand what is happening behind the curtains, the jargons and even be able to read some papers published in the field to keep up with the latest advances.</p>
<p>TL;DR Here is the list of resources mentioned in sequence:</p>
<ul>
<li><a href="https://renanmf.com/the-python-guide-for-beginners/">The Python Guide for Beginners</a></li>
<li><a href="https://www.youtube.com/watch?v=fNk_zzaMoSs&amp;list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab">Essence of Linear Algebra</a></li>
<li><a href="https://www.youtube.com/watch?v=WUvTyaaNkzM&amp;list=PLZHQObOWTQDMsr9K-rj53DwVRMYO3t5Yr">Essence of Calculus</a></li>
<li><a href="https://www.coursera.org/learn/machine-learning">Machine Learning</a></li>
<li><a href="http://course18.fast.ai/ml">Introduction to Machine Learning for Coders</a></li>
<li><a href="https://www.deeplearning.ai/deep-learning-specialization/">Deep Learning Specialization</a></li>
<li><a href="https://www.amazon.com.br/Hands-Machine-Learning-Scikit-Learn-TensorFlow-ebook/dp/B07XGF2G87">Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems</a></li>
</ul>
<h2>Watch on Youtube</h2>
<p>You can also watch this content on Youtube:</p>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/-uxyG_VAsyo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p>The content <a href="https://renanmf.com/machine-learning-and-deep-learning-software-engineers/">How to Learn Machine Learning and Deep Learning: a guide for Software Engineers</a> is from <a href="https://renanmf.com">Renan Moura - Software Engineering</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://renanmf.com/machine-learning-and-deep-learning-software-engineers/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
