## Logistic Regression in R

In data science and Statistics, it is a regression model if the dependent variable results in categorical values like True/False, Yes/No, or 0/1. Usually, the logistic regression model is binomial. However, it can be extended. It measures the probability of the successfulness or failure of an event as a dependent variable which is based on a mathematical equation. This equation relates the dependent variable (response variable) with the independent variables (predictor).

We can say that logistic regression is a generalized form of linear regression but the main difference is in the predicted value range is (-∞, ∞) while the range of predicted value in logistic regression is (0,1). In this post, we will learn about logistic regression and how to implement it in the R programming language.

## Why use logistic regression

After understanding the relationship between independent (predictor variables) and dependent (response variable), linear regression is often used. When the dependent variable is categorical, it is better to choose logistic regression. It is one of the simplest models but very useful in different applications because it is easy to interpret and fast in implementation.

In logistic regression, we try to categorize the data/observation into distinct classes which shows that logistic regression is a classification algorithm. Logistic regression can be useful in different applications such as:

We can use the credit record and bank balance of a customer to predict whether the customer is eligible to take the loan from the bank or not (response variable will be “eligible” or “non-eligible. You can access from the condition above that the response variable can have only two values. Whereas in linear regression the dependent variable can take more continuous multiple values.

## Logistic regression in R in Ubuntu 20.04

In R when the response variable is binary, the best to predict a value of an event is to use the logistic regression model. This model uses a method to find the following equation:

Log [p(X) / (1-p(X))] = β0 + β1X1 + β2X2 + … + βpXp

Xj is the jth predictor variable and βj is the coefficient estimate for the Xj. An equation is used by the logistic regression model to calculate the probability and generates the observation/output of value 1. That means the output with a probability equal to 0.5 or greater will be considered as value 1. Other than that all values will be considered as 0.

p(X) = eβ0 + β1X1 + β2X2 + … + βpXp / (1 + eβ0 + β1X1 + β2X2 + … + βpXp)

The following step-by-step example will teach you how to use logistic regression in R.

Step 1: Load the data for the model in R
First, we have to load a default dataset to demonstrate the use of the model. This dataset consists of 1000 observations as displayed below.

In this dataset columns, the default is showing whether an individual is a default. The student is showing whether an individual is a student. Balance is showing the average balance of an individual. And income is indicating the income of an individual. To build a regression model the status, bank balance, and income will be used to predict the probability of the individuals are default.

Step 2: Training and test samples creation
We will divide the dataset into a testing set and a training set to test and train the model.

70% of data is used for the training set and 30% for the testing set.

Step 3: Fitting Logistic regression
In R, to fit logistic regression we have to use a glm function and set the family to binomial.

In log odds, the average change is indicated by the coefficients. The P-value of student status is 0.0843 P-value of balance is <0.0000, P-value of income is 0.4304. These values are showing how effectively each independent variable is at predicting the likelihood of default.

In R, to check how well our logistic model fits in data McFadden’s, R2 metric is used. It ranges from 0 to 1. If the value is close to 0 it indicates the model is not fit. However, values over 0.40 are considered a fit model. The pR2 function can be used to compute McFadden’s R2.

As the value above is above 0.472, it is indicating that our model has high predictive power as well as the model is fit.

The importance of a function can also be calculated by the use of the varImp function. The higher value indicates that the importance of that variable will be higher than others.

Step 4: Use the Logistic regression model to make predictions
After fitting the regression model, we can’t make predictions about whether an individual will default or not on different values of balance, income, and the status of the student:

As we can see, if the balance is 1400, income is 2000 with the status of student “Yes” having a 0.02732106 probability of defaulting. On the other hand, an individual having the same parameters but Student status “No” has a 0.0439 probability of defaulting.

to calculate every individual in our dataset, the following code is used.

predicted <- predict(model, test, type=»response»)

Step 5: Diagnosing the Logistic regression model:
In this last step, we will analyze the performance of our model on the test database. By default, the individuals having a probability greater than 0.5 will be predicted “default”. However, using the optimalCutoff() function will maximize the precision of our model.

As we can see above, 0.5451712 is the optimal probability cutoff. So, an individual having a probability of 0.5451712 of being “default” or greater will be considered as “default”. However, an individual has a probability less than 0.5451712 will be considered as “not default”

## Conclusion

After going through this tutorial you should be familiar with logistic regression in R programming language in Ubuntu 20.04. You will also be able to identify when you should use this model and why it is important with binomial values. With the help of codes and equations, we have implemented the five steps of using the logistic regression in R with examples to explain it in detail. These steps cover everything starting from loading data to R, training and testing the dataset, fitting the model, and prediction making to model diagnostics.

## Do Chromebooks have Bluetooth?

Chromebooks are similar to laptops in design but they are different in software and operating systems. Chromebooks have ChromeOS in them. When it comes to sharing data, Bluetooth technology has changed the concept of data sharing among laptops and phones. Bluetooth sharing is faster than the old technology and the range of Bluetooth is also remarkable. The main feature of Bluetooth sharing is that it’s 100% wireless.

If you want to purchase a Chromebook you must be wondering whether Chromebook includes a Bluetooth feature? If you are not sure about that, read this article where we will provide you with the answer to your question.

## Do Chromebooks have Bluetooth?

When it comes to connectivity options, older versions of Chromebooks didn’t have Bluetooth built-in features. The latest versions of Chromebooks have a Bluetooth connectivity feature, making it easy to share and transfer data. Bluetooth connectivity is important in some ways e.g. when you are using a wireless keyboard and mouse, it will work through a Bluetooth connection.

## Can Bluetooth be used to connect something with a Chromebook?

There are some wireless devices that can be connected through Bluetooth with Chromebooks:

• Mouse
• Keyboard
• Speakers

## Can the Bluetooth connectivity be checked in Chromebook?

Follow these steps to check whether your Chromebook has a Bluetooth connectivity option or not :

Step 1: On your Chromebook home screen click on the display time on the right corner of the screen:

Step 2: A notification panel of a Chromebook will open and there might be a Bluetooth symbol present, if a Bluetooth symbol is present then your device has Bluetooth functionality:

## How to connect a Bluetooth device to a Chromebook?

It’s very easy to connect the Bluetooth device to your Chromebook, Make sure the Bluetooth device you want to connect is nearby and ready to pair up with Chromebook:

To activate the Bluetooth connectivity follow the simple steps given below:

Step 1: Click on the display time and select Bluetooth, a panel will open with a list of all the active devices.

Step 2: Click on the device name you want to connect and then click on connect option, and follow additional instructions if any.

There will be a displayed password on the screen or in the documentation, which some devices may require to open up.

Select the paired devices from the menu to check your Bluetooth connectivity status.

## How to disconnect the paired Bluetooth devices with your Chromebook?

All devices including Chromebook do have a function that allows you to disconnect the previously connected devices. Follow the simple steps mentioned below:

• Select the status tray and click on Bluetooth-enabled settings
• Select a device to unpair it with your chromebook
• Click on more options and select disconnect

## Bluetooth connectivity issues

Connecting your Bluetooth device to your Chromebook may not always work. When you try to pair the devices an error message pops on the screen saying that “Bluetooth connection failed”. To fix these issues with your Chromebook Bluetooth function, follow these tips:

• Make sure the Bluetooth device is compatible with Chromebook
• Turn off the Bluetooth connection and then turn on

## Conclusion

Bluetooth is the easiest way of sharing data with other devices and is a must-have option in every laptop. If you haven’t been able to find a Bluetooth option in your Chromebook, you must follow the above-mentioned guidelines where you will be able to learn how to enable and disable the Bluetooth option in your Chromebook. In case, if you run into a problem, we have also provided ways to cope with them so that you will be able to use the Bluetooth option in your Chromebook.

## Synchronizing Files on your Raspberry Pi with Syncthing

Syncthing is an open-source file synchronization application used to synchronize files between multiple devices, such as smartphones, personal computers, or embedded devices like Raspberry Pi. It provides a secure platform to easily share your files to other devices without using any third-party application, thus making life relatively easy and fast.

## Synchronizing Files on Raspberry Pi with Syncthing

The installation of Syncthing doesn’t requires any complex installation method instead you can easily complete its installation of your Raspberry Pi device using the following simple steps:

## Step 1: Updating Raspberry Pi Packages

Before moving towards Syncthing setup, it’s better to first update your Raspberry Pi packages using the below-mentioned command:

\$ sudo apt update && sudo apt upgrade

## Step 2: Installing Prerequisite

After updating the package, you will also need to install an additional package called “apt-transport-https” as this will handle the source that will operate over HTTPS service. You can install this package through following command:

\$ sudo apt install apt-transport-https

Next, you will also need to download and save GPG Key using the following command to ensure that the package is coming from a trusted source.

\$ curl -s https://syncthing.net/release-key.txt | gpg –dearmor | sudo tee /usr/share/keyrings/syncthing-archive-keyring.gpg >/dev/null

The above command will successfully add the GPG key.

## Step 4: Adding Syncthing Repository

After adding the GPG key, you can apply the following command to add the Syncthing repository to the Raspberry Pi source list.

\$ echo «deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable» | sudo tee /etc/apt/sources.list.d/syncthing.list

## Step 5: Updating the Source List

Merienda, you add the Syncthing repository, you will need to update the Raspberry Pi source list using the following command:

The above command updates the Raspberry Pi’s repository list.

## Step 6: Install Syncthing on Raspberry Pi

With source list updated, you can use the following command to install Syncthing on Raspberry Pi:

\$ sudo apt install syncthing

## Step 7: Running Syncthing on Raspberry Pi

After successfully installing Syncthing on Raspberry Pi, execute the following command to run Syncthing on Raspberry Pi.

When you execute the above command, it will open the Syncthing web interface with the address “127.0.0.1:8384” on your browser. It also generates the configuration file with the first time execution. You have to close the browser and use the “Ctrl+C” keys in the terminal to stop Syncthing on Raspberry Pi.

Note: It is important to open Syncthing at least merienda before moving towards the next step.

## Step 8: Opening Syncthing Configuration File

To make the changes, you have to open the Syncthing configuration file using the following command:

\$ sudo nano ~/.config/syncthing/config.xml

Within this file, find the below-given line:

You can use “Ctrl+W” to find the above line in the file.

Now, change the IP inside the line with the IP address of your Raspberry Pi and you can find your Raspberry Pi address through following command:

Save the above file by using the keys “CTRL+X”, Y and press enter to exit. We are doing this step just to ensure that only the trusted users who are connected with our restringido network will have access to the files.

## Step 9: Creating a Service File

In the final configuration step, we have to do one last task that is to make a service file for Syncthing using the following command:

\$ sudo nano /lib/systemd/system/syncthing.service

Add the following information inside the file:

[Unit]
Description=Syncthing
Documentation=man:syncthing(1)
After=network.target

[Service]
User=raspberrypi
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
RestartSec=5
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Save the file and finish creating the Syncthing service file on Raspberry Pi .

## Step 10: Enabling Syncthing Service

After creating a service file for Syncthing, you will need to enable the service again through the following command:

\$ sudo systemctl enable syncthing

## Step 11: Starting Syncthing Service

Now start the Syncthing service on Raspberry Pi using the below-mentioned command:

\$ sudo systemctl start syncthing

## Step 12: Checking Syncthing Service

You will also need to ensure whether the Syncthing service is running fine on your Raspberry Pi and you can do so by issuing the following command::

\$ sudo systemctl status syncthing

This ensures that the Syncthing service is running perfectly fine.

## Step 13: Accessing Syncthing Web Interface

Now use the address http://192.168.100.162:8384/ to access the web interface on your browser.

First, you will need to ensure Syncthing privacy so only you can can access your files on your system and you can do this by clicking on the “Settings” option.

In the “GUI” tab, enter username, provide password and then click on the “Save” button.

As soon as you save the changes, you will have to provide your username and password to access the web interface.

To synchronize the files between the devices, you will need to add the device ID by clicking on the “Add Remote Device” option. The device you want to add must have a Syncthing install and the device ID will be inside the application. After that, you can share your Raspberry Pi folder with that particular device by clicking on the “Add Folder” option.

## Conclusion

Syncthing is a robust application that provides users the freedom to share files between multiple devices in a secure way. You can install and run this application on your Raspberry Pi browser through the above-given steps that include adding a GPG key and repository and using the installation command to install the application on your device. After the installation, you will need to make some changes in the configuration files to access the Syncthing web interface on your browser. With the remote device ID, you can allow the device to perform file sharing with your Raspberry Pi.

## What is Raspi-Config Tool | A Complete Guide

The Raspberry Pi configuration tool is beneficial for the users as it enables them to configure various settings on their Raspberry Pi devices. This setting includes keyboard layout, WiFi, serial interface, display options, performance options, and much more. You can configure anything you want right onto your terminal window.

If you are new to the Raspberry Pi device, you should need help regarding the Raspi-Config tool. This article will let you understand some of the important options used in the device configuration tool.

## What is Raspi-Config Tool

A Raspi-Config is a command-line configuration tool used to configure various settings on Raspberry Pi. With Raspi-Config tool, you will be able to find several options which are as following:

• System Options
• Display Options
• Interface Options
• Performance Options
• Localisation Options
• Update

Each of these options includes several other options except for the “About Raspi-Config” that provides you the information about the tool.

## A complete guide of Raspi-Config tool

Configuring your Raspberry Pi settings through Raspi-Config tool is pretty straightforward and every individual can easily do it on their Raspberry Pi terminal.

## How to access Raspi-Config Tool on Raspberry Pi

To open the configuration, you will first need to run Raspberry Pi terminal using “CTRL+ALT+T” from keyboard or directly open it from your Raspberry Pi desktop:

Merienda the terminal is opened, you can execute the following command to run the RaspiConfig on your terminal.

In the RaspiConfig, you will be able to see several options and we will guide you what each option will do for you.

## 1: System Options

In the ”System Options” of RaspiConfig, you will find several other options that will let you change the system settings on your Raspberry Pi. Let’s discuss each option so that it will help you change these settings when you need them.

Wireless LAN: The Wireless LAN option will let you connect to your WiFi network on your Raspberry Pi device by providing your WiFi name and password.

Audio: The Audio option will let you decide the audio output for your Raspberry Pi device as this option enables you to listen to audio via headphones or HDMI.

Password: This option enables you to change the default Raspberry Pi password to make our device more secure.

Hostname: This option will allow you to change your device hostname.

Boot/Utilitario login: Using this option, you will be able to select the boot settings for your Raspberry Pi device.

Network at Boot: Enabling this option will boot your Raspberry Pi device after the internet connection is successfully established.

Splash Screen: This option will enable the splash screen on your device at boot.

Power LED: Skip this option as it won’t work on Raspberry Pi.

## 2: Display Options

This “Display Options” in Raspi-Config tool will help you change your device display settings as it includes several options like Underscan, screen blanking, VNC resolution and Composite.

Underscan: Enabling this option will remove black border around the screen.

Screen Blanking: You can use this option when you want to use your device for a longer time as disabling the screen blanking on your device will remove the screen saver to appear on your screen.

VNC resolution: This option is valuable if you are using VNC viewer for accessing Raspberry Pi screen as it lets you adjust the screen resolution for Raspberry Pi display.

Composite: This option decides whether you want a 4K resolution or not. Enabling this option will make the Raspberry Pi video output in 4K display.

## 3: Interface Options

In the “Interface Options”, you will be able to enable/disable various interfaces such as camera module, SSH, VNC, SPI, I2C, Serial Port, 1-Wire and Remote GPIO.

Camera Module: You will need to enable this option merienda you find a compatible camera module for your Raspberry Pi device.

SSH: Enabling this option will allow you to remotely access your Raspberry Pi device.

VNC: You can enable this option if you want to view your Raspberry Pi display on your laptop or mobile phone.

SPI: Enable this option if you have attached a four-wire serial link with your Raspberry Pi.

I2C: You can enable this option merienda you connect an I2C device with your Raspberry Pi.

Serial Port: This option is helpful if you want to exchange messages through serial connection as you have to enable in this case.

1-Wire: Enable this option if you connect a sensor that uses 1-wire protocol.

Remote GPIO: Enabling this option allows you to remotely access your device GPIO pins.

## 4: Performance Options

The “Performance Options” in RaspiConfig is crucial to boost your device performance. There you will find several options like overclock, GPU memory, overlay file system and fan settings.

Overclock: You can use this option if your device overheats too much as you have to set the CPU overclocking speed to enhance the device performance.

GPU Memory: This option lets you decide the GPU memory for your device as increasing the GPU memory may boost your device performance.

Overlay File System: Enabling this option will increase your device’s SD card performance as it avoids useless write options on your device.

Fan: This option will let you decide the fan setting for your GPIO Fan.

## 5: Localization Options

With “Localization Options”, you can change the language settings, country time zone, keyboard layout or Wireless LAN location.

In the “Advanced Options”, you will be able to find several options like Expand File System, Compositor, Network Interface Names, Proxy Settings, Boot Order, Bootloader Version and Wayland.

Expand File System: This option allows you to expand your Raspberry Pi storage and it’s better to use this option when you need additional storage for your Raspberry Pi device.

Compositor: This option helps you to enable or disable the composite manager on your device. It is capable of rendering drop shadow and is mostly utilized for display purposes.

Network Interface Names: You can enable and disable predictable network interface names through this option and it’s generally disable on your device.

Network Proxy Settings: This option is used to set up proxy settings on your Raspberry Pi device.

Boot Order: You can use this option to select your boot order which can only be utilized if you successfully perform SD card, network and USB device boot.

Wayland: Wayland is a communication protocol used in the device for performing communication between display server and clients. You can enable this option if you need it otherwise you can leave it disabled.

## 7: Update

You can use this option to update the Raspi-Config tool to the latest version.

## Conclusion

RaspiConfig tool is extremely important for the Raspberry Pi users, allowing them to perform configuration settings on their device. If you are a Raspberry Pi user and don’t have knowledge about this tool, follow the above guidelines. You can select any option and perform required changes to configure several settings on your Raspberry Pi device.

## Seaborn HeatMap Colors

Heatmaps are colored maps that display data in a two-dimensional format. Color variation is achieved by using hue, saturation, or brightness to portray the varied information on the color maps. This color variation provides the readers with visual information about the size of quantitative values. Heatmaps substitute numbers with colors since the human mind understands views better than the textual data. Considering that humans are primarily visual, it makes sense to present the data in any manner. Heatmaps are simple-to-understand visual representations of data. As a result, data visualization tools like Heatmaps are becoming increasingly popular.

Heatmaps are used to display patterns, variance, and anomalies, as well as to depict the saturation or intensity of the variables. Relationships between variables are depicted via heatmaps. Both axes are used to plot these variables. By observing the color shift in the cell, we can look for the patterns. It only takes numerical input and shows it on the grid, with different data values displayed by the varying color intensity.

Many various color schemes can be used to depict the heat map, each with its own set of perceptual advantages and disadvantages. Colors in the Heatmap indicate patterns in the data, thus the color palette decisions are more than just cosmetic. The finding of patterns can be facilitated by the appropriate color palettes but can also be hindered by the poor color choices.

Colormaps are used to visualize heatmaps since they are a simple and effective way to see data. Diverse colormaps could be utilized for different sorts of heatmaps. In this article, we’ll explore how to interact with Seaborn heatmaps using the colormaps.

## Example 1: Set the Sequential Colormaps Plot

When the data values (numeric) change from high to low and just one of them is significant for the analysis, we utilize the sequential colormaps. Note that we created a colormap with sns.color palette() and displayed the colors in the colormap with sns.palplot(). The following instance explains how to generate a sequential colormap heatmap with the Seaborn module.

In the following python script, we provide the three modules that are necessary for the code to work. Then, we insert the seed value zero into the random function for generating random numbers. We create the field data where the rand function is called that generates a random number in a specified interval for the x-axis and y-axis.  Then, we create a colormap variable where the color_palette created the color “Reds”. In the end, the cmap color is utilized for the heatmap.

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

np.random.seed(0)
data = np.random.rand(10, 10)
colormap = sns.color_palette(«Reds»)

ax = sns.heatmap(data, cmap=colormap)
plt.show()

The sequential color heatmap is represented like this from the previous script.

## Example 2: Set the Sequential Colormaps with the Cmap Argument Plot

As “Reds” is a built-in colormap in seaborn, it can also be passed straight to the cmap argument.

It’s worth noting that our colormap has a continuous color intensity, as opposed to the previous one, which had a discrete green intensity for a range of possible values. Here’s a deeper look at the colormaps obtained in the heatmaps mentioned in the following illustration:

We passed a zero for the rand seed and generated the random number by using the rand function inside the variable data. We set the interval (15,15) for both the x-axis and the y-axis. Then, we passed an argument cmap which has the color “Blues” inside the heatmap function. This creates the “Blue” color variations of the heatmap.

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
np.random.seed(0)
data = np.random.rand(15, 15)
ax = sns.heatmap(data, cmap=«Blues»)
plt.show()

The Blues’ sequential color intensity plot is shown inside the figure along with the color bar of the specified color.

## Example 3: Set the Diverging Colormaps Plot

They’re utilized to depict the numeric values that range from high to low (and vice versa), with both the maximum and minimum values being important. On a Seaborn heatmap, the following example explains how to use a diverging colormap.

Here, we import the Seaborn library which is installed in our python language. The Matplotlib library is also used for the visualization of the plot. We have another module which is NumPy for the NumPy features. Then, by utilizing the NumPy module, we have the np.random.seed function which passes a value of zero used to initialize the random numbers.

Inside the variable data, we call a NumPy function rand which set the number limit for both the axes in the plot. Then, we have a Seaborn heatmap function, which takes the argument cmap. The cmap is set with the default color scheme which is the coolwarm colors.

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

np.random.seed(0)

data = np.random.rand(10, 12)
ax = sns.heatmap(data, cmap=«coolwarm»)
plt.show()

In the following figure, we have a customized heatmap using cmap:

## Example 4: Set the Cbar Parameter Plot

The heatmap’s cbar attribute is a Boolean value that implies whether it should be plotted. The color bar is featured in the graph by default if the cbar parameter isn’t specified. Switch the cbar to False to disable the color bar. The cbar=False parameter in the heatmap() method can be used to disable the colorbar of the heatmap in Seaborn.

We required the four libraries; the additional library is the pandas for the data frame which we utilize in the code. With the Seaborn, we call a set function here. Then, with the loaded dataset function, the sample dataset flights are added and stored in the df variable.

In the next line, we have a pivot function that takes the column-wise data and groups the data accordingly. We pass the three columns: months, year, and passengers from the flight’s dataset.  Now, invoking the seaborn heatmap function sets the cbar argument to a false value. With the plt show function, the plot is rendered.

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

sns.set()
df = df.pivot(«month», «year», «passengers»)
ax = sns.heatmap(df, cbar=False)
plt.show()

The cbar is removed from the heatmap plot in the given figure:

## Conclusion

It’s simple to work with the Seaborn heatmaps. We discussed the two types of color maps which include the sequential and diverging color maps. We explained them briefly along with the running example with the Python Seaborn compiler inside the Ubuntu 20.04.

## Seaborn Regplot

Seaborn is a Matplotlib-based visual analytics library. It has a high-level framework for defining the visually appealing analytical graphs. Matplotlib package is the foundation of the Seaborn module. To visualize the statistics and regression analysis, we use the regplot() function.

To evaluate the regression model, there are many other interrelated contradictory approaches. Whenever the predicted output is a continuous as well as a cumulative value, it is referred to as a prediction model. Numerous other approaches can be employed. The most basic of which is the linear model. It integrates the values to the optimal higher dimensional space that passes through all of the vertices. The regplot() function is used to create the regression plots.

Regression Analysis is a technique used for evaluating the associations between one or more independent factors or predictors and the dependent attributes or covariates. The variations in the requirements in correlation to modifications in specific determinants are analyzed through the Regression Analysis. The criteria’s declarative requirement is dependent on the indicators, which give the new value of the dependent attributes whenever the data points are updated. Evaluating the intensity of covariates, anticipating an outcome, and estimating are the three important applications of a regression model.

## Example 1

In this step, we use the regplot() method to draw the regression plot of the data frame “mpg”.

import seaborn as sns
import matplotlib.pyplot as plt

sns.regplot(x = «mpg»,
y = «acceleration»,
data = data)

plt.show()

At the start of the program, we imported the required frameworks, Seaborn and matplotlib.pyplot. Seaborn is a Python module for creating numerical visuals. It is effectively correlated to the matplotlib library. Seaborn library assists users in accessing and evaluating the data. Among the most widely utilized modules for data analysis is Matplotlib. This library is a cross-platform package that creates two-dimensional charts using a range of data. It includes an Interface for integrating graphs in Python Graphical framework based on applications.

Here, we get a dataset of “mpg” by applying the load_dataset() method. This method is taken from the Seaborn library. The regplot() function is employed to draw the regression plots. The Seaborn module contains the regplot() function. This method contains three parameters. The x-axis of the histogram holds the values of mpg. Whereas the y-axis of the regression plot holds the values of acceleration. In the end, we use the plt.show() function to represent the plot.

## Example 2

Another visualization method of plotting the regression plot is by applying the regplot() method. Here, we employ this method on the “titanic” data set.

import seaborn as sns
import matplotlib.pyplot as plt

sns.regplot(x = «age»,
y = «fare»,
data = data,
dropna = True)
plt.show()

First of all, we integrate the header files. The Seaborn library is integrated as sns and matplotlib.pyplot is integrated as plt. In the next step, we load the required data frame so, we apply the load_dataset() method. This function contains the “titanic” parameter as we want the dataset of the titanic. The Seaborn package holds the function of load_dataset(). In the following step, we utilize the regplot() function. This function creates the regression visual of the titanic dataset. The function contains different arguments including the data, the value of the x-axis, y-axis, data, and dropna.

Here, we provide the value of the “dropna” attribute. By specifying the “dropna” parameter to True, we may insert a curvature to a plot. The x-axis of the regression map is labeled as “age” and the y-axis is labeled as “fare”. The plt.show() method is applied to illustrate the resultant graph.

## Example 3

The regplot() method of the Seaborn library can also be used to create a regression plot. In this case, we create a regression plot of the data set “exercise”.

import seaborn as sns
import matplotlib.pyplot as plt

sns.regplot(x = «id»,
y = «pulse»,
data = data)

plt.show()

Here, we introduce the essential libraries, Seaborn as sns and matplotlib.pyplot as plt. We apply the load_dataset() function of the Seaborn module to acquire the “exercise”  data. The gathered data is saved in the “data” attribute. The regression plot is created by using the regplot() method. This method is found in the Seaborn package. This method has a variable that represents the id, pulse, and data of the graph. Lastly, to depict the plot, we employ the plt.show() method.

## Example 4

In this instance, the regplot() method specifies a data set of “attention” and values of both the x-axis and y-axis.

import seaborn as sns
import matplotlib.pyplot as plt

sns.regplot(x = «solutions»,
y = «score»,
data = data)
plt.show()

We start by integrating the packages sns and plt. The seaborn library is incorporated as sns. Matplotlib is used to integrate plt. We now retrieve the appropriate data set. As a result, we use the load_dataset() function. If we want a database of attention, this method has an “attention” argument. The load_dataset() method is part of the Seaborn package.

After this, the regplot() method of the Seaborn module is applied. This module creates the regression plot. The function takes the several parameters such as data, x-axis value, and y-axis value. The regression map’s x-axis is marked as “solutions” and the y-axis is marked as “score”. The obtained regression plot is then visualized by using the plt.show() function.

## Conclusion

In this article, we talked about the numerous methods of creating the regression plots in Seaborn. We utilized the regplot() method to draw the regression plots. Furthermore, we drew regression graphs of the different inbuilt data sets of Seaborn. The regression visualizations in the Seaborn package are designed exclusively to provide a visual aid for highlighting the features from the set of data during the data exploration. As the name implies, a regression map draws a regression boundary between two variables and aids in the depiction of the underlying correlation coefficients.

## CSS First Letter

A Cascading Style Sheet plays an important role in decorating the first letter of the word in HTML. Sometimes, we need the user to pay attention to a specific piece of text, according to our requirement. To accomplish this purpose, we use the text decoration and effects on the first letter of the word of the paragraph or the heading. This assists in diverting the user’s focus on the relevant point. This selection is done through the CSS:: first-letter selector which is the CSS pseudo-element.

## CSS Pseudo-Element

It is the keyword that is added to the selector that enables you to decorate or style the particular section of the selected item. The basic syntax used for this styling is defined in the following:

 12345 Selector :: pseudo-element { Style property: value in % or px; }

The selector in this article represents the first letter of the word. The style property includes the border property, color, font, margin, text-decoration, padding, and background property as well. We apply the three main style properties in this guide.

## Font and Color Style on the First Letter

First, we apply the two properties in the first letter styling. Starting with the HTML opening tag, we declare the head and then open the style tag. Since we need to apply any effect on the first letter, it is necessary to mention it at the time of styling. Otherwise, the whole text of the paragraph will get affected. So, the “P” for the paragraph is mentioned along with the first letter declaration. The green color and font size in percent are applied.

 1234567 P:: first-letter { Font-size: 250%; Color: green; }

After that, the head section is closed. The body tag is complimented by the center-aligned tag. It is an example of inline styling. Inside the body, we add a heading again. The inline CSS is applied to apply the color to it. In the end, the paragraph is added where we applied the styling. We can also apply any style to the first letter of the heading like in the paragraph.

## Code:

Save the code and run it in the browser. You will see the resultant webpage where the first letter of the paragraph is bigger compared to the rest of the text and its color is changed. This change in style is useful in diverting the focus of the reader.

## Border Style on the First Letter

The second way to make the first letter prominent is to apply a square shape or a border around the first letter of the text. Let us elaborate on how it works.

This time, we take the two ways of styling the first letter by applying one style on the heading and the other one to the paragraph. Inside the style tag, the same first-letter value is declared to the heading “h3”. The border style is set to “solid”.

 12345 H3 ::  first-letter { Border-style:  solid; }

## Code:

Similarly, in the first letter of the paragraph, we apply the border style as double. We can also apply a simple border or the dotted one by replacing the border-style name with the “dotted” word. Inside the body, a heading and a paragraph are declared, both containing the dummy text to show the effects we applied on them. Save the file of the text editor and then run it in the default browser.

## Output:

You will see that in the heading, the first letter is “T’ and it is styled with a solid border. You can apply more effects on the border as well, like the border color, etc. This will attract more as compared to the entire text. The paragraph has the first letter “L” of “Lorem”. This is styled by the double border.

Note: Both the border effects are applied on the first letter of the first word as we mentioned in CSS. But if the first-letter definition is removed, the border will be applied to the whole text, either in the heading or in the paragraph.

## Text Decoration Style on the First Letter

The first letter of the text can also be styled by decorating the text. This time, we use the first letter of the list. Each list will be affected by a different style of the text decoration. CSS text decoration property has several aspects; we will go with the text decoration line.

First, consider the body section of the HTML code. Two simple headings are applied. Ater that, we declare a simple list. From the two types of lists, we use an unordered list here. The <ul> tag is declared. Inside the tags of the unordered list, we declare the lists with the tag <li>.

 12345
• Shiza Ahsan

All three lists are declared inside the tag of <ul>. Each list is closed separately and after the declaration of all the lists, </ul> is applied. Each list is applied with an id name. The style of the first letter is applied by identifying each example as we apply the different styles for each line in the list.

## HTML <body> code:

If the ids from the list are removed, then a single style is applied to all the lines in the list. Now, close the body section. Go towards the Head section of the HTML body.

Inside the style tag, the color of the heading is applied. It is an optional effect just to explain the working. The whole body is applied by the style to align on the left side of the web page.

 12345 Ul li { Margin-top: 15px; }

A common effect that is applied to all the lines in the list is a margin effect. To keep the distance between two lines in the list, we apply this effect. After that, each line in the list is applied in the different styles. For instance, in example1 id, we apply the effect of the text decoration with an underline dotted on the first letter.

 12345 #example1:: first-letter { Text-decoration: underline dotted; }

Similarly, example2 and example3 are applied by the text decoration of a red line through the letter. Whereas the third line in the list has an overline blue effect.

## CSS code:

After adding all the effects, save the code and we run the file. The first letter “S” of the word ‘Shiza” has a dotted line underneath. The first letter “S” of the second line has a red line through it. And the “Z” of Zaroon contains a blue line passing over it.

## Conclusion

The CSS first letter of the text in HTML plays an important role in diverting the attention of the user. In this article, we briefly give the basic introduction to the first-letter selector which is an element of the CSS pseudo property. This style of property has several categories. We can apply each one to highlight the first letter. The three properties that are applied are the font plus color effect, the border effect, and the text-decoration property having different styles and colors of lines passing under or through the first letters.

## How to Create an EC2 Instance on AWS Using Terraform

With the rise in cloud computing technology, more industries are migrating their workloads to cloud-based infrastructure. As a result of this pattern, technologists have felt the need for some mechanism to automate the process of instance deployment (and other cloud resources). Terraform is one such Open-source tool to facilitate this progress.

## What We Will Cover

This article will show how we can create an EC2 instance on AWS using Terraform. We will see an example of installing a simple web server on this instance. Let us first talk a little about the installation of Terraform.

## How You Can Install Terraform

Official Terraform packages for various operating systems like Windows, Mac, and Linux-based distros, such as Ubuntu/Debian, CentOS/RHEL, etc., are available. In addition, Terraform also maintains pre-compiled binary and can also be compiled from the source. You can check the various installation procedures on the Terraform website. To verify your Terraform installation, run the following command:

## Creating AWS EC2 Instance Using Terraform

After installing Terraform on your system, proceed with creating an EC2 instance on AWS. There are some files to effectively manage a Terraform deployment. Although we can create a single file and declare all the stuff, this approach will make the entire scenario clumsy. So, let us first create a working directory as seen in the following:

Step 1. Start with a folder that will hold all the configuration files. Create the folder, and move inside it as shown in the following:

 1 \$ mkdir linuxhint-terraform && cd linuxhint-terraform

Step 2. Let us create our first configuration file, “variables.tf”, that contains information about our AWS region and the type of instance we want to use, as shown in the following:

Now, put the below text inside it and save the file as shown in the following:

 12345678910 variable «aws_region» {   description = «The AWS region to deploy the EC2 instance in.»   default   = «us-east-1» } variable «instance_type» {  description = «instance type for ec2»  default   =  «t2.micro»}

Step 3. By default, when Terraform creates a new instance, the default security group associated with the instance denies all the traffic. We will therefore create a new file, “secgrp.tf”, to create a security group, “web-sg”, that will allow the inbound “SSH” and “HTTP” traffic, as well as all outbound traffic, as shown in the following:

Now, put the following code inside it as shown in the following:

 1234567891011121314151617181920212223 resource «aws_security_group» «web-sg» {   name = “new-secgrp”   ingress {     from_port   = 80     to_port     = 80     protocol    = «tcp»     cidr_blocks = [«0.0.0.0/0»]   }   ingress {    from_port   = 22    to_port     = 22    protocol    = «tcp»    cidr_blocks = [«0.0.0.0/0»]  }   egress {        from_port   = 0    to_port     = 0    protocol    = «-1»    cidr_blocks = [«0.0.0.0/0»]  }}

Step 4. Create a “main.tf” file that will define the desired infrastructure as shown in the following:

Now, put the following configuration inside it:

 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 terraform {   required_providers {    aws = {    source  = «hashicorp/aws»     version = «~> 3.27»     }  }   required_version = «>= 0.14.9» } provider «aws» {   region                = var.aws_region  shared_credentials_file = «/home/User_Name/.aws/credentials»  profile               = «profile1» } resource «aws_instance» «webserver» {   ami = «ami-09d56f8956ab235b3»  instance_type = var.instance_type  key_name = «EC2-keyPair-Name» vpc_security_group_ids = [aws_security_group.web-sg.id]associate_public_ip_address = true  root_block_device {    volume_type = «gp2»    volume_size = «30»    delete_on_termination = false }     user_data = <This is our test website deployed using Terraform.» > index.html EOF   tags = {    Name = «ExampleEC2Instance»  }} output «IPAddress» {  value = «\${aws_instance.webserver.public_ip}«}

In the previous code, do not forget to change the “User-Name” to your system user’s name and the “EC2-keyPair-Name” to the name of the key pair in your case. Let us see a bit about the parameters used in the above files:

aws_instance: This creates an EC2 instance resource. Instances can be created, changed, and destroyed

AMI: Specify the AMI id to be used with the EC2 instance

instance_type: This option is used to declare the type of the instance to be used

key_name: Specifies the name of the key pair to use with the EC2 instance

vpc_security_group_ids: An argument for a list of security group IDs to attach

associate_public_ip_address: Specify whether to attach public IP with an instance inside a VPC

user_data: Used for passing commands/data on an instance when launching it

Now, initialize Terraform by running the following command:

Now, apply the changes using the following command:

## Verifying the Procedure

Now, let us check whether the desired EC2 instance is created. Head to the EC2 console and check for the running instances as shown in the following image:

Since our instance was created successfully, we will now see if the website we deployed is working correctly or not. Copy the DNS name or public IP of the instance and enter it inside a web browser as shown in the following:

Well done! Our web server is working nicely.

## Cleaning up the Resources

When you have tested your infrastructure or when you do not require it, clean up the resources by running the following command:

## Conclusion

This guide taught us about creating an EC2 instance on AWS using Terraform. We have also demonstrated how to provision a simple AWS web server using Terraform.

## How to Configure Application Load Balancer With Host-Based Routing

“A load balancer receives requests and then transfers them to targets defined in a target group. We can create an Application Load balancer either using the AWS management console or AWS CLI. There are several routing options with AWS Application Load Balancer, e.g., Host-Based routing.

In Host-based routing, incoming traffic is routed on the basis of the domain name or host name given in the Host Header. In this tutorial, we are going to create an Application Load balancer with Host-Based routing.”

## Overview of This Lab

In this lab, we will set up Application Load Balancer on AWS using the host-based routing approach. To perform this lab, we require the following components: First, we need two availability zones with a minimum of one EC2 instance in each of them. Next is a VPC with at least one public subnet in each of these availability zones. We will configure the load balancer using these public subnets. Finally, configure a web server for the above EC2 instances and use the security group to open the port 80 for http requests on these instances.

## Configuring the EC2 Instances

The first EC2 instance is an Ubuntu 20.04 Linux machine, and the web server (apache) displays the message: “This is an xyz host”. It has a hostname: www.xyz.tecofers.com

Similarly, the second instance is also an Ubuntu 20.04 Linux, with the web server displaying the message: “This is an abc host”. It has a hostname: www.abc.tecofers.com

The web servers contain the “abc” and “xyz” directories inside their root directories, i.e. (/var/www/).

## Setting up the Target Group

Step 1. In this step, we will create target groups(“xyz” and “abc”) for routing the incoming requests. On the EC2 dashboard, select the Target Groups option on the left pane under the Load Balancing title. Now select the “Create target group” option:

Step 2. The “Specify group details” page has several options to be filled.

1. For the “Choose a target type” option, click the “Instances” radiodifusión button here.

1. For the “Target group name”, enter an appropriate target group name(“xyz” in my case).
1. For the “Protocol” and “Port” options, select “HTTP” and “80”, respectively.
1. For the “VPC” option, choose the VPC containing your instances.
1. Finally, for the “Protocol version,” stick to the default option(HTTP1).

ii) The “Health checks” Configuration has the following fields:

