Skip to content
Snippets Groups Projects
Commit 2ca73268 authored by GILSON Matthieu's avatar GILSON Matthieu
Browse files

Upload New File

parent e9e9c186
No related merge requests found
%% Cell type:code id:349c8bc6-1a18-4fe2-869c-5581df684b1c tags:
``` python
import numpy as np
import pandas as pd
from sktime.datasets import load_from_arff_to_dataframe
import matplotlib.pyplot as plt
```
%% Cell type:code id:47021efb-21dc-4ed2-8375-de1355344a16 tags:
``` python
#dataset = 'FordA'
dataset = 'Cricket'
#dataset = 'Phoneme'
X_train, y_train = load_from_arff_to_dataframe('{0}/{0}_TRAIN.arff'.format(dataset))
X_test, y_test = load_from_arff_to_dataframe('{0}/{0}_TEST.arff'.format(dataset))
```
%% Cell type:code id:ea059511-2df8-447e-a064-ab23a2d4b6f5 tags:
``` python
plt.figure()
plt.plot(X_train.iloc[0,0])
plt.xlabel('time')
plt.ylabel('a.u.')
plt.title('example trace')
plt.show()
```
%% Output
%% Cell type:code id:5f1297d0-e59b-46ef-bd1c-2c974b7b2fbd tags:
``` python
X_mean_train = pd.DataFrame(columns=['mean'])
for i in range(X_train.shape[0]):
X_mean_train = pd.concat((X_mean_train,
pd.DataFrame({'mean': X_train.iloc[i,0].mean()}, index=[0])), ignore_index=True)
X_mean_test = pd.DataFrame(columns=['mean'])
for i in range(X_test.shape[0]):
X_mean_test = pd.concat((X_mean_test,
pd.DataFrame({'mean': X_test.iloc[i,0].mean()}, index=[0])), ignore_index=True)
```
%% Cell type:code id:656566da-5f08-414a-90d5-274ed35f0b73 tags:
``` python
print(X_mean_train.shape, y_train.shape)
print(np.unique(y_train))
```
%% Output
(108, 1) (108,)
['1.0' '10.0' '11.0' '12.0' '2.0' '3.0' '4.0' '5.0' '6.0' '7.0' '8.0'
'9.0']
%% Cell type:code id:ad8ea31a-e7af-45a7-b6f0-091b51d82db3 tags:
``` python
from sklearn.linear_model import LogisticRegression
lr = LogisticRegression()
lr.fit(X_mean_train, y_train)
print(lr.score(X_mean_test, y_test))
```
%% Output
0.08333333333333333
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment