You are reading the article How To Make Unique Instagram Grid Layouts Using Individual Pictures. (Corner Grids) updated in December 2023 on the website Minhminhbmm.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 How To Make Unique Instagram Grid Layouts Using Individual Pictures. (Corner Grids)
If you are looking for a way to spice up your Instagram account and have already used a traditional photo grid more times than you can count. This article will show you how to add a unique twist to the original Instagram photo grid concept. A clever, easy way to add effects like circles, diamonds, stars, hearts, etc to Instagram photo grids.
How to View the Analytic Information of Any Instagram Account.
In the past, creating photo grids used to be a painstakingly difficult task, with a single image needing to be prepared prior to posting. (manually cut into segments using a program like photoshop or gimp). Now though, there are a variety of different automated apps which you can use to create your own Instagram photo grid automatically. As an example Instagrid: Grids for Instagram will allow you to quickly and easily create a traditional photo grid that chops a single image into different parts to form a grid in only a few steps.
That was the old type of Instagram photo grid! There’s now a new type of Instagram photo grid gaining popularity. Corner Grids, aka Corner Photo Grids. These differ slightly as they allow you to upload single images with corner modifications which create an interesting grid effect when used on multiple images. As can be seen in the cover image for this article.
Related: How to Stop Chrome Signing You Out Every Time You Close the Browser or Restart Your Computer.
How Do You Make Photo Grids With Circle, Diamonds, Star, and Heart Cutouts? (Instagram Corner Grids ‘aka’ Instagram Corner Grid Photos)To create more intricate photo grids on Instagram, you’ll need to use a new app called CornerGram. If you’ve used any of the other Instagram grid apps in the past, it won’t take you long to get used to using CornerGram. Sadly CornerGram is currently only available on Android devices. So if you own an iOS device, you will have to search for an alternative.
Download CornerGram From Google Play.
Once you have downloaded the app, using it is super straight forward, first, choose an image you’d like to cornerise, then accept the Crop Now option to make sure the image fits a 1:1 ratio.
Next, choose the shape of the edge you’d like to use, either a circle, square with outward round corners, diamond, star, square with inward round edges or a heart. Finally, choose the size of the edge effect you’d like to use either 0.75x, 1x, 1.5x or 2x, then tap Save.
After the image has been saved, you can open Instagram and post it as you would any other image you have in the past. It will require you to post a few images to start seeing the effect. As you can see in the example above, six images gets the best results. It’s important to mention that once you start a style, it is best to stick with it for a considerable amount of time. If you switch to another corner type, you’ll have a weird mismatch for the adjustment period of 3 images.
If you’ve always wanted to download Instagram Videos, make sure you check out the following guide which will show you How to Search For and Download Instagram Videos Using Hashtags. One of the quickest and easiest ways to download video content from Instagram.
You're reading How To Make Unique Instagram Grid Layouts Using Individual Pictures. (Corner Grids)
How To Make A Collage On Instagram
Instagram is all about sharing pictures in various forms with your followers and other people, and one way to do that is through collages. Collages allow users to add more than one photo to their Stories and posts. This tutorial shows you how to create a collage on Instagram and via other third-party apps and websites.
Use Instagram Stickers to Create Collages in StoriesThis is perhaps the easiest method that Instagram users have to create a quick collage. You can use as many photos as you would like for these creations, which isn’t possible with other methods. Follow these instructions to create a collage in Stories.
Select the background image for your collage or snap a new photo.
Tap on the “Sticker” button at the top.
Select the “Collage” icon.
You won’t be able to additional images in bulk and will need to add them individually.
Editing Your CollageThe new image will show up in miniature format on the background you previously selected. You can use your fingers to enlarge, shrink, or twist and rotate it. Hold down the image with your finger to move it to the desired part of the display.
If you tap on the image, you can change the shape of the photo, such as from a square to a circle or star.
To add another photo, repeat steps #4 through #6.
Continue the process until you’ve added all your images. Keep in mind that you can also add normal Stickers to your collage but not additional images from Instagram’s generous database.
If you wish to remove one of the images from the collage, drag the image toward the bottom of the screen to get rid of it. When you’re done editing, press “Your Story” to post the result.
Note: Do you want to post a collage on your Instagram profile instead of Stories? Before pressing the “Your Story” button to post the Story, tap on the three dots in the upper-right corner and select “Save.” This will save the image to your phone’s Gallery. From there, you can use it to make a regular post on Instagram.
This easy method won’t add your photos into a nice grid. But you can arrange them manually on a background. If you prefer something a bit more controlled, you may want to try the second option.
Take Advantage of Instagram’s Layout Option to Create a Collage for StoriesUsing a layout to create a collage is a bit more restrictive, as you’ll be limited to a number of photos when creating your collage. If you don’t mind this aspect, follow the below steps.
Launch the Instagram app on your smartphone.
Swipe left from your screen to go to camera mode and select “Story” from the menu at the bottom.
Tap on the “Layout” icon in the vertical menu on the left.
Press on the layout example underneath to select the configuration of your Story. You can up to six pics to your collage.
Once you’ve selected a layout, start adding pictures. You can snap photos or add images from your own Gallery by tapping on the photo thumbnail in the lower-left corner.
If you’d like to change the position of a certain image, long-press on it and drag toward the desired position. You can tap on a photo, then on the “Trash” icon to remove it.
Once you’re satisfied, hit the checkmark icon at the bottom.
View the final result in the next screen and add extra stickers, images, text and filters to your Story, if you would like.
Once you’ve added everything, press the “Your Story” button to post your creation.
Note: you can download the Story to your phone, then use the image to do a regular post on Instagram.
Try a Third-Party AppIf you feel Instagram’s options are a bit restrictive, you can easily turn to third-party apps to make your collages, as they usually have more options (although not all of the apps are free). You can try using Instagram’s own Layout app. The app boasts a few additional features that make it convenient to use. Follow the steps below to create a collage using this app.
Layout for InstagramSelect your favorite collage layout options in the upper section of the screen.
You’ll be taken to the “Editing” screen where you can arrange the photos to look their best.
It’s possible to arrange the portion of the image that will be visible by dragging your image with your finger. You can also resize the grid cells. Just tap on one and drag the blue handles until you’re happy with the result.
The app offers option to easily mirror, flip or replace each of the photos you’re using.
When you’re done, press the “Save” button in the upper-right corner. The collage will be saved to your Gallery app. Look for it in the Layout folder.
PicCollageOpen PicCollage on your device.
Tap the “Grid” button or use the “Freestyle” option.
Select one of the many Grid options.
Add your photos to the grid. By default, the different parts of the grid will be separated by thick lines. You can use the “Layout” button and make them invisible if you would like. As a side benefit, it may allow you to get rid of the watermark later.
Use the menu at the bottom to arrange and edit the images the way you would like. For instance, you can add stickers or add filters over the photos. Explore the options to make your collage look awesome.
Once you’re finished editing, press the “Done” button in the upper-right corner.
Select the “Save to Gallery” option.
Find the image in your Gallery. You can try cropping it a little to get rid of the annoying watermark.
There are other apps that can help you create collages quickly, although most of them add watermarks to the end results. Here are some examples:
PicBowPicBow is a web collage maker that is free to use. It doesn’t look as modern as other options yet doesn’t make you pay for its features. The only annoying thing is that it adds a watermark. Fortunately, you can crop out the watermark
Open PicBow on your PC in your browser.
Press the “Collage” button from the menu on top.
Select the type of grid you’d like to use for your collage from the option on the right.
To make it easier to crop out the watermark, you may want to remove the borders between the images in your collage. To do so, go to “Collage & Border” on the right and use the “Border thickness” slider to minimize the borders.
Press the “Download & Share” button at the top.
You can quickly post your creation on Instagram. If you want to use the collage as a Story, you’ll need to send it to your mobile device first.
Frequently Asked Questions Can you also make an Instagram collage out of videos?Yes, with Instagram’s integrated Layout feature for Reels. Swipe left from your feed and select “Reels” from the menu at the bottom, then tap “Layout” and choose between the three options. Alternatively, you can use an app like InShot to make a video collage that you can then post on Instagram.
Can you create a collage mixing videos and photos?Yes. You’ll need an app like InShot that lets you overlay images over videos. You’ll need to use the “PIP” option when creating your Instagram collage.
Can I use a photo collage in Instagram Reels?Yes, but you’ll need to prepare the collage beforehand using one of the apps or websites in this tutorial, then upload the creation as an Instagram Reel.
Image credit: Unsplash All screenshots by Alexandra Arici
Alexandra Arici
Alexandra is passionate about mobile tech and can be often found fiddling with a smartphone from some obscure company. She kick-started her career in tech journalism in 2013, after working a few years as a middle-school teacher. Constantly driven by curiosity, Alexandra likes to know how things work and to share that knowledge with everyone.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.
How To Make A Text Italic Using Javascript
In this tutorial, we will learn to make a text italic using JavaScript. We give the italic property to a text to differentiate it from other text within the sentence.
In HTML, we can make a text italic by just adding the text within the ‘i’ tag. But sometimes, we have to make it dynamic, that not possible with HTML. Then, we have to use a programming language like JavaScript to make the text italic.
Let’s have a look at how to make a text italic using JavaScript. Following are the ways by which we can make a text italic in JavaScript −
Using String italics() Method.
Using Style fontStyle Property.
By Creating DOM Italic Object.
Using String italics() MethodThe italics() method is the method in JavaScript used to make the text italic. It does the same thing that the ‘i’ tag in HTML. This method can be invoked only on the strings. It also does not takes any arguments.
SyntaxAll the users can follow the below syntax to use the italics() method to make a text italic using JavaScript −
string.italics();
ExampleIn the example below, we used the italics() method to make a text italic using JavaScript.
var
text
=
“Welcome to the JavaScript”
;
document
.
getElementById
(
‘para’
)
.
innerHTML
=
text
.
italics
(
)
;
In the above example, users can see that we have used the italics() method to make a text italic using JavaScript.
Using Style fontStyle PropertyWe can use the fontStyle property of the DOM style to make a text italic. We set this property to string value “italic”.
SyntaxFollowing is the syntax to make a text italic using HTML DOM style fontStyle property −
document.getElementById("paragraph").style.fontStyle = "italic"; Examplefunction
italic
(
)
{
document
.
getElementById
(
“paragraph”
)
.
style
.
fontStyle
=
“italic”
;
}
By Creating DOM Italic ObjectThe DOM(document object model) is a standard in JavaScript to access the elements in the document. We can add or access all elements of HTML through the DOM in JavaScript. We make our text italic in HTML by placing it inside the ‘i’ tag. In the same way, we can add the italic element and append the text inside it through the DOM in JavaScript.
SyntaxAll the users can follow the below syntax to use the DOM Objects to make a text italic using JavaScript −
var2.appendChild(var3);
Algorithms
Step-1 − Create an ‘i’ element using DOM.
Step-2 − Create a text node and add text to it.
Step-3 − Append the text node in the ‘i’ element.
Step-4 − Now, append the ‘i’ element to any container element.
Examplefunction
italic
(
)
{
var
para
=
document
.
getElementById
(
“para”
)
;
var
add_element
=
document
.
createElement
(
‘i’
)
;
var
text
=
document
.
createTextNode
(
para
.
innerHTML
)
;
add_element
.
appendChild
(
text
)
;
para
.
innerHTML
=
“”
;
para
.
appendChild
(
add_element
)
;
}
In this tutorial, we have learned about the two ways by which we can make a text italic in JavaScript. Among these, italics() is the method that makes a string italic. We also have used the DOM Objects to make a text italic using a custom logic in JavaScript. You can use both ways to make a text italic while the italics() is the simplest.
How To Play Mahjong (With Pictures)
Article Summary
X
Mahjong is a fun 4-player game where players try to form melds with tiles to score points. The goal of the game is to get the highest score by creating a mahjong, which is 4 melds and a pair. A meld is a set of 3 matching tiles (pong meld), 4 matching tiles (kong meld), or 3 consecutive numbers in the same suit (chow meld). There are 3 suits: bamboos (or sticks), characters, and dots. The tiles within the suits are numbered 1 through 9. There are also 4 wind tiles, 3 dragon tiles, 4 flower tiles, and 4 season tiles. To start the game, mix all 144 tiles together face-down, then divide them evenly among the players. Each player makes a wall in front of them with their 36 tiles by stacking 1 row of 18 tiles on another row of 18 tiles. Then, everyone pushes their rows together to form a square. Each player picks up 13 tiles from the row on their side. Next, each player rolls 2 dice and the highest number goes first. On a player’s turn, they start by drawing a new tile from their row. If they draw a tile that makes a meld with the other tiles in their hand, they can call it out and lay the tiles in the meld face-down in front of them. After a player draws a tile and plays any melds they have, they discard a tile from their hand by placing it face-up in the middle of the square. Finally, they draw a new tile from their row to end their turn, and the player to their left goes next. At any point in the game, any player can pick up a tile from the middle of the square to make a meld, whether it’s their turn or not. Players can also pick up a pair with the wind, dragon, flower, or season tiles. Each time a player claims a tile to make a meld or pair, they must announce it out loud before picking up the tile and setting it face-up in front them. The game is over when one player has created a mahjong, or 4 melds and a pair of matching tiles. When a player scores a mahjong, they reveal their 4 melds and the pair. Only the winning mahjong is scored. When scoring a winning mahjong, any melds made with tiles from the center of the square are considered “exposed,” and any melds made using just the tiles in the player’s hand are considered “concealed.” Concealed melds are worth more points. An exposed pong is worth 2 points, an exposed kong is worth 8 points, and an exposed chow is worth 0 points. A concealed pong is worth 4 points, a concealed kong is worth 16 points, and a concealed chow is worth 0 points. A pair of winds or dragons is worth 2 points, and 4 flowers are worth 4 points. Any other pairs are worth 0 points. After you score the winning Mahjong, shuffle the winning tiles and play another round. Play 4 rounds in total. The player with the highest score after 4 rounds wins the game! To learn more about creating melds, read on!
Did this summary help you?
Create A Video With Pictures In Only 5 Minutes Using Invideo
Create a video with pictures in only 5 minutes using InVideo
5
Share
X
InVideo is a free online tool that you can use to create a video with pictures, music, and text in a few minutes.
This online tool comes with a database of over 4,000 templates and over 1 million video clips.
You have to select a template, then add your text, video, and sound from a very friendly interface.
In the end, you can personalize the video for social media or YouTube and export, download, or upload it.
X
INSTALL BY CLICKING THE DOWNLOAD FILE
To fix Windows PC system issues, you will need a dedicated tool
Fortect is a tool that does not simply cleans up your PC, but has a repository with several millions of Windows System files stored in their initial version. When your PC encounters a problem, Fortect will fix it for you, by replacing bad files with fresh versions. To fix your current PC issue, here are the steps you need to take:
Download Fortect and install it on your PC.
Start the tool’s scanning process to look for corrupt files that are the source of your problem
Fortect has been downloaded by
0
readers this month.
You need to cut your clip, add some effects, maybe add pictures sound and text, a logo, and a lot of other elements, especially if you want to create a tutorial, a presentation video, or a video collage.
What would you say if we told you that you can do all that with a new online tool from InVideo?
How to create a video with pictures and music using InVideo?First, you will have to create an account on InVideo’s website to be able to edit videos on the go. It takes just a couple of seconds and you will be able to use your Google or Facebook account to start.
The next thing to do is to choose one from over 4,000 templates available on the platform. And you can be sure that you will find the one you need for your video, especially if you’re creating a video for your business.
As you can see, you can even set the format of the video to select the perfect template. Moreover, you can also create a video from a bare text or, if you’re a pro, you can start with a blank canvas.
How do you find the correct template for your video? You can use the search function to find the thematic like testimonial or slideshow or even a product like shows or sunglasses if you want to create an ad.
InVideo’s interface is extremely easy to useOnce you’ve found your template, you can start customizing the video with your own text and videos, or you can use one of over 1 million clips available to use in the app.
You can even add your own fonts, company logo and soundtrack to customize your video. And as you can see from the picture above, the interface is extremely friendly and easy to use in just a few minutes.
If you’re still a bit puzzled, you can use one of the many tutorials that will guide you on the spot for any function of the editor.
Changing the colors, adding the brand logo with a simple drag-and-drop movement, and saving the video is also like a gameplay even for beginners.
Still experiencing issues?
Was this page helpful?
x
Start a conversation
Make Amazing Data Science Projects Using Pyscript.js
This article was published as a part of the Data Science Blogathon.
Introduction on PyScript.jsWhat is PyScript.js?
It is a front-end framework that enables the use of Python in the browser. It is developed using Emscripten, Pyodide, WASM, and other modern web technologies.
Using Python in the browser does not mean that it can replace Javascript. But it provides more convenience and flexibility to the Python Developers, especially Machine Learning Engineers.
What PyScript Offers?
5. It provides flexibility to the developers. Now they can quickly build their python programs with the existing UI components such as buttons and containers.
This tutorial shows you how we can create our machine learning model with a web GUI using PyScript.
We will use the famous Car Evaluation Dataset to predict the car’s condition based on the six categorical features. We will discuss the dataset later but first, start with setting up the chúng tôi library.
Setting Up PyScript.jsThis section will set up our HTML Template and include the chúng tôi library.
We will use VSCode here, but you can choose any IDE.
1. Create a directory named as PyscriptTut.
$ mkdir PyscriptTut $ cd PyscriptTut2. Creating an HTML Template
Create an HTML template inside it named index.html
Inside this template, place the starter HTML code
Bootstrap CDN is used for Styling the Web Page
PyScript Installation
We will not install the library on our machine, we will directly import the library from the PyScript website.
Important Note:
You have to use a Local Server to run the HTML Code. Otherwise, you may face issues in importing several libraries in a python environment.
If you are using VSCode, then you can use its Live Server Extension.
Or you can also create a python server writing the below command in the terminal
Sample Code
You can try this sample code to check whether PyScript is successfully imported or not.
print(“Welcome to puscript tutorial”) for i in range(1, 10): print(i)
This is a simple program that prints the number from 1 to 9 using a for-loop.
If everything goes fine, the output looks like that
Hurray 🎉, our PyScript library is installed successfully in our template.
Creating GUIThis section will create a web GUI to use our machine learning model for training and testing.
As mentioned above, we will use Bootstrap Library for creating custom styling. I have also used inline CSS in some places.
1. Add Google Fonts CDN
2. Some CSS Configuration
Add the below code to your template. It will enable smooth scrolling on our web page and apply the above font.
* { margin: 0; padding: 0; } html { scroll-behavior: smooth; } body { font-family: ‘Montserrat’, sans-serif; }
3. Adding Bootstrap Navbar Component
<button type=”button” data-toggle=”collapse” data-target=”#navbarSupportedContent”
4. Adding Heading Content
We will create a small landing page with some texts and images.
The Source of the image used in this component can be found here.
5. Component to Train the Model
In this component, we will create some radio buttons and input texts, so that users can select which classifier they want to train and by how many tests split.
<input type=”radio” name=”modelSelection” Random Forest <input type=”radio” name=”modelSelection” Logistic Regression <input type=”radio” name=”modelSelection” MLP Classifier <input type=”radio” name=”modelSelection” Gradient Boosting
6. Component for Alert Messages
This component is used for alerts and success messages.
7. Component for checking the Training Results
In this, we can see the Accuracy and Weighted F1 Score of the selected model after training.
8. Component for selecting Car Parameters
We can select the six parameters to check the performance of the car.
The Submit will remain disabled until you train the model.
9. Component to Output the Result
This component displays the predicted value.
10. Footer (Optional)
This is the footer for our web page
Our GUI is now created, ✌
Small NoteFrom now onwards, we will train our machine learning model. We need to add libraries in the Python Environment
– pandas – scikit-learn – numpy
Importing LibrariesFirstly we will import all the necessary libraries
import pandas as pd import pickle from sklearn.model_selection import train_test_split, GridSearchCV from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier from sklearn.neural_network import MLPClassifier from sklearn.metrics import accuracy_score, f1_score from chúng tôi import open_url import numpy as np Dataset PreprocessingAs discussed earlier, we will use Car Evaluation Dataset from UCI ML Repository.
You can download the dataset from that link.
This dataset contains six categorical features, which are Buying Price, Maintenance Price, No. of Doors, No. of Persons, Luggage Capacity, and Safety Qualifications
6. Safety – low, mid, high
The Output is classified into four classes namely, unacc, acc, good, vgood
4. vgood – Very Good
Function to Upsample the Dataset
def upSampling(data): from sklearn.utils import resample # Majority Class Dataframe df_majority = data[(data['score']==0)] samples_in_majority = data[data.score == 0].shape[0] # Minority Class Dataframe of all the three labels df_minority_1 = data[(data['score']==1)] df_minority_2 = data[(data['score']==2)] df_minority_3 = data[(data['score']==3)] # upsample minority classes df_minority_upsampled_1 = resample(df_minority_1, replace=True, n_samples= samples_in_majority, random_state=42) df_minority_upsampled_2 = resample(df_minority_2, replace=True, n_samples= samples_in_majority, random_state=42) df_minority_upsampled_3 = resample(df_minority_3, replace=True, n_samples= samples_in_majority, random_state=42) # Combine majority class with upsampled minority classes df_upsampled = pd.concat([df_minority_upsampled_1, df_minority_upsampled_2, df_minority_upsampled_3, df_majority]) return df_upsampledFunction to read input data and return processed data.
def datasetPreProcessing(): # Reading the content of CSV file. data = pd.read_csv(csv_url_content) pyscript.write("headingText", "Pre-Processing the Dataset...") # This is used to send messages to the HTML DOM. # Removing all the null values data.isna().sum() # Removing all the duplicates data.drop_duplicates() coloumns = ['buying', 'maint', 'doors', 'people', 'luggaage', 'safety', 'score'] # Converting Categorical Data into Numerical Data data['buying'] = data['buying'].replace('low', 0) data['buying'] = data['buying'].replace('med', 1) data['buying'] = data['buying'].replace('high', 2) data['buying'] = data['buying'].replace('vhigh', 3) data['maint'] = data['maint'].replace('low', 0) data['maint'] = data['maint'].replace('med', 1) data['maint'] = data['maint'].replace('high', 2) data['maint'] = data['maint'].replace('vhigh', 3) data['doors'] = data['doors'].replace('2', 0) data['doors'] = data['doors'].replace('3', 1) data['doors'] = data['doors'].replace('4', 2) data['doors'] = data['doors'].replace('5more', 3) data['people'] = data['people'].replace('2', 0) data['people'] = data['people'].replace('4', 1) data['people'] = data['people'].replace('more', 2) data['luggaage'] = data['luggaage'].replace('small', 0) data['luggaage'] = data['luggaage'].replace('med', 1) data['luggaage'] = data['luggaage'].replace('big', 2) data['safety'] = data['safety'].replace('low', 0) data['safety'] = data['safety'].replace('med', 1) data['safety'] = data['safety'].replace('high', 2) data['score'] = data['score'].replace('unacc', 0) data['score'] = data['score'].replace('acc', 1) data['score'] = data['score'].replace('good', 2) data['score'] = data['score'].replace('vgood', 3) upsampled_data = upSampling(data) return upsampled_dataLet’s understand these above functions in more detail:
1. Firstly, we have read the CSV File using the Pandas library.
2. You may be confused by this line py script.write(“headingText”, “Pre-Processing the Dataset…”).
This code updates the messages component in the HTML DOM that we have created above.
You can write any message in any HTML Tag
3. Then, we have removed the null values and the duplicates. But luckily, this dataset does not contain any null values.
4. Further, we have converted all the categorical data into numerical data.
5. Finally, we have performed upsampling of the dataset.
You can observe that the number of samples in one particular class is far more than in the other classes. Our model will be biased towards a specific class because it has very little data to train on other classes.
So we have to increase the number of samples in other classes. It is also called Upsampling.
I have created a separate function named upSampling that will upsample the data.
Now we have an equal number of samples for all the classes.
Training the ModelFunction to check which machine learning model is selected by the user for training.
def model_selection(): selectedModel = document.querySelector('input[name="modelSelection"]:checked').value; if selectedModel == "rf": document.getElementById("selectedModelContentBox").innerText = "Random Forest Classifier"; return RandomForestClassifier(n_estimators=100) elif selectedModel == "lr": document.getElementById("selectedModelContentBox").innerText = "Logistic Regression"; return LogisticRegression() elif selectedModel == "gb": document.getElementById("selectedModelContentBox").innerText = "Gradient Boosting Classifier"; return GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=1, random_state=0) else: document.getElementById("selectedModelContentBox").innerText = "MLP Classifier"; return MLPClassifier()Function to train the model on the chosen classifier.
def classifier(model, X_train, X_test, y_train, y_test): clf = model clf.fit(X_train, y_train) y_pred = clf.predict(X_test) y_score = clf.fit(X_train, y_train) acc_score = accuracy_score(y_test, y_pred) f1Score = f1_score(y_test, y_pred, average='weighted') return acc_score, model, f1Score def trainModel(e=None): global trained_model processed_data = datasetPreProcessing() # Take the Test Split as an input by the user test_split = float(document.getElementById("test_split").value) # If the test split is greater than 1 or less than 0 then we will throw an error. pyscript.write("headingText", "Choose Test Split between 0 to 1") return document.getElementById("testSplitContentBox").innerText = test_split; X = processed_data[['buying', 'maint', 'doors', 'people', 'luggaage', 'safety']] y = processed_data['score'] # Splitting the Dataset into training and testing. X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_split, random_state=42) # Below function can return the classification model choosen by the user model = model_selection() pyscript.write("headingText", "Model Training Started...") acc_score, trained_model, f1Score = classifier(model, X_train, X_test, y_train, y_test) pyscript.write("headingText", "Model Training Completed.") # Writing the value of accuracy and f1-score to the DOM document.getElementById("accuracyContentBox").innerText = f"{round(acc_score*100, 2)}%"; document.getElementById("f1ContentBox").innerText = f"{round(f1Score*100, 2)}%"; # Below code is to enable the Model Training Button when the Model is successfully trained. document.getElementById("submitBtn").classList.remove("disabled"); document.getElementById("submitBtn").disabled = False; document.getElementById("trainModelBtn").classList.remove("disabled"); document.getElementById("trainModelBtn").disabled = False; if e: e.preventDefault() return False Testing the ModelIn this section, we will test our model on the six parameters that we have discussed above.
Below is the function to test the model.
def testModel(e=None): buying_price = int(document.getElementById("buying_price").value) maintanence_price = int(document.getElementById("maintanence_price").value) doors = int(document.getElementById("doors").value) persons = int(document.getElementById("persons").value) luggage = int(document.getElementById("luggage").value) safety = int(document.getElementById("safety").value) arr = np.array([buying_price, maintanence_price, doors, persons, luggage, safety]).astype('float32') arr = np.expand_dims(arr, axis=0) result = trained_model.predict(arr) condition = "" if result[0] == 0: condition = "Unaccepted" elif result[0] == 1: condition = "Accepted" elif result[0] == 2: condition = "Good" else: condition = "Very Good" pyscript.write("resultText", f"Predicted Value: {condition}") if e: e.preventDefault() return FalseFirstly, we will take the input from the user and the feed that input to the model for prediction. Then finally, we output the results.
Our machine learning model is now trained.
Conclusion
Deployed Version – Link
Before PyScript, we don’t have any proper tool to use Python on the client-side. Frameworks such as Django or Flask can mainly use Python on the backend. In recent years, Python has grown its population immensely. It has been used in Machine Learning, Artificial Intelligence, Robotics, etc.
In this article, we have trained and tested a machine learning model completely in HTML language. You can increase the model’s accuracy by tuning some hyperparameters or searching for the best parameters using Grid Search CV or Randomized Search CV.
The main focus of this article is to use the chúng tôi library, not to achieve a high accuracy classification model.
4. Finally, we have written the code to test the model based on the user’s input.
Do check my other articles also.
Thanks for reading, 😊
The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.
Related
Update the detailed information about How To Make Unique Instagram Grid Layouts Using Individual Pictures. (Corner Grids) on the Minhminhbmm.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!