我可以使用textblob来预测Likert量表结果吗?

时间:2016-02-26 08:48:36

标签: python scikit-learn nltk textblob

我有大约300名参与者,他们每次产生45个短片(虽然许多参与者写了相同的情况),并评估了他们在这种情况下会感到焦虑的程度(1-5个缩写)。

示例数据:

#Import libraries
from textblob.classifiers import NaiveBayesClassifier

#Train the NBC with training data
cl = NaiveBayesClassifier(train)

#Examine Training Accuracy
cl.accuracy(train)

#Generates a list of informative features
cl.show_informative_features(50)

我想知道我是否可以在python中使用textblob来确定是否有任何常见的单词会导致某人在这个单项上的得分更高。

到目前为止我所拥有的是简单的类别分类系统。

String text;
String pres_doctor;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    main = (LinearLayout) findViewById(R.id.main);
    txt_qty =new TextView(this);

    addNewRow();
    Button btnadd = (Button) findViewById(R.id.add_new_row);
    btnadd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            addNewRow();
        }
    });
    Button btnSubmit=(Button)findViewById(R.id.btn_submit);
    btnSubmit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {






        }
    });

}

private LinearLayout CreateSpinner() {

    final LinearLayout rowLayout = new LinearLayout(this.getApplicationContext());
    final TextView serialNumberText = new TextView(this);
    serialNumberText.setText(String.valueOf(i++));
    ItemSpinner = new Spinner(this);
    ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_spinner_item, itemlist);
    adapter1.setDropDownViewResource(android.R.layout.select_dialog_item);
    ItemSpinner.setAdapter(adapter1);

    text = ItemSpinner.getSelectedItem().toString();

    final EditText ItemQuantity = new EditText(this);
    int x = 0;
    ItemQuantity.setText("" + x);
    ItemQuantity.setTextColor(Color.GREEN);
    ItemQuantity.setInputType(InputType.TYPE_CLASS_NUMBER);
    ItemQuantity.setGravity(Gravity.CENTER);

    final EditText ItemPrice = new EditText(this);
    ItemPrice.setText("0");
    ItemPrice.setTextColor(Color.GREEN);
    final EditText RowTotal = new EditText(this);
    RowTotal.setText("0");
    RowTotal.setTextColor(Color.BLUE);


    AdapterView.OnItemSelectedListener onItemSelectedListener1 =
            new AdapterView.OnItemSelectedListener() {

                @Override
                public void onItemSelected(AdapterView<?> parent, View view,
                                           int position, long id) {

                    pres_doctor = ItemSpinner.getSelectedItem().toString();
                    RowTotal.setText("0");
                    String val = String.valueOf(itemrate[position]);
                    ItemPrice.setText(val);
                    ItemPrice.setGravity(Gravity.CENTER);
                    int Quantity = Integer.parseInt(ItemQuantity.getText().toString());
                    int Price = Integer.parseInt(ItemPrice.getText().toString());
                    RowTotal.setText(String.valueOf(Quantity * Price));
                    txt_nettotal = (TextView) findViewById(R.id.textView);
                    txt_nettotal.setTextColor(Color.BLUE);
                    int value = 0;
                    for (EditText editText : row_list) {
                        int list = Integer.parseInt(editText.getText().toString());
                        value += list;
                    }
                    txt_nettotal.setText(String.valueOf(value));

                }


                @Override
                public void onNothingSelected(AdapterView<?> parent) {
                }

            };
    ItemSpinner.setOnItemSelectedListener(onItemSelectedListener1);


    btnMinus = new Button(this);
    btnMinus.setText("-");
    btnMinus.setTextColor(Color.BLACK);
    btnMinus.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            int oldValue = Integer.parseInt(ItemQuantity.getText().toString());
            int newValue = 0;
            if (oldValue > 0) newValue = oldValue - 1;
            ItemQuantity.setText(String.valueOf(newValue));
            ItemQuantity.setGravity(Gravity.CENTER);
            final TextView txt_nettotal = (TextView) findViewById(R.id.textView);
            txt_nettotal.setTextColor(Color.BLUE);
            int value = 0;
            for (EditText editText : row_list) {
                int m = Integer.parseInt(editText.getText().toString());
                value += m;
            }
            txt_nettotal.setText(String.valueOf(value));

        }
    });

    btnPlus = new Button(this);
    btnPlus.setText("+");
    btnMinus.setTextColor(Color.BLACK);
    btnPlus.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            int oldValue = Integer.parseInt(ItemQuantity.getText().toString());
            ItemQuantity.setText(String.valueOf(oldValue + 1));
            ItemQuantity.setGravity(Gravity.CENTER);
            final TextView txt_nettotal = (TextView) findViewById(R.id.textView);
            txt_nettotal.setTextColor(Color.BLUE);
            int value = 0;
            for (EditText editText : row_list) {
                int m = Integer.parseInt(editText.getText().toString());
                value += m;

            }
            txt_nettotal.setText(String.valueOf(value));

        }
    });
    ItemQuantity.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            try {
                int Quantity = Integer.parseInt(ItemQuantity.getText().toString());
                int Price = Integer.parseInt(ItemPrice.getText().toString());
                RowTotal.setText(String.valueOf(Quantity * Price));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
    row_list.add(RowTotal);
    qty_list.add(ItemQuantity);
    rowLayout.addView(serialNumberText);
    rowLayout.addView(ItemSpinner);
    rowLayout.addView(btnMinus);
    rowLayout.addView(ItemQuantity);
    rowLayout.addView(btnPlus);
    rowLayout.addView(ItemPrice);
    rowLayout.addView(RowTotal);

    return rowLayout;
}

private void addNewRow() {
    GridLayout gridLayout = new GridLayout(this);

    gridLayout.addView(CreateSpinner());

    main.addView(gridLayout);
}
  1. 我怎么能得到这个来考虑这是间隔(或某些人会说序数)数据而不是名义数据? (例如,包含单词&#34;陌生人&#34;导致焦虑增加X%。)

  2. 如果这是不可能的(或者即使它不是),有没有办法打印在每个类似的类别中标记给定情况的百分比概率? (例如,1 = 0.08; 2 = 0.23,3 = 0.44,4 = 0.19,5 = 0.06)

  3. 非常感谢任何建议。

0 个答案:

没有答案