1. For the “Health check protocol” drop-down menu, choose HTTP.
1. For the “Health check path”, specify a custom path or use the default one(recommended).
2. We recommend keeping the “Advanced health check settings” as it is. Adding tags is an optional step. Enter “Next” to continue.

## Register the Instances

In this step, we need to register the instances with the Target Groups.

Step 1. On this page, choose an instance and then select the button “Include as pending below”. This will make the instance appear in the “Review targets” heading. Proceed by hitting the “Create target group” button.

For another target group, “abc”, repeat the same steps of creating a target group and then attach another instance here. On the Target groups, the two target groups will appear as:

So far, we have not attached any Load balancer to our target groups. Let’s go and create a load balancer.

## Create the Application Load Balancer

Note: Creating a load balancer service requires you to pay AWS.

Step 1. On the EC2 dashboard, select the Load Balancers title and hit the “Create Load Balancer” button, and then choose “Application Load Balancer”:

Step 2. Enter a name for the load balancer that satisfies the naming constraints. Under the Scheme, keep the default option (“Internet-facing”) selected. For “IP address type,” choose IPv4.

Step 3. On moving ahead, we have “Network mapping”; here, choose the VPC we are working with. Also, choose two availability zones that hold the targets. The incoming traffic will be routed to these targets by the load balancer.

Step 4. For the Security Groups, select or create a new security group for the load balancer that will allow communication with the target port (port 80)

Step 5. Now come the Listeners and routing segment; what we have to do here is to configure a listener by choosing a protocol(HTTP here) and a port. For the Default action, choose your target corresponding to the “forward to” field.

Step 6. Adding tags and Add-on services are optional steps and can be skipped. After reviewing the configuration summary and click the “Create load balancer” button:

## Add the Host-based Forwarding Rules

After the load balancer is created and its status becomes active, we are required to add traffic forward rules.

Step 1. From the “Load Balancers” page and select the load balancer and then further move to the Listeners tab:

Step 2. Navigate to the Listeners tab and under the “Rules” column, click on the “View/Edit rules” link. A new page appears here first; click on the “+” icon, then click on the “Insert Rule” link.

Step 3. For the IF(all match) column, do as follows:

i) click on the “+ Add condition”  and set “Host header” as the type of Rule.

ii) enter the host or domain name inside the field corresponding to the label “is”.

Step 4. For the “Then” column, do as follows:

I) click on “+Add action” and set “Forward to” as the action.

ii) choose the target group.

Save the rule and for another target group, insert the rule in the same way and save it.

In case the above rules are not satisfied, the default rule will be used.

## Register the Domain

