: Oliver Theobald
: Machine Learning& Python for Absolute Beginners A Hands-On Guide to Python Programming and Machine Learning from Scratch
: Packt Publishing
: 9781806380046
: 1
: CHF 14.10
:
: Programmiersprachen
: English
: 248
: DRM
: PC/MAC/eReader/Tablet
: ePUB

Starting with Python syntax and data types, this guide builds toward implementing key machine learning models. Learn about loops, functions, OOP, and data cleaning, then transition into algorithms like regression, KNN, and neural networks. A final section walks you through model optimization and building projects in Python.
The book is split into two major sections-foundational Python programming and introductory machine learning. Readers are guided through essential concepts such as data types, variables, control flow, object-oriented programming, and using libraries like pandas for data manipulation.
In the machine learning section, topics like model selection, supervised vs unsupervised learning, bias-variance, and common algorithms are demystified with practical coding examples. It's a structured, clear roadmap to mastering both programming and applied ML from zero knowledge.

 

2

 


 

 

VARIABLES


 

While solving mathematical equations can help us to familiarize ourselves with inputs and outputs, and operating the Python interpreter, we’re not yet utilizing the many awesome features that come packed in with Python. Let’s unbox some of these features, beginning with the ability to create and assign variables.

 

2.1 About Variables


Variables are a fundamental part of Python and many other programming languages. In mathematics, a variable is something that varies, such as the price of a product item or the height of a person. However, in computer programming, the role of a variable is to store a defined value in the computer’s memory for ongoing use. This enables earlier code to be saved, referenced, and manipulated later down the line. Once you have created a new variable name and assigned a value to it, you can ask the Python interpreter to call the saved value by entering that unique variable name.

To create a variable in Python, you first need to type out a unique name and assign it to a value using the equals (=) operator. For instance, using the equals operator, we can assign the value 0.2 as our income tax rate and 50000 as our annual income.

 

Example 1

# Assign two variables

tax_rate = 0.2

annual_income = 50000

 

Now, anytime we refer to the variabletax_rate, the Python interpreter will understand this as equal to 0.2. Likewise, anytime we refer to the variableannual_income, the Python interpreter will understand this as equal to 50000, as demonstrated in the next example.

 

Example 2

# Multiply tax rate by annual income

tax_rate * annual_income

Out: 10000.0

 

The Python interpreter recognizes the variable namestax_rateandannual_incomeand automatically multiplies these variables based on their assigned values (0.2 * 50000 = 10000.0).

 

2.2 The Equals Operator


In Python, it’s important to remember that the equals operator does not perform the same role as an equals sign in mathematics. While the equals operator is used in Python to assign a variable and save an associated value, it is not connected to any mathematical logic.

 

Example 3

# Create a new variable

one = 2 + 2

 

In the example above, the value2 + 2is stored in a variable calledone. This example shows that the variable name doesn’t have to be equal or even relate to what’s packed inside the variable. However, it does make sense to name your variables based on what value is contained inside. Similar to the way you might pack boxes labeled “kitchen” and “garage” when moving to a new home, naming conventions in Python help you to find and manage variables more efficien