Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
federhub committed Oct 1, 2019
1 parent 9dd6239 commit f848966
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import mean_squared_error as MSE
from PyGRNN import GRNN
from pyGRNN import GRNN
# Loading the diabetes dataset
diabetes = datasets.load_diabetes()
X = diabetes.data
Expand All @@ -38,7 +38,7 @@ X_train, X_test, y_train, y_test = train_test_split(preprocessing.minmax_scale(X
test_size=0.25)

# Example 1: use Isotropic GRNN with a Grid Search Cross validation to select the optimal bandwidth
IGRNN = GRNN.GRNN()
IGRNN = GRNN()
params_IGRNN = {'kernel':["RBF"],
'sigma' : list(np.arange(0.1, 4, 0.01)),
'calibration' : ['None']
Expand All @@ -55,7 +55,7 @@ y_pred = best_model.predict(X_test)
mse_IGRNN = MSE(y_test, y_pred)

# Example 2: use Anisotropic GRNN with Limited-Memory BFGS algorithm to select the optimal bandwidths
AGRNN = GRNN.GRNN(calibration="gradient_search")
AGRNN = GRNN(calibration="gradient_search")
AGRNN.fit(X_train, y_train.ravel())
sigma=AGRNN.sigma
y_pred = AGRNN.predict(X_test)
Expand All @@ -65,22 +65,25 @@ mse_AGRNN = MSE(y_test, y_pred)
The package can also be used to perform feature selection:
```sh
from PyGRNN import feature_selection as FS
from pyGRNN import feature_selection as FS
# Loading the diabetes dataset
diabetes = datasets.load_diabetes()
X = diabetes.data
y = diabetes.target
featnames = diabetes.feature_names

# Example 1: use Isotropic Selector to explore data dependencies in the input
# space by analyzing the relatedness between features
IsotropicSelector = FS.Isotropic_selector(bandwidth = 'rule-of-thumb')
IsotropicSelector.relatidness(X, feature_names = featnames)
IsotropicSelector.plot_(feature_names = featnames)

# Example 2: use Isotropic Selector to perform an exhaustive search; a rule-of-thumb
# is used to select the optimal bandwidth for each subset of features
IsotropicSelector = FS.Isotropic_selector(bandwidth = 'rule-of-thumb')
IsotropicSelector.es(X, y.ravel(), feature_names=featnames)
# Example 2: use Isotropic Selector to perform a complete analysis of the input

# Example 3: use Isotropic Selector to perform a complete analysis of the input
# space, recongising relevant, redundant, irrelevant features
IsotropicSelector = FS.Isotropic_selector(bandwidth = 'rule-of-thumb')
IsotropicSelector.feat_selection(X, y.ravel(), feature_names=featnames, strategy ='es')
Expand Down

0 comments on commit f848966

Please sign in to comment.