To make the host-based routing work over the internet, we have to register the hostnames with Route 53 and map them with the load balancer DNS.

Step 1. From the Route 53 dashboard, choose the “Create hosted zone” option:

Step 2. Next, enter your domain name to where traffic will be routed to. For the “type” field, set “Public hosted zone”. Hit the button “Create hosted zone”.

Step 3. In the “Records” section, choose “Create record”.

Step 4. On  the “Choose routing policy’ page, select the link “Switch to wizard” and then choose the “Simple Routing” box and click “Next”:

Step 5. Now choose “Define simple record” and then enter the record details:

Domain: domain or subdomain name to route the traffic to.

Record type: DNS type of the record.

Value/Route traffic to:

1. Choose “Apelativo to Application and Classic Load Balancer”
2. Choose the region where the load balancer is deployed

On the next page, click on the “Create records” button.

Do the same steps for another domain name and verify the above record on the “Configure Records” page.

## Test the Setup

To verify the above procedure, on a web browser, enter the DNS name of the load balancer along with the hostnames:

## Conclusion

We have finally made the way to host-based routing on the AWS application load balancer. Try to do this lab yourself and also try to configure the Application Load balancer with path-based routing.

## Git is Not Recognized as an Internal or External Command, Operable Program or Batch File

Git has been a revolutionary technology and tool for every modern software developer. Version control tools let you keep track of the changes and preserve a source code snapshot if you need to revert the changes.

