[scikit-learn] How to apply LR in gridded (for multiple location datasets) time series datasets?

Vishal Singh shalu.ashu50 at gmail.com
Wed Mar 28 22:50:04 EDT 2018


Hello,

This code is written for multivariate (multiple independent variables
x1,x2,x3..xn and a dependent variable y) time series analysis using
logistic regression (correlation and prediction).

#Import Libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

#Import Dataset
dataset = pd.read_csv(‘precipitation.csv’)
x = dataset.iloc[:,[2,3]].values
y =dataset.iloc[:,4].values

#Split Training Set and Testing Set
from sklearn.cross_validation import train_test_split
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.25)

#Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X=StandardScaler()
x_train=sc_X.fit_transform(x_train)
x_test=sc_X.transform(x_test)

#Training the Logistic Model
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression()
classifier.fit(x_train, y_train)

#Predicting the Test Set Result
y_pred = classifier.predict(x_test)


This code is based on one point location (one lat/long) datasets. Suppose,
I am having gridded datasets (which has many points/locations, lat/long,
varying in space and time) then How I will implement this code. I am not
expertise in python. If somebody can help me in this? If somebody can give
me an example or idea so I can implement this code as per my requirement.

Thank you in advance.

Vishu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20180329/2b455273/attachment.html>


More information about the scikit-learn mailing list