import numpy
import csv_output
from sklearn import lda, svm
from skimage import feature, color, exposure
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, RobustScaler
from sklearn.decomposition import PCA
from sklearn import random_projection
from sklearn.ensemble import RandomForestClassifier
from sklearn import feature_selection

#preloading
print("loading data...")
size = 100
images, labels, classes = loader.loadTrainingImagesPoleNumbersAndClasses()
amount = len(images)

print("resizing...")
resized = util.loading_map(lambda x: operations.cropAndResize(x, 0, size),
                           images)
print("grayscaling...")
grayscaled = util.loading_map(color.rgb2gray, resized)

n_folds = 10

model = Pipeline([("standard scaler", StandardScaler()),
                  ("logistic regression",
                   LogisticRegression(solver='lbfgs',
                                      multi_class='multinomial'))])
Example #2
0
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 28 15:43:03 2015

@author: Rian
"""

from distance_model import DistanceModel
import data_loading
import util
import image_operations as operations
import feature_extraction as extraction
from skimage import feature, color, exposure
import feature_validation as validation

training_images, training_labels, training_classes = data_loading.loadTrainingImagesPoleNumbersAndClasses(
)
size = 100

print("resizing...")
resized = util.loading_map(lambda x: operations.cropAndResize(x, 0, size),
                           training_images)
print("hsv...")
hsv = util.loading_map(color.rgb2hsv, resized)
print("grayscaling...")
grayscaled = util.loading_map(color.rgb2gray, resized)

print("colors")
colors = util.loading_map(
    lambda x: extraction.split_image_features(
        extraction.calculateColorFeatures, 7, x), hsv)