scikit学习平均感知器分类器(scikit learn averaged perceptron classifier)
我是机器学习的新学习者,我想做一个只有少数属性的2级分类。 我通过在线研究得知,两类平均感知器算法适用于线性模型的两类分类。
但是,我一直在阅读Scikit-learn的文档,如果Scikit-learn提供了一个平均的感知器算法,我有点困惑。
我想知道
sklearn.linear_model.Perceptron
类是否可以通过正确设置参数来实现为两级平均感知器算法。非常感谢你的帮助。
I am a new learner to machine learning and I want to do a 2-class classification with only a few attributes. I have learned by researching online that two-class averaged perceptron algorithm is good for two-class classification with a linear model.
However, I have been reading through the documentation of Scikit-learn, and I am a bit confused if Scikit-learn is providing a averaged perceptron algorithm.
I wonder if the
sklearn.linear_model.Perceptron
class can be implemented as the two-class averaged perceptron algorithm by setting up the parameters correctly.I appreciate it very much for your kind help.
原文:https://stackoverflow.com/questions/47665910
满意答案
您只需执行以下操作:准备好您的xml,如下所示:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toLeftOf="@+id/addItem" android:hint="Add a new item to List View" /> <Button android:id="@+id/addItem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="Add" /> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/editText" > </ListView> </RelativeLayout>
活动如下所示:
public class MainActivity extends Activity { EditText editText; Button addButton; ListView listView; ArrayList<String> listItems; ArrayAdapter<String> adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText = (EditText) findViewById(R.id.editText); addButton = (Button) findViewById(R.id.addItem); listView = (ListView) findViewById(R.id.listView); listItems = new ArrayList<String>(); listItems.add("First Item - added on Activity Create"); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems); listView.setAdapter(adapter); addButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { listItems.add(editText.getText().toString()); adapter.notifyDataSetChanged(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { Toast.makeText(MainActivity.this, "Clicked", Toast.LENGTH_LONG) .show(); } }); } }
You just do the following : Prepare your xml like this :
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toLeftOf="@+id/addItem" android:hint="Add a new item to List View" /> <Button android:id="@+id/addItem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="Add" /> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/editText" > </ListView> </RelativeLayout>
Activity looks like following :
public class MainActivity extends Activity { EditText editText; Button addButton; ListView listView; ArrayList<String> listItems; ArrayAdapter<String> adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText = (EditText) findViewById(R.id.editText); addButton = (Button) findViewById(R.id.addItem); listView = (ListView) findViewById(R.id.listView); listItems = new ArrayList<String>(); listItems.add("First Item - added on Activity Create"); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems); listView.setAdapter(adapter); addButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { listItems.add(editText.getText().toString()); adapter.notifyDataSetChanged(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { Toast.makeText(MainActivity.this, "Clicked", Toast.LENGTH_LONG) .show(); } }); } }
相关问答
更多添加按钮到自定义ListView适配器(Adding button to custom ListView Adapter)
在将按钮添加到xml文件时,使用自定义适配器的ListView也会被覆盖(ListView using custom Adapter is overwritten when also adding buttons to the xml file)
按钮上的自定义适配器刷新ListView单击(Refreshing ListView from Custom Adapter on Button Click)
如何在适配器的listview项目中单击图像按钮后刷新列表视图?(How to refresh listview after click imagebutton in listview item from adapter?)
ListView适配器行为奇怪(ListView adapter behaves strangely)
无法单击Listview适配器的按钮(Listview adapter's button can not be clicked)
ListView适配器表现得很奇怪。(ListView Adapter behaving weirdly. Unrelated buttons in the ListView get clicked after i click on a button in the same ListView)
如何使用适配器在按钮单击上添加ListView项目(How to add ListView items on button click using adapter)
在按钮的onclicklistener中设置listview的适配器后,Listview的项目变灰了......?(Listview's items grayed out after setting the listview's adapter in a button's onclicklistener…?)
使用SimpleCursorAdapter更新ListView(无需重新初始化适配器)(Updating ListView using SimpleCursorAdapter ( without re-initializing adapter ))
相关文章
更多learn C on the mac 读后笔记
10 Programming Languages You Should Learn Right Now
Solr学习笔记之5、Component(组件)与Handler(处理器)学习
JAVA设计模式学习12——装饰器模式
Mangos模拟器综合资源贴
Solr学习笔记之2、集成IK中文分词器
✈工欲善其事,必先利其器✔™
路由器基础知识点汇总学习
机器学习资源大全【转】
Hadoop中的排序器/组合器/合并器
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!