0% found this document useful (0 votes)
3 views2 pages

Python AI Practical: Data Visualization & Regression

The document contains Python code examples for plotting a line chart from a CSV dataset, performing a train-test split for regression, and calculating RMSE, MSE, and AMSE for given data points. It utilizes libraries such as pandas, matplotlib, and sklearn for data manipulation and visualization. Additionally, it includes a Java code snippet for calculating regression metrics.

Uploaded by

Utsav purohit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python AI Practical: Data Visualization & Regression

The document contains Python code examples for plotting a line chart from a CSV dataset, performing a train-test split for regression, and calculating RMSE, MSE, and AMSE for given data points. It utilizes libraries such as pandas, matplotlib, and sklearn for data manipulation and visualization. Additionally, it includes a Java code snippet for calculating regression metrics.

Uploaded by

Utsav purohit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AI Practical - Python

Q1. Write a python code to plot a line chart of the dataset [Link].
import pandas
import csv
import [Link] as plt
series = pandas.read_csv('[Link]', header=0, index_col=0)
[Link]()
[Link]()

Q2. Write a python program to do the train-test-split for regression where the test data
should be 20% of the dataset and the rest should be train data.
import pandas as pd
import [Link] as plt
from sklearn.model_selection import train_test_split
from [Link] import load_iris
data=pd.read_csv('[Link]')
print([Link]())
y=[Link]
x=[Link]('temp',axis=1)
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2)
print(x_train.head())
print("Shape of training")
print(x_train.shape)
x_test.head()
print("Shape of testing")
print(x_test.shape)
Q3. Write a Java code to find RMSE, MSE, AMSE for the given data points: (1,1), (2,1),
(3,2), (4,2), (5,4) and corresponding predicted values [0.6,1.29,1.99,2.69,3.4] where
regression line equation is Y' = 0.7X – 0.1

from [Link] import mean_squared_error, mean_absolute_error,


mean_absolute_percentage_error
import math
Y_true = [1,1,2,2,4]
Y_pred = [0.6,1.29,1.99,2.69,3.4]
print("MSE = ", mean_squared_error(Y_true,Y_pred))
print("RMSE = ", [Link](mean_squared_error(Y_true,Y_pred)))
print("MAE = ", mean_absolute_error(Y_true,Y_pred))
print("MAPE = ", mean_absolute_percentage_error(Y_true,Y_pred))

You might also like