MAYUKHMALI DAS
Published © GPL3+

Predictive programming and my conspiracy theory

In this write-up you will explore a world which exists but is kept hidden from us and how the government predicts future using big data.

BeginnerFull instructions provided2 hours2,523
Predictive programming and my conspiracy theory

Things used in this project

Story

Read more

Custom parts and enclosures

Raspberry pi

Schematics

Raspberry pi setup for coding

CSV file of the data for prediction

Code

Weather prediction using Linear regression

Python
Write this code in Google colab for best results , as I wrote it in Google colab
from google.colab import files
uploaded = files.upload()
import io
import pandas as pd 
import numpy as np 
import sklearn as sk 
from sklearn.linear_model import LinearRegression 
import matplotlib.pyplot as plt  
df2 = pd.read_csv(io.BytesIO(uploaded['mayukhmali_weather.csv']))
datanew = pd.read_csv("mayukhmali_weather.csv") 
datanew = datanew.drop(['Events', 'Date', 'SeaLevelPressureHighInches',  
                  'SeaLevelPressureLowInches'], axis = 1) 
datanew = datanew.replace('T', 0.0)  
datanew = datanew.replace('-', 0.0) 
datanew.to_csv('mayukhmali_final.csv') 
data = pd.read_csv("mayukhmali_final.csv") 
X = data.drop(['PrecipitationSumInches'], axis = 1)  
Y = data['PrecipitationSumInches'] 
Y = Y.values.reshape(-1, 1) 
day_index = 798
days = [i for i in range(Y.size)]  
clf = LinearRegression()  
clf.fit(X, Y) 
inp = np.array([[74], [60], [45], [67], [49], [43], [33], [45], 
                [57], [29.68], [10], [7], [2], [0], [20], [4], [31]]) 
inp = inp.reshape(1, -1) 
print('Precipitation for the input is:', clf.predict(inp)) 
print("Precipitation trend graph: ") 
plt.scatter(days, Y, color = 'b') 
plt.scatter(days[day_index], Y[day_index], color ='r') 
plt.title("Precipitation level") 
plt.xlabel("Days") 
plt.ylabel("Precipitation in inches")   
plt.show() 
x_vis = X.filter(['TempAvgF','WindAvgMPH'], axis = 1) 
print("Precipitation vs selected attributes graph: ") 
for i in range(x_vis.columns.size): 
    plt.subplot(3, 2, i + 1) 
    plt.scatter(days, x_vis[x_vis.columns.values[i][:100]], 
                                               color = 'b') 
  
    plt.scatter(days[day_index],  
                x_vis[x_vis.columns.values[i]][day_index], 
                color ='r') 
    plt.title(x_vis.columns.values[i]) 
plt.show() 

Credits

MAYUKHMALI DAS

MAYUKHMALI DAS

6 projects • 8 followers
Currently pursuing Electronics and Telecommunication engineering from Jadavpur university , India .

Comments