# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# %matplotlib inline

jagan = pd.read_csv('C:/Users/akano/Downloads\Machine-Learning-Using-Scikit-learn-and-other-libraries-master (2)/Machine-Learning-Using-Scikit-learn-and-other-libraries-master/1.Regression/data_jaganAnalysis.csv')
tanco = pd.read_csv('C:/Users/akano/Downloads\Machine-Learning-Using-Scikit-learn-and-other-libraries-master (2)/Machine-Learning-Using-Scikit-learn-and-other-libraries-master/1.Regression/data_tanco1.csv')
lemon = pd.read_csv('C:/Users/akano/Downloads\Machine-Learning-Using-Scikit-learn-and-other-libraries-master (2)/Machine-Learning-Using-Scikit-learn-and-other-libraries-master/1.Regression/data_lemonAnalysis.csv')
tangelo = pd.read_csv('C:/Users/akano/Downloads\Machine-Learning-Using-Scikit-learn-and-other-libraries-master (2)/Machine-Learning-Using-Scikit-learn-and-other-libraries-master/1.Regression/data_tangeloAnalysis.csv')


jagan.head()

tanco.head()

lemon.head()

tangelo.head()

jagan.describe()

tanco.describe()

lemon.describe()

tangelo.describe()

correlation_jagan = jagan.corr()
correlation_tanco = tanco.corr()
correlation_lemon = lemon.corr()
correlation_tangelo = tangelo.corr()

export_correlation_jagan = correlation_jagan
export_correlation_jagan.to_csv("jagan result correlation")

correlation_tanco

correlation_lemon

correlation_tangelo

sns.heatmap(correlation_jagan)

sns.heatmap(correlation_tanco)

sns.heatmap(correlation_lemon)

sns.heatmap(correlation_tangelo)

sns.boxplot(data = jagan)

sns.boxplot(data = tanco)

sns.boxplot(data = lemon)

sns.boxplot(data = tangelo)

sns.boxplot(data = correlation_jagan)

sns.boxplot(data = correlation_tanco)

sns.boxplot(data = correlation_lemon)

sns.boxplot(data = correlation_tangelo)



jagan.columns

## Anova and p-value test
import scipy.stats as stats
from scipy.stats import ttest_ind
from scipy.stats import f_oneway

length = jagan['Length (mm)']
width = jagan['Width (mm)']
thickness = jagan['Thickness (mm)']
stats.f_oneway(length, width, thickness)


x = tanco[['Length (mm)', 'Width (mm)', 'Thickness (mm)',
       'Volume(mm3)']]
y = tanco['Mass (g)']



from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.1, random_state = 101)

# +

x_train
# -

#fitting simple linear regression to the training set
from sklearn.linear_model import LinearRegression
regressor=LinearRegression()

#fit the regressor
regressor.fit(x_train,y_train)

# +
#y_train

# +
#y_test
# -

#predictig test results
y_pred = regressor.predict(x_test)

from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
from sklearn.metrics import mean_squared_error

mean_absolute_error(y_test, y_pred)

mean_squared_error(y_test, y_pred)

r2_score(y_test, y_pred)

from sklearn import linear_model
from sklearn. model_selection import cross_val_score
lasso = linear_model.Lasso()
print(cross_val_score(lasso, x, y, cv=5))

jagan.columns

X = jagan[['Length (mm)', 'Width (mm)', 'Thickness (mm)', 'Volume(mm3)']]
Y = jagan['Mass (g)']

# +
from sklearn.model_selection import train_test_split
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.1, random_state = 101, shuffle = True)

#fitting simple linear regression to the training set
from sklearn.linear_model import LinearRegression
regressor=LinearRegression()

#fit the regressor
regressor.fit(X_train,Y_train)

#predictig test results
y_pred = regressor.predict(X_test)

from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
from sklearn.metrics import mean_squared_error
# -

mean_absolute_error(Y_test, y_pred)

mean_squared_error(Y_test, y_pred)

r2_score(Y_test, y_pred)

from sklearn import linear_model
from sklearn. model_selection import cross_val_score
lasso = linear_model.Lasso()
print(cross_val_score(lasso, x, y, cv=5))



X = lemon[['Length (mm)', 'Width (mm)', 'Thickness (mm)', 'Volume (mm3)']]
Y = lemon['Mass (g)']

# +
from sklearn.model_selection import train_test_split
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.1, random_state = 101, shuffle = True)

#fitting simple linear regression to the training set
from sklearn.linear_model import LinearRegression
regressor=LinearRegression()

#fit the regressor
regressor.fit(X_train,Y_train)

#predictig test results
y_pred = regressor.predict(X_test)

from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
from sklearn.metrics import mean_squared_error
# -

print(mean_absolute_error(Y_test, y_pred),mean_squared_error(Y_test, y_pred),r2_score(Y_test, y_pred) )

from sklearn import linear_model
from sklearn. model_selection import cross_val_score
lasso = linear_model.Lasso()
print(cross_val_score(lasso, x, y, cv=5))





X1 = lemon[['Length (mm)', 'Width (mm)', 'Thickness (mm)', 'Volume (mm3)']]
Y1 = lemon['Mass (g)']

# +
from sklearn.model_selection import train_test_split
X1_train, X1_test, Y1_train, Y1_test = train_test_split(X1, Y1, test_size = 0.1, random_state = 101, shuffle = True)

#fitting simple linear regression to the training set
from sklearn.linear_model import LinearRegression
regressor=LinearRegression()

#fit the regressor
regressor.fit(X1_train,Y1_train)

#predictig test results
y_pred = regressor.predict(X1_test)

from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
from sklearn.metrics import mean_squared_error
# -

print(mean_absolute_error(Y1_test, y_pred),mean_squared_error(Y1_test, y_pred),r2_score(Y1_test, y_pred) )

from sklearn import linear_model
from sklearn. model_selection import cross_val_score
lasso = linear_model.Lasso()
print(cross_val_score(lasso, x, y, cv=3))

parameter = tangelo[['Length (mm)', 'Width (mm)', 'Thickness (mm)', 'Volume (mm3)']]

X = parameter

X.shape

Y.shape

X = np.arange(0, len(X_train), 1)

X = parameter
Y = tangelo['Mass (g)']

# +
from sklearn.model_selection import train_test_split
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.1, random_state = 101, shuffle = True)

#fitting simple linear regression to the training set
from sklearn.linear_model import LinearRegression
regressor=LinearRegression()

#fit the regressor
regressor.fit(X_train,Y_train)

#predictig test results
y_pred = regressor.predict(X_test)

from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
from sklearn.metrics import mean_squared_error
# -

print(mean_absolute_error(Y_test, y_pred),mean_squared_error(Y_test, y_pred),r2_score(Y_test, y_pred) )

X_train = np.arange(0, len(X_train), 1)

X_train.shape





StarcoderdataJupyterScriptsDedupFiltered