IT Learning

実践形式でITのお勉強

Changing OpenJDK8 to OpenJDK11 on CentOS7

2022/11/07   -CentOS

Description I changed java environment from OpenJDK8 to OpenJDK11 and wrote the procedure to do it in here. The reason I changed OpenJDK version is simply I think OpenJDK8 is a little old and OpenJDK11 is better for me in the future. Step1 : Checking the existing java version java -version openjdk version “1.8.0_262”OpenJDK Runtime Environment (build 1.8.0_262-b10)OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)   Step2 : Removing existing OpenJDK8 We can remove the existing OpenJDK8 environment with “yum remove” command. It’s good way to use wild-card to clean it fully. sudo yum -y remove java-1.8.0-openjdk* Checking the version …

【Python】How to datetime aggregation by pandas

2022/11/05   -Python

Description Pandas is powerful method to deal with the data and here we are showing how to aggregate by this method with some examples. Data for test We are preparing test data like following.以下のようなテスト用の時系列データフレームを用意します。 import pandas as pd from pandas import Series datetime = pd.date_range(start='2021-12-31',end='2022-01-02', freq='30s') df = pd.DataFrame(range(len(datetime)), index=date, columns = ['val']) df.head() df.tail() Method1 : resample The resumple function is actually for downsampling but it’s also useful to aggregate by grouping datetime. You have to remember to set datatime column as index in advance. df['datetime'] = pd.to_datetime(df['datetime']) df.set_index('datetime', inplace=True) And then you set the character which represents year, …

【Python】How to input password in python by getpass

2022/11/03   -Python

Description When you need to input your ID and Password for certification by program, It’s not good idea to write them as plaintexts in your source code because of security reason. It’s safer to let human to input them at each time. In python, you can use input function for it, but there is a problem the password characters you are inpurting is showed at the screen. Alternatively you can use getpass function hide the characters and now we show the way to use it. Example of input function Firstly, we are showing the example of input function. when input …

Deriving Regression coefficient from Residual Sum of Squares

2022/09/04   -Statistics

When Linear Regression equation, \(y=\hat{\alpha} + \hat{\beta} x\), is found from the data, the formula for their coefficients, \(\hat{\alpha}\) and \(\hat{\beta}\), are the followings. $$ \hat{\beta} = r_{xy}\frac{s_{y}}{s_{x}} $$ $$ \hat{\alpha} = \bar{y} – \hat{\beta}\bar{x_i} $$ \(r_{xy} \): correlation coefficient \(s_{x} \): standard deviation of \(x\), \(s_{y} \): standard deviation of \(y\) Here we will explain how to derive these equation from the residual sum of squares. Derivation We will use the following residual sum of regression below. $$ S(\hat{\alpha}, \hat{\beta}) = \sum^{n}_{i=1}(y_i – \hat{y})^2 = \sum^{n}_{i=1}(y_i – (\hat{\alpha} + \hat{\beta} x_i ))^2 $$ To find \(\hat{\alpha}\) and \(\hat{\beta}\) to …

Multiple Regression Analysis by Python statsmodels

2022/09/03   -Python, Statistics

Overview In this article, there is a explanation of Multiple Regression Analysis by using statsmodels in python. We focus not analyzing but understanding how to use this library. Environments Python 3.8.6statsmodels 0.13.2 Preparetion of datase This time we will use Red Wine Quality dataset. This dataset is published as OpenDatabase License in kaggle site. We download it and save the csv file in any directory. Red Wine Quality | Kaggle Installing statsmodels By using pip command, we will install the statsmodels library. pip install statsmodels Loading dataset Next, we will load the dataset you save in any directory by pandas …

How to fix AnimationEvent ‘Hit’ on animation ‘Attack1’ has no receiver! in Unity

2020/09/20   -Unity

Overview When we got free Animation at Unity Asset Store and used it with SimpleAnimation, I encountered following error. AnimationEvent ‘Hit’ on animation ‘Attack1’ has no receiver! Are you missing a component? To come to the point, the error could be fixed by deleting Animation Event from the Inspector. The following shows how to fix it step by step. Environments Windows10Unity 2020.1.f1 When error happened We used two packages, Robot Kyle from the Unity Technologies and WARRIOR PACK BUNDLE 3 FREE Animation from Explosive to control Robot Kyle with attack animation. Robot Kyle https://assetstore.unity.com/packages/3d/characters/robots/space-robot-kyle-4696#reviews WARRIOR PACK BUNDLE 3 FREE Warrior …

【Python】From DataFrame To list type

2020/09/14   -Python

Overview Pandas can get data from a database with read_sql easily.Here we can show how to convert dataframe to list type for only one row from database. Example table in databse a,b,c are columns of this test_table. abc110100220200330300440400test_table Let’s get only “a” column from this table with pandas.These are sample code. import pandas as pd import psycopg2 connection = psycopg2.connect(host=’host’, dbname=’database’, user=’username’, password=’password’) df = pd.read_sql("SELECT a FROM test_table", connection) df.head() Result If you want to convert this result from dataframe to list type, you may think like [1, 2, 3, 4]. There is a simple method to convert dataframe …

【Python】Not getting all rows with BeautifulSoup

2020/09/09   -Python

Overview When Scraping with Beautiful Soup a problem occurred like not getting all rows of the table but a few of them. This example shows how to fix it Environment Python 3.7.3 Problem occurred example This is a example table you want to scrape. NumberName1Sato2Kato3Ito4Goto I saw the html code in a web browser by pushing F12 key. <table class="test_table"> <thead> <tr> <th>Number</th> <th>Name</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Sato</td> </tr> </tbody> <tbody> <tr> <td>2</td> <td>Kato</td> </tr> </tbody> <tbody> <tr> <td>3</td> <td>Ito</td> </tr> </tbody> <tbody> <tr> <td>4</td> <td>Goto</td> </tr> </tbody> </table> When I use the following code to scrape the …

【Unity】The way to fix error CS0619:’GUIText’ is obsolete:’GUIText has been removed. Use UI.Text instead.’

2020/09/06   -Unity

Overview There occured error CS0619:’GUIText’ is obsolete:’GUIText has been removed. Use UI.Text instead.’ to use Standard Assets. This article shows a way to fix it. Environment Unity 2019.4.3f1 Occurences Making C# script from Assets > Create > C# Script . Attaching the script to Sphere object by drag & drop, I get message ‘Can’t add script’ . This massage warns that the name of the script is different from its class name or there are some error of compiling. But I don’t find any error for compiling or the difference of the names. Now, finding these GUIText error in console …

【Unity】Object starts to chase the player approaching

2020/09/02   -Unity

Overview There is a sample the Cube Object starts to chase the player who goes in a certain area around it. Environment Unity 2020 1.1f1Windows10 Picture of implementation Step1 : Set the player Ethan from the Standard Assets can be used as a human object. Flowwing article explains how to set Ethan and move him. 【Unity】Standard Assetsでサクッと人間をキー操作する After place Ethan on Terrian, set the Tag in inspector “Player”. Adding rigidbody and capusule collider is needed. Step:2 Cube Object chasing player Next, Set 3D Object Cube. GameObject > 3D Object Cube Adding Character Controller and Sphere Collider to the Cube Object. …