Search Results
737 results found with an empty search
- CS6262 Network Security Assignment 4
1 Introduction/Assignment Goal The goal of this project is to introduce students to machine learning techniques and methodologies, that help to differentiate between malicious and legitimate network traffic. In summary, the students are introduced to: Use a machine learning-based approach to create a model that learns normal network traffic. Learn how to blend attack traffic, so that it resembles normal network traffic, and by-pass the learned model. 1 Readings & Resources This assignment relies on the following readings: ”Anomalous Payload-based Worm Detection and Signature Generation”, Ke Wang, Gabriela Cretu, Salvatore J.Stolfo, RAID2004. Link: http://cs.fit.edu/ pkc/id/related/wang05raid.pdf ”Polymorphic Blending Attacks”, Prahlad Fogla, Monirul Sharif, Roberto Perdisci, Oleg Kolesnikov, Wenke Lee, Usenix Security 2006. Link: wenke.gtisc.gatech.edu/papers/usenixsecurity2006.pdf True positive (true detections) and False positive (false alarms): https://en.wikipedia.org/wiki/Sensitivityandspecificity 2 Task A Preliminary reading. Please refer to the above readings to learn about how the PAYL model works: a) how to extract byte frequency from the data, b) how to train the model, and c) the definition of the parameters; threshold and smoothing factor. Code and data provided. Please look at the PAYL directory, where we provide the PAYL code and data to train the model. Install the Mahalanobispackages needed. Please read the file SETUP to install packages that are needed for the code to run. PAYL Code workflow. Here is the workflow of the provided PAYL code: Mahalanobis Read in the parameters: threshold for the mahalanobis distance and smoothing factor. The parameters need to be provided by the user. Read in the normal data and separate it into training and testing. 75% of the provided normal data is for training and 25% of the normal data is for testing. Read in the payloads of the training data. Sort the payload strings by length and generate a model for each length. Each model per length is based on [ mean frequency of each ascii, standard deviation of frequencies for each ascii] Read in the payloads of the test data. Test the testing data against the trained model: 1. Compute the mahalanobis distance between each test payload and the model (of the same length), and 2. Label the payload: If the Mahalanobis distance is below the threshold, then accept the payload as normal traffic. Otherwise, reject it as attack traffic. Select parameters and set them in the PAYL code. Run the PAYL code. python wrapper.py Observe the output of the PAYL code: The code reports the true positive. $ python wrapper.py Attack data not provided, training and testing model based on pcap files in data/ folder alone. To provide attack data, run the code as: python wrapper.py --------------------------------------------- Training Testing Total Number of testing samples: 7616 Percentage of True positives: XX.XX Exiting now Main Task: Perform experiments to select proper parameters. Provide different parameters as input to the code, and observe the True Positive rates. Please select parameters that give you a True Positive rate of 99% or above. Please note that it is entirely up to the student, to write her/his own wrappers around the code provided, as needed. e.g.a script to evaluate multiple parameters in parallel. Also please note that you may find multiple pairs of parameters that can achieve a TP of 99% and above. Deliverable. Please provide the threshold, the smoothing factor, and the true positive rate. See the Deliverables section for format. 3 Task B Train the model on normal data, using the parameters that you found from Task A. Test the attack trace against the model. Verify that it gets rejected. You should run as follows and observe the following output: $ python wrapper.py attack-trace-test Attack data provided, as command-line argument attack-trace-test --------------------------------------------- Training Testing Total Number of testing samples: 7616 Percentage of True positives: XX.XX -------------------------------------- Analyzing attack data, of length1 No, the calculated distance of ZZZZ is greater than the threshold of XXXX. It doesn’t fit the model. Total number of True Negatives: 100.0 Total number of False Positives: 0.0 Number of samples with the same length as attack payload: 1 4 Task C Preliminary reading. Please refer to the” Polymorphic Blending Attacks” paper. In particular, section 4.2 that describes how to evade 1-gram and the model implementation. More specifically we are focusing on the case where m <= n and the substitution is one-to-many. We assume that the attacker has a specific payload (attack payload) that he would like to blend in with the normal traffic. Also, we assume that the attacker has access to one packet (artificial profile payload) that is normal and is accepted as normal by the PAYL model. The attacker’s goal is to transform the byte frequency of the attack traffic so that it matches the byte frequency of the normal traffic and thus by-pass the PAYL model. Code provided: Please look at the Polymorphic blend directory. – How to run the code: Run task1.py Main function: Task1.py contains all the functions that are called. Output: The code should generate a new payload that can successfully by-pass the PAYL model that you have found above (using your selected parameters). The new payload (Output) is shellcode.bin + encrypted attack body + XOR table + padding. Please refer to the paper for full descriptions and definitions of Shellcode, attack body, XOR table, and padding. The Shellcode is provided. Substitution table: We provide the skeleton for the code needed to generate a substitution table, based on the byte frequency of attack payload and artificial profile payload. According to the paper, the substitution table has to be an array of length 256. For the purpose of implementation, the substitution table can be e.g.a python dictionary table. We ask that you complete the code for the substitution function. Padding: Similarly we provide a skeleton for the padding function and we ask that you write the rest. Main tasks: Please complete the code for the substitution.py and padding.py, to generate the new payload. Deliverables: Please deliver your code for the substitution and the padding, and the output of your code. Please see the section deliverables. 5 Task D Test your output (below noted as Output) against the PAYL model and verify that it is accepted. FP should be 100% indicating that the payload got accepted as legit, even though is malicious. You should run as follows and observe the following output: $ python wrapper.py Output Attack data provided, as command-line argument Output --------------------------------------------- Training Testing Total Number of testing samples: 7616 Percentage of True positives: XX.XX -------------------------------------- Analyzing attack data, of length1 Yes, the calculated distance of YYYY is lesser than the threshold of XXXX. It fits the model. Total number of True Negatives: 0.0 Total number of False Positives: 100.0 6 Deliverables & Rubric For this project, please provide the following deliverables. PART A: 35 points) Please report the parameters that you found in a file named Parameters. Please report a decimal with 2 digit accuracy for each parameter. Format: |Threshold:1.23| |SmoothingFactor:1.24| |TruePositiveRate:80.95| PART B: 5 points Please report the score of the payload after completing part B. Format: |Distance:2000| PART C: 40 points Please submit the code for substitution.py and padding.py. PART D: 20 points Please submit your Output from Part C. If you need any type of help related Machine Learning project, then, please contact us at here.
- Index, Slice and Reshape NumPy Arrays for Machine Learning
Sometimes, when we working on Machine learning datasets then we need to slice, index or reshape datasets as per given requirements. It is an important part of prepare data in datasets, in this blog we will learn all types of slicing in machine learning so that we can easily handle datasets for ML or data science tasks. How slicing datasets? Machine learning data is present as an array format, which means it is in 1 D array, 2 D array, etc. In python, it represents using NumPy arrays. In this tutorial, we will be working with the Numpy array to extract data from datasets. Reading Data Data is read from different ways like list data, CSV format or excel. But in this, we will work with the list and CSV file. List data: 1D array # one dimensional example >>> from numpy import array # list of data >>> data = [1, 2, 3, 4, 5] # array of data >>> data = array(data) >>> print(data) List data: 2D array >>> from numpy import array # list of data >>> data = [[1, 2], [3, 4], [5, 6]] # array of data >>> data = array(data) >>> print(data) >>> print(type(data)) Array Index Once your data is represented using a NumPy array, you can access it using indexing. 1-Dimensional Indexing Index data can be access using given below print statements for 1-D Numpy array # index data >>> print(data[0]) >>> print(data[4]) 2-Dimensional Indexing # index data >>> print(data[0,0]) Array Slicing If you not know about ML and start to read it then first it is a very tuff task for beginners that how to slicing datasets as per your requirements. To do this use colon operator ‘:’ with a ‘from‘ and ‘to‘ index before and after the column respectively. Syntax: >>> data[from:to] >>> print(data[:]) 1-Dimensional Slicing >>> print(data[0:1]) >>> print(data[-2:]) 2-Dimensional Slicing In these two colon-separated by comma and the first one for row and second one column. Syntax: >>> data[:, :-1] or >>> data[:, -1] You can take own data and try these itself and get output if you need other help then comments below the comments section so we can reply to your comments and make something is missing then we modifying blog. We will always provide the best services for any projects if you need help with any projects then please contact us here.
- Replacing strings with numbers in Python for Data Analysis with pandas
In this blog, we will learn how to implement string format data in ML and how to fit it into ML models. Sometimes data is given in string format which is not fit into ML models, to solve this issue first changing a string value into any numeric value and then split it into training and testing data. Let we will learn below data and fit it into ML models then we need to change sex column value into numeric like- F(Female) - 1 M(Male) - 2 Here we change the value of F by 1 and M by 2, here below python code to do this is: Here below steps to do this: Step 1: Read the CSV file using: >>> df = pd.read_csv('mydata.csv') >>> df.head() And after this remove all nan value from the dataset >>> data = df.dropna() Step 2: Divided data into target and source for training and testing. We will use one column as target for prediction # divide data for training and testing >>> x=data.drop('target column',axis=1) >>> y=data.target column Now we will split data into training and testing >>> from sklearn.model_selection import train_test_split >>> x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.5) Now we will change the value string to numeric for data analysis and fit it into ML models for predictions. Dropping unnecessary column from data using drop: >>> x_train_data = x_train.drop(['name'],axis=1) Step 3: >>>x_train_data .sex[x_train.sex == 'F'] = 1 >>>x_train_data .sex[x_train.sex == 'M'] = 2 By using this all value of sex column is updated to numeric values. Step 4: After this, we will fit it into the models Fit into the Logistic Regression >>> model = LogisticRegression() >>> fit = model .fit(x_train_data, y_train) I hope it may be helpful for you, and there are many models which you need to predict or need help to predict any types of ML models then contact us here We have a highly professional expert team that help any type of machine learning and data science problem and give better solutions within your due date.
- Need help with Database homework on Azure - Codersarts
Are you looking for Database homework on Azure? We offers database homework help in SQL Server, Database On Azure, Oracle, MySQL, MongoDB. postgresql, PhpMyAdmin, Microsoft Azure Assignment help. Database homework on Azure Topics include: Deploying SQL Server Deploying SQL Server to various environments and scenarios Migrating databases between versions and platforms Course hands-on Azure SQL Server Connection Creating database Database connection URL setup Azure SQL Databases with ASP.NET What is Azure database Azure SQL Database is a general-purpose relational database-as-a-service (DBaaS). SQL Database is a high-performance, reliable, and secure cloud database that you can use to build data-driven applications and websites in the programming language of your choice, without needing to manage infrastructure. Other database homework help service Database Assignment Help MongoDB Assignment Help SQL Homework Help #databaseAssignmentHelp #mongodbAssignmentHelp #SQlHomeworkHelp
- String Manipulation In Python
It is the process of python built-in string methods and formatting operations. In python, the string can be defined between the single and double quotations. x = 'string here 1' y = "string here 1" x == y it gives "true" as an output. String Manipulation in Python In python string handle through many ways like: upper() - Used to change a string into the uppercase letter lower() - Used to change a string into the lowercase letter capitalize() - show string with the first letter as a capital title() - It works as a capitalize() swapcase() - every string word look as first and the last word is capital Let we will learn these string manipulation functions using python which is given below: Adding and removing spaces - Formatting of string In the python strip() method used to remove space, it strips whitespace from the beginning and end of the line. Let suppose string is - >>> string = " Welcome to the Codersarts " >>> string.strip() Output result shows without any space in string. Another way to remove space from left and right side of the string is like - rstrip() or - remove space from the right side of a string lstrip() - remove space from the left side of the string There are many other formattings of strings center() - Center the string within given space ljust() and - will left-justify the string within spaces of a given length. rjust() - right-justify the string within spaces of a given length zfill() - which is a special method to right-pad a string with zeros. Finding and replacing substrings This is the main common feature that is used to find and replacing substrings from a string in python. find()/rfind(), index()/rindex(), and replace() These built-in methods are the best for finding and replacing substrings. Now we discuss rfind() and rindex() methods- These work same as above but searching from the end, not beginning and rindex() rfind() startswith() and methods endswith() - These used in python for the special case of checking for a substring at the beginning or end of a string. replace() - Use to replace a given substring with a new string. Splitting and partitioning strings If you want to find substring and then split the string based on its location, the partitions() and/or split() methods used. The split() method is more useful. The default is to split on any whitespace, returning a list of the individual words in a string: For Ex - line = "This is codersarts blog" line.split() It output shows as: ['This', 'is', 'codersarts', 'blog'] Another related method is splitlines(), which splits on newline characters. >>> string = """this >>> is codersarts >>> blog""" string.splitlines() The outcome is like that - ['this', 'is codersarts', 'blog'] Format Strings Used to manipulate strings into desired formats. string representations can always be found using the str() function. let we learn it as - >>> number= 2.458 >>> str(number) The outcome is like that - '2.458', it is an string formate of number 2.458 A more flexible way to do this is to use format strings, which are strings with special markers (noted by curly braces) Let we check this: >>> print("The value of number is {}".format(number)) Output: 'The value of the number is 2.458' Another more examples to formatting string are like this: >>> print("My name is: {0}. and village is: {1}.".format('Naveen kumar', 'Etah')) 'My name is: Naveen kumar. and village is: Etah.' >>> print("First letter: {first}. Last letter: {last}.".format(last='N', first='R')) 'First letter: N. Last letter: R.' Apply on digit: >>> number = 3.142 >>> print("number= {0:.2f}".format(number)) 'number= 3.14' In this blog, we will cover the most useful string manipulation methods which are used in python to manipulate the string. It makes easy to perform the operation on strings. If you like Codersarts blogs then please make comments in blow comments sections or give an idea if anything is missing so we can analyze our skill and provide the best ideas to us. If you need any type of programming, coding or project help then visit Codersarts or contact here.
- Machine Learning Algorithms- Fit and predict train and test data
Hi, In this post, we will learn how machine learning algorithm work, here we go through basic concepts of all the machine learning algorithms and how to fit and predict train and test data in machine learning. Types of ML Algorithms: ML Algorithms divided into three categories - 1. Supervised Learning 2. Unsupervised Learning 3. Reinforcement Learning Supervised Learning It consists of the target variable (or dependent variable) which is to be predicted from a given set of predictors (independent variables). The training process continues until the model achieves a desired level of accuracy on the training data. Types of Supervised Learning Regression, Decision Tree, Random Forest, KNN, Logistic Regression, etc. Unsupervised Learning This algorithm work without having any target or outcome variable to predict. It is used for the clustering population in different groups, which is used for segmenting customers in different groups. Types of Unsupervised Learning Apriori algorithm, K-means Reinforcement Learning This algorithm used from past experience and tries to capture the best possible knowledge to find accurate decisions. Types of Reinforcement Learning Markov Decision Process Linear Regression # importing required libraries import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error Logistic Regression Decision Tree SVM (Support Vector Machine) Naive Bayes KNN (k- Nearest Neighbors) K-Means Metrics to Evaluate your Machine Learning Algorithm There are different types of metrics used to evaluate ML Algorithms : Classification Accuracy Logarithmic Loss Confusion Matrix Area under Curve F1 Score Mean Absolute Error Mean Squared Error Here we will create basic train and test data and fit it into different models, you can also try it itself, here we some changes are made the first one is set appropriate libraries and fit data. For more visit go to the Codersarts official website - click here
- K-Mean Cluster - Working with Machine learning Unsupervised Algorithm
K-means clustering is one of the simplest and popular unsupervised machine learning algorithms. Here unsupervised mean, its interference with datasets without referring to known, or labeled outcomes. First, we need to created random clusters and these are points to the centroid. After this find the distance from each centroid until we will not get the correct result. It works with using repeating some numbers of iterations. Steps to do it First, import all related libraries like skit-learn and use some random data to illustrate a K-means clustering simple explanation. Import libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import Kmean %matplotlib inline Generate random data Then after this, we will generate random data. ------------------------------------------------------------- center_1 = np.array([1,1]) center_2 = np.array([2,8]) center_3 = np.array([10,8]) X = 2+2.5 *np.random.rand(200,2) + center_1 X1 = 2+2 *np.random.rand(200,2) + center_2 X2 = 1+2 *np.random.rand(200,2) + center_3 data = np.concatenate((X, X1, X3), axis = 0) plt.scatter(X[:,0], X[:,1], s=7, c='b', label = 'Cluster 1') plt.scatter(X1[:,0], X1[:,1], s=7, c='r') plt.scatter(X2[:,0], X2[:,1], s=7, c='k') plt.show() --------------------------------------------------------------- It draws like this: Then after this fit into the Kmean Algorithms: ---------------------------------------------- from sklearn.cluster import KMeansKmean = KMeans(n_clusters=2) Kmean.fit(data) ---------------------------------------------- Find the centroid of each cluster --------------------------------------------- Kmean.cluster_centers_ --------------------------------------------- Outputs look like that: array([[ 4.25116126, 4.23343225], [ 4.89833143, 10.92433901], [ 2.029634 , 2.10565485]]) Use these center points to draw on clusters as below code: ------------------------------------------------------- plt.scatter(X[:,0], X[:,1], s=7, c='b', label = 'Cluster 1') plt.scatter(X1[:,0], X1[:,1], s=7, c='r') plt.scatter(X2[:,0], X2[:,1], s=7, c='k') color = ['red','green','yellow'] plt.scatter(2.029634, 2.10565485, s=200, c=color[0], marker='*', label='centroid 1') plt.legend() plt.show() --------------------------------------------------------- I hope this blog is more helpful in creating clusters and finding centers of each cluster and then plot each clusters with the centroids. Thanks for reading this blog if you need any type of help related to the python machine learning then contact here or comments below so that we can solve our issue and give and reply.
- JavaScript Math, Random and Boolean
JavaScript Math Object The JavaScript Math object allows you to perform mathematical tasks on numbers. Example: Math.sin() Math.sin(x) returns the sine (a value between -1 and 1) of the angle x (given in radians). If you want to use degrees instead of radians, you have to convert degrees to radians: Angle in radians = Angle in degrees x PI / 180. Example: Math.min() and Math.max() Math.min() and Math.max() can be used to find the lowest or highest value in a list of arguments: Example: Math Constructor Unlike other global objects, the Math object has no constructor. Methods and properties are static. All methods and properties (constants) can be used without creating a Math object first. Math Object Methods Method Description abs(x) Returns the absolute value of x acos(x) Returns the arccosine of x, in radians asin(x) Returns the arcsine of x, in radians atan(x) Returns the between -PI/2 arctangent of x as a numeric value and PI/2 radians atan2(y, x) Returns the arctangent of the quotient of its arguments ceil(x) Returns the value of x rounded up to its nearest integer cos(x) Returns the cosine of x (x is in radians) exp(x) Returns the value of Ex floor(x) Returns the value of x rounded down to its nearest integer log(x) Returns the natural logarithm (base E) of x max(x, y, z, ..., n) Returns the number with the highest value min(x, y, z, ..., n) Returns the number with the lowest value pow(x, y) Returns the value of x to the power of y random() Returns a random number between 0 and 1 round(x) Returns the value of x rounded to its nearest integer sin(x) Returns the sine of x (x is in radians) sqrt(x) Returns the square root of x tan(x) Returns the tangent of an angle JavaScript Random Math.random() Math.random() returns a random number between 0 (inclusive), and 1 (exclusive): Math.random() always returns a number lower than 1. Example: JavaScript Random Integers Math.random() used with Math.floor() can be used to return random integers. Example: JavaScript Booleans A JavaScript Boolean represents one of two values: true or false. Boolean Values Very often, in programming, you will need a data type that can only have one of two values, like YES / NO ON / OFF TRUE / FALSE For this, JavaScript has a Boolean data type. It can only take the values true or false. The Boolean() Function You can use the Boolean() function to find out if an expression (or a variable) is true: Example: Comparisons and Conditions The chapter JS Comparisons gives a full overview of comparison operators. The chapter JS Conditions gives a full overview of conditional statements. The Boolean value of an expression is the basis for all JavaScript comparisons and conditions. Booleans Can be Objects Normally JavaScript booleans are primitive values created from literals: var x = false; But booleans can also be defined as objects with the keyword new: var y = new Boolean(false); Example: Note:- Do not create Boolean objects. It slows down execution speed.
- JavaScript Date objects and methods
JavaScript Date Objects JavaScript Date Object lets us work with dates: Example: JavaScript Date Output By default, JavaScript uses the browser's time zone and display a date as a full text string: Fri Oct 18 2019 11:35:53 GMT+0530 (IST) Creating Date Objects Date objects are created with the new Date() constructor. There are 4 ways to create a new date object: new Date() new Date(year, month, day, hours, minutes, seconds, milliseconds) new Date(milliseconds) new Date(date string) new Date() new Date() creates a new date object with the current date and time. Example: Date objects are static. The computer time is ticking, but date objects are not. new Date(year, month, ...) new Date(year, month,...) creates a new date object with a specified date and time. 7 numbers specify year, month, day, hour, minute, second, and millisecond (in that order): 6 numbers specify year, month, day, hour, minute, second. 5 numbers specify year, month, day, hour, and minute. 4 numbers specify year, month, day, and hour.milliseconds. 3 numbers specify year, month, and day. 2 numbers specify year and month. Month can not be omitted. If only one parameter is supplied, it will be treated as milliseconds. Example: Note:- JavaScript counts months from 0 to 11. January is 0. December is 11. Previous Century One and two digit years will be interpreted as 19xx: Example: JavaScript Stores Dates as Milliseconds JavaScript stores dates as number of milliseconds since January 01, 1970, 00:00:00 UTC (Universal Time Coordinated). Zero time is January 01, 1970 00:00:00 UTC. Now the time is: 1571378753606 milliseconds past January 01, 1970 new Date(milliseconds) new Date(milliseconds) creates a new date object as zero time plus milliseconds. Using new Date(milliseconds), creates a new date object as January 1, 1970, 00:00:00 Universal Time (UTC) plus the milliseconds. Example: Note:- One day (24 hours) is 86 400 000 milliseconds. Date Methods When a Date object is created, a number of methods allow you to operate on it. Date methods allow you to get and set the year, month, day, hour, minute, second, and millisecond of date objects, using either local time or UTC (universal, or GMT) time. Displaying Dates JavaScript will (by default) output dates in full text string format. When you display a date object in HTML, it is automatically converted to a string, with the toString() method. The toUTCString() method converts a date to a UTC string (a date display standard). The toDateString() method converts a date to a more readable format. Example: JavaScript Date Formats JavaScript Date Input There are generally 3 types of JavaScript date input formats: Type Example ISO Date "2015-03-25" (The International Standard) Short Date "03/25/2015" Long Date "Mar 25 2015" or "25 Mar 2015" The ISO format follows a strict standard in JavaScript. The other formats are not so well defined and might be browser specific. JavaScript Date Output Independent of input format, JavaScript will (by default) output dates in full text string format: Wed Mar 25 2015 05:30:00 GMT+0530 (IST) JavaScript ISO Dates ISO 8601 is the international standard for the representation of dates and times. The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format. Example (Complete date) The computed date will be relative to your time zone. Depending on your time zone, the result above will vary between March 24 and March 25. Note:- UTC (Universal Time Coordinated) is the same as GMT (Greenwich Mean Time). Time Zones When setting a date, without specifying the time zone, JavaScript will use the browser's time zone. When getting a date, without specifying the time zone, the result is converted to the browser's time zone. In other words: If a date/time is created in GMT (Greenwich Mean Time), the date/time will be converted to IST (Indian Standard Time) if a user browses from India. JavaScript Short Dates. Short dates are written with an "MM/DD/YYYY" syntax like this. Example: JavaScript Long Dates. Long dates are most often written with a "MMM DD YYYY" syntax like this. Month and day can be in any order. And, month can be written in full (January), or abbreviated (Jan). Commas are ignored. Names are case insensitive. Example: Date Input - Parsing Dates If you have a valid date string, you can use the Date.parse() method to convert it to milliseconds. Date.parse() returns the number of milliseconds between the date and January 1, 1970. You can then use the number of milliseconds to convert it to a date object. Example: JavaScript Get Date Methods These methods can be used for getting information from a date object: Method Description getFullYear() Get the year as a four digit number (yyyy) getMonth() Get the month as a number (0-11) getDate() Get the day as a number (1-31) getHours() Get the hour (0-23) getMinutes() Get the minute (0-59) getSeconds() Get the second (0-59) getMilliseconds() Get the millisecond (0-999) getTime() Get the time (milliseconds since January 1, 1970) getDay() Get the weekday as a number (0-6) Date.now() Get the time. ECMAScript 5. The getTime() Method The getTime() method returns the number of milliseconds since January 1, 1970: Example: The getMonth() Method The getMonth() method returns the month of a date as a number (0-11). In JavaScript, the first month (January) is month number 0, so December returns month number 11. You can use an array of names, and getMonth() to return the month as a name. Example: The getDate() Method The get Date() method returns the day of a date as a number (1-31). Example: UTC Date Methods UTC date methods are used for working with UTC dates (Universal Time Zone dates): Method Description getUTCDate() Same as getDate(), but returns the UTC date getUTCDay() Same as getDay(), but returns the UTC day getUTCFullYear() Same as getFullYear(), but returns the UTC year getUTCHours() Same as getHours(), but returns the UTC hour getUTCMilliseconds() Same as getMilliseconds(), but returns the UTC milliseconds getUTCMinutes() Same as getMinutes(), but returns the UTC minutes getUTCMonth() Same as getMonth(), but returns the UTC month getUTCSeconds() Same as getSeconds(), but returns the UTC seconds JavaScript Set Date Methods Set Date methods let you set date values (years, months, days, hours, minutes, seconds, milliseconds) for a Date Object. Set Date Methods Set Date methods are used for setting a part of a date: Method Description setDate() Set the day as a number (1-31) setFullYear() Set the year (optionally month and day) setHours() Set the hour (0-23) setMilliseconds() Set the milliseconds (0-999) setMinutes() Set the minutes (0-59) setMonth() Set the month (0-11) setSeconds() Set the seconds (0-59) setTime() Set the time (milliseconds since January 1, 1970) The setFullYear() Method The setFullYear() method sets the year of a date object. In this example to 2020. The setFullYear() method can optionally set month and day. Example: The setHours() Method The setHours() method sets the hours of a date object (0-23): Example: Compare Dates Dates can easily be compared. JavaScript counts months from 0 to 11. January is 0. December is 11. The following example compares today's date with January 14, 2100 Example:
- Learning Path: Machine Learning for beginner
Start learning machine learning for beginner is always a challenging or may be unclear task like from where you can start machine learning, what is best online reference or material, which is best for machine learning python or R. There are lots of material available over internet from there you can learn machine learning but there are very rare website where you will get everything worth. however, i personally feel that for a beginner just keep in the mind first note down the main headings or topics of machine learning that you want to learn and search best website for each topics related to. so in this article i am going to show you what is path of machine learning. There are following steps: Step 1: Which is best for machine learning Python or R Python is always good options for beginner when you are going to learn machine learning with the following benefits. Why python is the best for machine learning You learning a lots programming capability and easy syntax. There are large no of community or website actively sharing machine learning content so you can easily get that. Actively new update You can easily get machine expert or tutor online. Large no of packages and libraries support API Integration is easily available. There may be other good reason it depends on individual knowledge and use. so you can comment below if you have. Python is also a good choice for if you are programmer or software developer or from computer science background but if you are from non-programming background and want to perform only data analytics and math related stuff and your vision in only to data visualisation and data insights nothing else then go for R. But As a student if you learn R you are going to confine or limit yourself in boundaries or only for Statistics Step 2: Data Preparation or Exploration To be good at machine learning or master in it. Its not about selection of good algorithm or programming language but understand data, collecting data from right source, unbiased data, cleaning data and based on data exploration you can choose fitting algorithm. These are some best data preparation strategies to prepare good data. Variable Identification, Univariate and Multivariate analysis Missing values treatment Outlier treatment Feature Engineering Step 3: Introduction to Machine Learning When you are comfortable with data handling and selection now you can learn deep dive into algorithm and functions. There is three main task of every machine learning algorithms Train the model Testing the model Predicating the model Step 4: Advanced Machine Learning After learning and understanding the machine learning you can explore advanced machine learning techniques like Deep Learning and Machine Learning with Big Data. Deep Learning: Below are the list of deep learning resources that will help you to get started: deeplearning.net. You will find everything here – lectures, datasets, challenges, tutorials. Another course from Geoff Hinton a try in a bid to understand the basics of Neural Networks. Pattern recognition using Python (Resource 1, Resource 2, Resource 3) and R (Resource ) Text Mining using Python (Resource) and R (Resource 1 , Resource 2) Ensemble Modeling Ensembling can add a lot of power to your models and has been a very successful technique in various Kaggle competitions. Machine Learning with Big Data There are various application of machine learning algorithms like "spam detection", "web document classification", "fraud detection", "recommendation system" and many others. Below are the list of tutorials to deal with big data using machine learning. Scalable Machine Learning Packages for Big Data in Python ( Pydoop, PyMongo) and R (Resource1, Resource2)
- JavaScript Arrays
JavaScript Arrays JavaScript arrays are used to store multiple values in a single variable. Example: What is an Array? An array is a special variable, which can hold more than one value at a time. An array can hold many values under a single name, and you can access the values by referring to an index number. Creating an Array Using an array literal is the easiest way to create a JavaScript Array. Syntax: var array_name = [ item1, item2, ...]; Example: Spaces and line breaks are not important. A declaration can span multiple lines. Putting a comma after the last element (like "BMW",) is inconsistent across browsers. IE 8 and earlier will fail. Using the JavaScript Keyword new The JavaScript new keyword is used to create a new array and to assign values to it. Example: The above two examples are the same. For simplicity, readability and execution speed, the first one (the array literal method) is used. Access the Elements of an Array An array element can be accessed by referring to its index number. Example: Note:- Array indexes start with 0. [0] is the first element. [1] is the second element. Changing an Array Element The values of an array can be changed. Example: Access the Full Array With JavaScript, the full array can be accessed by referring to the array name: Example: Arrays are Objects Arrays are a special type of objects. The typeof operator in JavaScript returns "object" for arrays. But, JavaScript arrays are best described as arrays. Array: Arrays use numbers to access its "elements". In this example, person[0] returns Mukesh. Example: Object: Objects use names to access its "members". In this example, person.fname returns Mukesh. Example: Array Elements Can Be Objects JavaScript variables can be objects. Arrays are special kinds of objects. Because of this, you can have variables of different types in the same Array. You can have objects in an Array. You can have functions in an Array. You can have arrays in an Array: myArray[0] = Date.now; myArray[1] = myFunction; myArray[2] = myCars; Array Properties and Methods The real strength of JavaScript arrays are the built-in array properties and methods: The length Property The length property of an array returns the length of an array (the number of array elements). Example: The length property is always one more than the highest array index. Accessing the First and Last Array Element Example: Associative Arrays Many programming languages support arrays with named indexes. Arrays with named indexes are called associative arrays (or hashes). JavaScript does not support arrays with named indexes. In JavaScript, arrays always use numbered indexes. Example: Note:- If you use named indexes, JavaScript will redefine the array to a standard object. After that, some array methods and properties will produce incorrect results. The Difference Between Arrays and Objects In JavaScript, arrays use numbered indexes. In JavaScript, objects use named indexes. Arrays are a special kind of objects, with numbered indexes. When to Use Arrays. When to use Objects. JavaScript does not support associative arrays. You should use objects when you want the element names to be strings (text). You should use arrays when you want the element names to be numbers. Avoid new Array() There is no need to use the JavaScript's built-in array constructor new Array(). Use [] instead. These two different statements both create a new empty array named points: var points = new Array(); // Bad var points = []; // Good JavaScript Array Methods Converting Arrays to Strings The JavaScript method toString() converts an array to a string of (comma separated) array values. Example: Popping and Pushing When you work with arrays, it is easy to remove elements and add new elements. This is what popping and pushing is: Popping items out of an array, or pushing items into an array. Popping The pop() method removes the last element from an array. The pop() method returns the value that was "popped out". Example: Pushing The push() method adds a new element to an array (at the end). The push() method returns the new array length. Example: Shifting Elements Shifting is equivalent to popping, working on the first element instead of the last. The shift() method removes the first array element and "shifts" all other elements to a lower index. The shift() method returns the string that was "shifted out". The unshift() method adds a new element to an array (at the beginning), and "unshifts" older elements. The unshift() method returns the new array length. Example: Changing Elements Array elements are accessed using their index number. Array indexes start with 0. [0] is the first array element, [1] is the second, [2] is the third ... The length property provides an easy way to append a new element to an array. Example: Deleting Elements Since JavaScript arrays are objects, elements can be deleted by using the JavaScript operator delete. Example: Using delete may leave undefined holes in the array. Use pop() or shift() instead. Splicing an Array The splice() method can be used to add new items to an array. The splice() method returns an array with the deleted items. Example: JavaScript Sorting Arrays Sorting an Array The sort() method sorts an array alphabetically: Example: Reversing an Array The reserve() method reverses the elements in an array. You can use it to sort an array in descending order. Example: Numeric Sort By default, the sort() function sorts values as strings. This works well for strings. However, if numbers are sorted as strings, "25" is bigger than "100", because "2" is bigger than "1". Because of this, the sort() method will produce incorrect result when sorting numbers. Example: Find the Highest (or Lowest) Array Value There are no built-in functions for finding the max or min value in an array. However, after you have sorted an array, you can use the index to obtain the highest and lowest values. Example: Sorting a whole array is a very inefficient method if you only want to find the highest (or lowest) value. My Min / Max JavaScript Methods This function loops through an array comparing each value with the highest value found: Example: This function loops through an array comparing each value with the lowest value found: JavaScript Array Iteration Methods Array iteration methods operate on every array item. Array.forEach() The forEach() method calls a function (a callback function) once for each array element. Note that the function takes 3 arguments: The item value The item index The array itself Example: Array.map() The map() method creates a new array by performing a function on each array element. The map() method does not execute the function for array elements without values. The map() method does not change the original array. Example: Note that the function takes 3 arguments: The item value The item index The array itself When a callback function uses only the value parameter, the index and array parameters can be omitted Array.filter() The filter() method creates a new array with array elements that passes a test. This example creates a new array from elements with a value larger than 18: Example: Note that the function takes 3 arguments: The item value The item index The array itself Array.reduce() The reduce() method runs a function on each array element to produce (reduce it to) a single value. The reduce() method works from left-to-right in the array. See also reduceRight(). The reduce() method does not reduce the original array. Example: Note that the function takes 4 arguments: The total (the initial value / previously returned value) The item value The item index The array itself Array.reduceRight() The reduceRight() method runs a function on each array element to produce (reduce it to) a single value. The reduceRight() works from right-to-left in the array. See also reduce(). The reduceRight() method does not reduce the original array. Example: Note that the function takes 4 arguments: The total (the initial value / previously returned value) The item value The item index The array itself
- JavaScript Strings and Numbers Tutorial
JavaScript Strings JavaScript strings are used for storing and manipulating text. A JavaScript string is zero or more characters written inside quotes. Single or double quotes can be used. Quotes can be used inside a string, as long as they don't match the quotes surrounding the string. Example: String Length To find the length of a string, use the built-in length property. The length property returns the length of a string. Example: Escape Character The backslash (\) escape character turns special characters into string characters: Code Result Description \' ' Single quote \" " Double quote \\ \ Backslash The sequence \" inserts a double quote in a string. Example: Six other escape sequences are valid in JavaScript. Code Result \b Backspace \f Form Feed \n New Line \r Carriage Return \t Horizontal Tabulator \v Vertical Tabulator Note:- The 6 escape characters above were originally designed to control typewriters, teletypes, and fax machines. They do not make any sense in HTML. Breaking Long Code Lines For best readability, programmers often like to avoid code lines longer than 80 characters. If a JavaScript statement does not fit on one line, the best place to break it is after an operator. You can also break up a code line within a text string with a single backslash. Example: Note:- The \ method is not the preferred method. It might not have universal support. Some browsers do not allow spaces behind the \ character. A safer way to break up a string, is to use string addition. Example: Note:- You cannot break up a code line with a backslash. Strings Can be Objects Normally, JavaScript strings are primitive values, created from literals: var firstName = "John"; But strings can also be defined as objects with the keyword new: var firstName = new String("John"); Example: Note:- Don't create strings as objects. It slows down execution speed. The new keyword complicates the code. This can produce some unexpected results. When using the == operator, equal strings are equal. When using the === operator, equal strings are not equal, because the === operator expects equality in both type and value. Or even worse. Objects cannot be compared. Example: Note:- Comparing two JavaScript objects will always return false. JavaScript String Methods String methods help you to work with strings. String Methods and Properties Primitive values, like "Hello There", cannot have properties or methods (because they are not objects). But with JavaScript, methods and properties are also available to primitive values, because JavaScript treats primitive values as objects when executing methods and properties. String Length The length property returns the length of a string. Example: Finding a String in a String The indexof() method returns the index of (the position of) the first occurrence of a specified text in a string: Example: JavaScript counts positions from zero. 0 is the first position in a string, 1 is the second, 2 is the third ... The lastIndexof() method returns the index of the last occurrence of a specified text in a string. Example: Note:- Both indexof() and lastIndexof() return -1 if the text is not found. Both methods accept a second parameter as the starting position for the search: The lastIndexof() methods searches backwards (from the end to the beginning), meaning: if the second parameter is 15, the search starts at position 15, and searches to the beginning of the string. Searching for a String in a String The search() method searches a string for a specified value and returns the position of the match. Example: Extracting String Parts There are 3 methods for extracting a part of a string: slice(start, end) substring(start, end) substr(start, length) The slice() Method slice() extracts a part of a string and returns the extracted part in a new string. The method takes 2 parameters: the start position, and the end position (end not included). Example: Note:- JavaScript counts positions from zero. First position is 0. If a parameter is negative, the position is counted from the end of the string. If you omit the second parameter, the method will slice out the rest of the string. The substring() Method substring() is similar to slice(). The difference is that substring() cannot accept negative indexes. Example: If you omit the second parameter, substring() will slice out the rest of the string. The substr() Method substr() is similar to slice(). The difference is that the second parameter specifies the length of the extracted part. Example: If you omit the second parameter, substr() will slice out the rest of the string. If the first parameter is negative, the position counts from the end of the string. Replacing String Content The replace() method replaces a specified value with another value in a string: Example: The replace() method does not change the string it is called on. It returns a new string. By default, the replace() method replaces only the first match. By default, the replace() method is case sensitive. To replace case insensitive, use a regular expression with an /i flag (insensitive). Note that regular expressions are written without quotes. To replace all matches, use a regular expression with a /g flag (global match). Converting to Upper and Lower Case A string is converted to upper case with toUpperCase(). Example: A string is converted to lower case with toLowerCase(). Example: The concat() Method concat() joins two or more strings: Example: The concat() method can be used instead of the plus operator. These two lines do the same: All string methods return a new string. They don't modify the original string. Formally said: Strings are immutable: Strings cannot be changed, only replaced. String.trim() The trim() method removes whitespace from both sides of a string. Example: The trim() method is not supported in Internet Explorer 8 or lower. If you need to support IE 8, you can use replace() with a regular expression instead: You can also use the replace solution above to add a trim function to the JavaScript String.prototype. JavaScript Numbers JavaScript has only one type of number. Numbers can be written with or without decimals. Example: Extra large or extra small numbers can be written with scientific (exponent) notation. JavaScript Numbers are Always 64-bit Floating Point Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc. JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard. This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63: Value (aka Fraction/Mantissa) Exponent Sign 52 bits (0 - 51) 11 bits (52 - 62) 1 bit (63) Precision Integers (numbers without a period or exponent notation) are accurate up to 15 digits. The maximum number of decimals is 17, but floating point arithmetic is not always 100% accurate. Adding Numbers and Strings JavaScript uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated. If you add a string and a number, the result will be a string concatenation. Example: Numeric Strings JavaScript strings can have numeric content: var a = 100; // a is a number var b = "100"; // b is a string JavaScript will try to convert strings to numbers in all numeric operations. JavaScript allows the division(/), multiplication(*) and substraction(-) on strings, but does not support addition(+). NaN - Not a Number NaN is a JavaScript reserved word indicating that a number is not a legal number. Trying to do arithmetic with a non-numeric string will result in NaN (Not a Number). Example: However, if the string contains a numeric value , the result will be a number. You can use the global JavaScript function isNaN() to find out if a value is a number. Watch out for NaN. If you use NaN in a mathematical operation, the result will also be NaN. NaN is a number: typeof NaN returns number. Infinity Infinity (or -Infinity) is the value JavaScript will return if you calculate a number outside the largest possible number. Example: Division by 0 (zero) also generates Infinity Infinity is a number: typeof Infinity returns number. Hexadecimal JavaScript interprets numeric constants as hexadecimal if they are preceded by 0x. Example: By default, JavaScript displays numbers as base 10 decimals. But you can use the to String() method to output numbers from base 2 to base 36. Hexadecimal is base 16. Decimal is base 10. Octal is base 8. Binary is base 2. Numbers Can be Objects Normally JavaScript numbers are primitive values created from literals: var x = 123; But numbers can also be defined as objects with the keyword new: var y = new Number(123); JavaScript Number Methods Number methods help you work with numbers. Number Methods and Properties Primitive values (like 3.14 or 2014), cannot have properties and methods (because they are not objects). But with JavaScript, methods and properties are also available to primitive values, because JavaScript treats primitive values as objects when executing methods and properties. The toString() Method The toString() method returns a number as a string. All number methods can be used on any type of numbers (literals, variables, or expressions): Example: Converting Variables to Numbers There are 3 JavaScript methods that can be used to convert variables to numbers: The Number() methodThe parseInt() methodThe parseFloat() method These methods are not number methods, but global JavaScript methods. Global JavaScript Methods JavaScript global methods can be used on all JavaScript data types. These are the most relevant methods, when working with numbers. Method Description Number() Returns a number, converted from its argument. parseFloat() Parses its argument and returns a floating point number parseInt() Parses its argument and returns an integer The Number() Method Number() can be used to convert JavaScript variables to numbers: Example: If the number cannot be converted, NaN (Not a Number) is returned. The parseInt() Method parseInt() parses a string and returns a whole number. Spaces are allowed. Only the first number is returned: Example: Number Properties Property Description MAX_VALUE Returns the largest number possible in JavaScript MIN_VALUE Returns the smallest number possible in JavaScript POSITIVE_INFINITY Represents infinity (returned on overflow) NEGATIVE_INFINITY Represents negative infinity (returned on overflow) NaN Represents a "Not-a-Number" value Example:










