<jupyter_start><jupyter_text>0. Import<jupyter_code>import pandas as pd
import numpy as np

from sklearn import preprocessing

import matplotlib.pyplot as plt
import matplotlib.pyplot as plt2<jupyter_output><empty_output><jupyter_text>1. Adeline algorithm<jupyter_code>class AdalineGD(object):
    
    def __init__(self, rychlost_ucenia=0.01,pocet_iteracii = 50):

        self.rychlost_ucenia = rychlost_ucenia
        self.pocet_iteracii = pocet_iteracii
        
    def fit(self,X,y):
        
        self.w_ = np.zeros(1+X.shape[1])
        self.cost_=[]
        
        for i in range (self.pocet_iteracii):
            output = self.net_input(X)       
            errors = (y-output)
            self.w_[1:] += self.rychlost_ucenia * X.T.dot(errors)
            self.w_[0] += self.rychlost_ucenia * errors.sum()
            cost = (errors ** 2).sum()/2.0
            self.cost_.append(cost)
        return self
    
    def net_input(self,X):
        return np.dot(X,self.w_[1:])+self.w_[0]
    
    def linearna_aktivacia(self,X):
        return self.net_input(X)
    
    
    def predikcia(self,X):
        return np.where(self.linearna_aktivacia(X)>=0.0,1,-1)
# dataframe
data = pd.read_csv('/content/drive/MyDrive/Škola/NS/cvicenie_4/kosatec_data.csv', header = None)
data
vstup = data.iloc[0:100, [0,2]].values
y = np.where((data.iloc[0:100,4]) == 'kosatec_sibirsky',-1,1)
y
x = preprocessing.scale(vstup)
plt.hist(vstup)
plt.show()

plt2.hist(x)
plt2.show()
adaline = AdalineGD()
adaline.fit(x,y)
print(adaline.cost_)
plt.plot(adaline.cost_)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13341493268053856, 'fraction_numerical': 0.022643818849449205, 'mean_word_length': 2.6990950226244346, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '330606', 'license': 'MIT', 'n_tokens_mistral': 691, 'n_tokens_neox': 644, 'n_words': 94, 'path': 'cvicenie_4/Untitled0.ipynb', 'repo_name': 'Ludovit-Laca/NS-cvicenia', 'size': '1634'}