Machine Learning Lab File: Submitted To: Submitted by
Machine Learning Lab File: Submitted To: Submitted by
BATCH A5
SLOT C
EXPERIMENT 1
NumPy is the fundamental package for scientific computing with Python. It contains among
other things:
MATHEMATICAL FUNCTIONS
ARCSIN, ARCOS and ARCTAN functions return the trigonometric
inverse of sin, cos, and tan of the given angle.
NUMPY.AROUND() is a function that returns the value rounded to the desired precision.
NUMPY.FLOOR() is a function returns the largest integer not greater than the input parameter.
STRING FUNCTIONS
ADD() is a function that returns element-wise string concatenation for two arrays of str or Unicode.
MULTIPLY() is a function that returns the string with multiple concatenation, element-wise.
CENTER() is a function that returns a copy of the given string with elements centered in a string of specified
length.
SPLIT() is a function that returns a list of the words in the string, using separate or delimiter.
SORTING FUNCTIONS
NUMPY.SORT() function returns a sorted copy of the input array.
NUMPY.ARGSORT() function performs an indirect sort on input array, along the given axis and using a specified
kind of sort to return the array of indices of data.
NUMPY.LEXSORT() function performs an indirect sort using a sequence of keys. The keys can be seen as a
column in a spreadsheet.
STATICTICAL FUNCTIONS
NUMPY.AMIN() and NUMPY.AMAX() functions return the minimum and the maximum from the elements in the
given array along the specified axis.
NUMPY.MEDIAN() returns the value separating the higher half of a data sample from the lower half – Median.
NUMPY.PERCENTILE() returns Percentile (or a centile) that is a measure used in statistics indicating the value
below which a given percentage of observations in a group of observations fall.
Matplotlib tries to make easy things easy and hard things possible. You can generate
plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc., with just a few
lines of code. For examples, see the sample plots and thumbnail gallery.
For simple plotting the pyplot module provides a MATLAB-like interface, particularly
when combined with IPython. For the power user, you have full control of line styles,
font properties, axes properties, etc, via an object oriented interface or via a set of
functions familiar to MATLAB users.
• BAR PLOT
# importing matplotlib module from matplotlib
import pyplot as plt
• HISTOGRAM
# importing matplotlib module from matplotlib
import pyplot as plt
• SCATTER PLOT
2. Series
dataflair_s1 = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
3. DataFrame
dataflair_df1 = pd.DataFrame(np.random.randn(8, 3),
index=dataflair_index,columns=['A', 'B', 'C'])
4. Panel
dataflair_wp1 = pd.Panel(np.random.randn(2, 5, 4), items=['Item1',
'Item2'],major_axis=pd.date_range('1/1/2000', periods=5),minor_axis=['A', 'B', 'C',
'D'])
EXPERIMENT 2
PROCEDURE:
To read data from CSV files, you must use the reader function to generate a reader object.
The reader function is developed to take each row of the file and make a list of all columns.
Then, you have to choose the column you want the variable data for.
10. data.head()
Function Description
Read a comma-separated values (csv) file into DataFrame.Also supports
read_csv optionally iterating or breaking of the file into chunks.
Preview the first 5 lines of the loaded data
head
CONCLUSION:
We read a csv file and stored it in the variable, ‘data’. We successfully displayed the first five
lines of our dataset.
INDEX
Sr. No. TOPIC DATE SIGN