Whether you are working on a small or a massive software project, using a git repository to manage it can be more than beneficial.

Before using git on your system, you need to install and configure it. Git is cross-platform and can be installed on any system running Windows, macOS, or Linux.

On Windows, you may face the “git is not recognized as an internal, external command, operable program, or batch file” error even after installing git.

## What causes “‘git’ is not recognized as an internal or external command, operable program or batch file.” Error?

There are three major causes of the error. These includes:

## Fix #1 Git is not installed on the target system.

Before using git, you must ensure you have it installed and configured on your system. Although there are several methods of installing git on Windows, it is recommended to use the official git for Windows installer.

Open your browser and navigate to the resource below:

Select the installer version for your Windows system.

You can accept the default values as they work well out of the box.

Under the “Adjusting your PATH environment.”, select “Git from the command line and 3rd-party software.”

The above option adds git to your PATH environment variable. This helps you access the git utility from any directory in your command prompt and any third-party software such as your code editor.

Continue with the setup wizard and complete the installation process. Merienda the installation is complete, open your CMD window and check the git version.

## Fix #2 Git is not available in the PATH environment system

Suppose you have git installed and still getting the “‘git’ is not recognized as an internal or external command, operable program or batch file.” error. In that case, the error is caused by git missing from the PATH environment variable.

You can fix that by manually adding git in your system environment variable. You can run:

setx /M path «%path%;C:Program FilesGitcmd»

The command above should update your system’s environment variables to include the path to the git binary.

If you are looking for a graphical method, start by navigating to the git binary in file explorer.

By default, you will find it in either of these directories.

C:Program FilesGitcmd

C:Program Files (x86)Gitcmd

Select the full path in the Windows explorer path bar and click copy.

Press the Windows Key + R to launch the Run dialog.

Enter sysdm.cpl to launch the System properties window.

Go to “System Variables” and select “Path.” Then, click on Edit to edit the Path environment variable.

Click on New and paste the path you copied earlier.

Click on OK to save the changes.

Merienda completed, launch a new terminal window and run the where git command.

## Fix #3 Reload Terminal Session

You will need to reload the session to update the environment variables if you have a terminal session open when installing git.

You can do this by closing and opening a new terminal session.

## Closing

Using this tutorial, you discovered three significant causes of the “git command not recognized…” error. You also learned three ways to fix this error if it arises in your system.