Python subplot size12/19/2023 ![]() Once the necessary data preprocessing steps were taken up, the Logistic regression model was fitted to the split data by importing the necessary scikit linear model package for Logistic Regression as shown below.įrom sklearn.linear_model import LogisticRegression Here random parameters for figure size were mentioned to obtain clear visible visual and later the initial images of the data were obtained as shown below.Īs we are working with the image dataset and for the classification of images we are using the Logistic Regression algorithm it was necessary to reshape the dependent component of the train and test appropriately as Logistic Regression is built to work with at most two dimensions of data and moreover this being an image dataset it is necessary to reduce the dimensions of the image data which is originally in three dimensions to two dimensions as shown below to evacuate the issues with respect to dimensionality. Plt.title('Sign language of '.format(Y_train)) Later the split data was used to visualize the data present across the training and testing phase using subplots to validate the split among the input and the output as shown below. ![]() It is a better practice to mention a random value for the random_state parameter while splitting the data to ensure uniform shuffles of data for training and testing. from sklearn.model_selection import train_test_split Once the dataset was loaded into the working environment the dataset was split for the training and testing with a split ratio of 80:20 respectively using the scikit-learn model selection module as shown below. The output of the shape command will be as shown below. Print('Output Dataframe shape',out_df.shape) print('Input Dataframe shape',inp_df.shape) The shape of the data can be computed as shown below. Once the dataset was loaded into the working environment the shape of the numpy data was determined to estimate the number of rows and columns present in the data and it was seen that there are 410 images of size (64,64) in the input data used and there are 410 images in the output data. Out_df=np.load('/content/drive/MyDrive/Colab notebooks/Image classificatiob using LOGREG/op.npy') ![]() inp_df=np.load('/content/drive/MyDrive/Colab notebooks/Image classificatiob using LOGREG/inp.npy') Below are the steps to be followed to load numpy data into the working environment. Case Study for Image Classification with Logistic RegressionĪs mentioned earlier as this article emphasizes using Logistic Regression for Image classification we are using the Hand Sign Digit Classification dataset with two categories of images showing Hand Signs of 0 and 1.Ī numpy format dataset was utilized for this article, so the input and the output dataset were loaded into the working environment appropriately as shown below and the main reason for using the numpy format data is for easy computation as numpy data processing is faster when compared to other data types. Logistic regression operates basically through a sigmoidal function for values ranging between 0 and 1. Logistic Regression is one of the supervised machine learning algorithms which would be majorly employed for binary class classification problems where according to the occurrence of a particular category of data the outcomes are fixed. ![]() Case Study for Image Classification with Logistic Regression.Image classification is mostly employed with Convolutional Neural Networks (CNNs), but this article is an attempt to showcase that even logistic regression has the capability to classify images efficiently with a reduction in computational time and also to waive off the tedious task of building complex models for image classification. Image Classification is a process of classifying various image categories to their appropriate labels or categories it is associated with.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |