mglearn引发的感想

mglearn,一个机器学习的模块组件,本以为和其它的组件一样,pip安装一波就行了,实际上,行是行了,额,为啥用起来会有警告呢🐸,不明觉厉,但是确实在Jupyter里面不影响使用,暂且不管啥问题先用着

主要的是,昨天装了一个Anaconda,实际上用起来感觉还行,但为啥总感觉启动的时候有点不稳定🤣

conda install mglearn
!pip install mglearn
!pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mglearn 
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import matplotlib.pyplot as plt


# In[2]:


import mglearn


# In[3]:


X,y = mglearn.datasets.make_wave(n_samples = 40)


# In[4]:


plt.plot(X,y,'o')

plt.ylim(-3,3)

plt.xlabel('Feature')

plt.ylabel('Target')


# In[5]:


X,y = mglearn.datasets.make_forge()


# In[6]:


mglearn.discrete_scatter(X[:,0],X[:,1],y)


# In[7]:


mglearn.plots.plot_knn_classification(n_neighbors = 1)


# In[8]:


from sklearn.model_selection import train_test_split


# In[9]:


X,y = mglearn.datasets.make_forge()


# In[10]:


X_train,X_test,y_train,y_test = train_test_split(X,y,random_state = 0)


# In[11]:


print ('{}'.format(X_train.shape))


# In[12]:


from sklearn.neighbors import KNeighborsClassifier


# In[13]:


clf = KNeighborsClassifier(n_neighbors = 3)


# In[14]:


clf.fit(X_train,y_train)


# In[15]:


print ('{}'.format(clf.score(X_test,y_test)))


# In[16]:


for num in range(1,3):
    clf = KNeighborsClassifier(n_neighbors = num)
    clf.fit(X_train,y_train)
    print ('{}'.format(clf.score(X_test,y_test)))
    print ('\n')


# In[17]:


X,y = mglearn.datasets.make_wave()


# In[18]:


mglearn.plots.plot_knn_regression(n_neighbors = 1)


# In[19]:


mglearn.plots.plot_knn_regression(n_neighbors = 1)


# In[20]:


mglearn.plots.plot_knn_regression(n_neighbors = 3)


# In[ ]:


uC代码迁移有待了解一下,毕竟不能完全基于高阶操作系统甚至是高性能CPUGPU以及其它的加成等,uC才是王道

发表评论

您的电子邮箱地址不会被公开。

召唤伊斯特瓦尔