Python programming blog

Sunday, June 13, 2021

Weather prediction using python Machine learning project ( Naïve Bayes )

 This blog contains the code for Weather prediction machine learning project using python Programming




STEP1: Installing Dependencies

*pip install pandas
*pip install sklearn

STEP2: Importing the libraries

#NaiveBayes project (Weather Prediction)
#Required Modules
import pandas as pd
from sklearn.preprocessing import LabelEncoder
from sklearn.naive_bayes import GaussianNB

STEP3:Reading the CSV

df = pd.read_csv("new_dataset.csv")
df

STEP4:Encoding the strings into numbers:

Numerics=LabelEncoder()


STEP5:Dropping the target column

inputs=df.drop('Play',axis='columns')
target=df['Play']
target

STEP6:Creating new dataframe

inputs['outlook_n']= outlook_at.fit_transform(inputs['Outlook'])
inputs['Temp_n']= outlook_at.fit_transform(inputs['Temp'])
inputs['Hum_n']= outlook_at.fit_transform(inputs['Humidity'])
inputs['win_n']= outlook_at.fit_transform(inputs['Windy'])
inputs


STEP7: Dropping the string columns

inputs_n=inputs.drop(['Outlook','Temp','Humidity','Windy'],axis='columns')
inputs_n

STEP8: Applying GaussianNB

classifier = GaussianNB()
classifier.fit(inputs_n,target)

STEP9: Prediction

classifier.predict([[0,0,0,1]])


Video explanation:




                                                               

Fullcode:Github


Thanks for reading the article❤




7 comments:

  1. Where is that csv file, please upload

    ReplyDelete
    Replies
    1. explain step 3 how to import data ,can you share dataset

      Delete
  2. how to visualize the data on a graph

    ReplyDelete
  3. Can you provide a base paper for weather prediction

    ReplyDelete
  4. outlook_at is not defined. how can we use that before defining??

    ReplyDelete
    Replies
    1. It must be 'numerics' in the place of 'outlook_at'

      Delete