Posts

rock paper scisor game

for the exact code: https://github.com/animeesh/game-rock-paper-scissor code  random lib is used to get the random value  import random #input_list = ["Rock", "Paper", "Scissor"] while True:     input_user = input("Select the input: ")     print (input_user)      possible_action=["rock","paper","scissor"]     computer_action=random.choice(possible_action)          print(f"\nyou chose :{input_user},computer chose :{computer_action}.\n")     #hear starts the real technique     if input_user ==computer_action:         print(f"both player selected {input_user}.hence its a tie!")     elif input_user== "rock":         if computer_action=="scissor":             print("rock smashes scissor! you win")         else:             print("paper covers the rock! you lose") ...

using your age and duration of workout finding how much calories you burned!

dataset: https://www.kaggle.com/fmendes/fmendesdat263xdemos/download ......................................................................................................................................................... import pandas as  pd import matplotlib.pyplot as plt import numpy as np import pickle  from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression df_calories=pd.read_csv("ineuron/calories.csv") df_exercise=pd.read_csv("ineuron/exercise.csv") data=df_exercise.merge(df_calories, on='User_ID') #print(data.head()) #[:,0:-1] all rows and all expect last column (independent  variable) also feature column #data_x = data.iloc[:,:-1].values data_x= df.loc[:,[ 'Weight','Age','Duration']] data_y=df.iloc[:,-1] #[:,-1]all rows and only last column (dependent variable) also target column #data_y = data.iloc[:,-1].values x_train,x_test,y_train,y_test = train_test_split(data_x,data_y,test...

Logestic Regression

In [18]: import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split df = pd . read_csv ( "framingham_heart_disease.csv" ) df . head () Out[18]: male age education currentSmoker cigsPerDay BPMeds prevalentStroke prevalentHyp diabetes totChol sysBP diaBP BMI heartRate glucose TenYearCHD 0 1 39 4.0 0 0.0 0.0 0 0 0 195.0 106.0 70.0 26.97 80.0 77.0 0 1 0 46 2.0 0 0.0 0.0 0 0 0 250.0 121.0 81.0 28.73 95.0 76.0 0 2 1 48 1.0 1 20.0 0.0 0 0 0 245.0 127.5 80.0 25.34 75.0 70.0 0 3 0 61 3.0 1 30.0 0.0 0 1 0 225.0 150.0 95.0 28.58 65.0 103.0 1 4 0 46 3.0 1 23.0 0.0 0 0 0 285.0 130.0 84.0 23.10 85.0 85.0 0 In [5]: df . describe () Out[5]: male age education currentSmoker cigsPerDay BPMeds prevalentStroke prevalentHyp diabetes totChol sysBP diaBP BMI heartRate glucose TenYearCHD count 4238.000000 4238.000000 4133.000000 4238.000000 4209.000000 4185.000000 4238.000000 4238.000000 4238.000000 4188.000000 423...

Project 3:Movie Recomendation using python

Image
Basicly there are two types of recomendation system  content based filtering colaborative filtering you can google out this and get to know about it i am here basicly to put down the projects and code so all what we do is predict the movie for the  customer using the angular distance (we can calculate using two method ie. euclidian diatance and angular distance) according to the problem you have to decide which one will be suitable for the project i think this much description is ell and good lets cary on with the codes so are you ready? this is the basic code to get the matrix of the text realation ,i mean the realtion between the words in  two sentence. from  sklearn.feature_extraction.text  import  CountVectorizer from  sklearn.metrics.pairwise  import  cosine_similarity text=[ "London Paris London" , "Paris Paris London" ] cv=CountVectorizer() cv_matrix=cv.fit_transform(text) #print(cv_matrix.toarray()) similirity_scor...

Project 2: pdf extractor using python

Image
let us prepare a project of few codes to extract the whole pdf    import pip install PyPDF2 code: ............................................................................................................................................. from PyPDF2 import PdfFileReader #read a pdf file ie. by rb mode file=open("Handbook.pdf",'rb') #reader ia s variable use to read file  reader=PdfFileReader(file) #lets get the info of the pdf document print("document info:",reader.getDocumentInfo()) print() #getNumPages() this comand can get you page numbers of pdf print("number pf pages are:",reader.getNumPages()) #lets take variable "pages" to take comand over get number of pages pages=reader.getNumPages() for i in range(0,pages):     print("page number=",i+1)     pageObj = reader.getPage(i)     print(pageObj.extractText()) print() print(reader.getDocumentInfo().creator) file.close() ............................................................

k nearest neighbors with well defined k value

Image
 so let us understand how we can chooose the perfect k for our model  from the last model i had prepared a function def regression(model):     x_train,x_test,y_train,y_test= train_test_split(x,y,test_size=0.2)     reg_all=model     reg_all.fit(x_train,y_train)     y_predict=reg_all.predict(x_test)     rmse_value=np.sqrt(mean_squared_error(y_test,y_predict))     print("rms error={}".format(rmse_value)) i have prepared cross value squared to get the mean of rmse where k=3 denote the mean of three iterated value of rmse Lasso is a way to conterect over fitting (we can also use ridge) to check. from sklearn.model_selection import cross_val_score from sklearn.linear_model import Lasso def regression_cv(model,k=3):     scores=cross_val_score(model,x,y,scoring='neg_mean_squared_error',cv=k)     rmse=np.sqrt(-scores)     print('reg rmse:',rmse)     print('reg mean:',rmse.mean()) importi...

Packt publication linear regression

code: ''' step1: import all the required packages step2: read the csv file and deop the null value step3: declare x & y ie. independent and target vallue step4:split train and test values from the data set step5:call Linear regression and fit x & y train value step6: predict y for our x value from test value and find rmse value rmse value can be usefull to undersand the effeciency of our model ''' import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error from sklearn.model_selection import train_test_split In [20]: df_housing . head () Out[20]: CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX PTRATIO B LSTAT MEDV 0 0.00632 18.0 2.31 0 0.538 6.575 65.2 4.0900 1 296 35.3 396.9 4.98 24.00 1 0.02731 0.0 7.07 0 0.469 6.421 78.9 4.9671 2 242 17.8 396.9 9.14 21.60 2 0.02731 0.0 7.07 0 0.469 6.421 78.9 4.9671 2 242 17.8 396.9 9.14 21.61 3 0.02731 0.0 7.07 0 0.4...