2024年4月8日月曜日

[Xcode]シミュレーターのソフトキーボードが表示されない「解決策」

Xcode Version:15.3, Simulator Version: 15.3

////  ContentView.swift//  TaxCalculator////  Created by jeff on 2024/04/07.//import SwiftUIstruct ContentView: View {    @State var inputText = ""    @State var Tax8 = 0.0    @State var Tax10 = 0.0    var body: some View {        VStack (spacing:20){            TextField("ここに文字を入力", text: $inputText)                .keyboardType(.numberPad)            Button("計算"){                Tax8 = (Double(inputText) ?? 0) * 0.08                Tax10 = (Double(inputText) ?? 0) * 0.10            }            Text("価格:\(inputText)")            Text("消費税8%:\(Tax8) "  )            Text("消費税10%:\(Tax10)")        }        .padding()    }}#Preview {    ContentView()}

上記Swiftコードの下線部に数字しか入力できないように、iPhoneのソフトキーボードを定義しているにもかかわらず、Xcodeでシミュレーションしたところ、下記のように、Macbook Airのキーボードで数字以外の入力ができます。しかも、ソフトキーボードが表示されません。

Simulator → I/O → Keyboard → Connect Hardware Keyboardが選択されていることは原因です。これを使用していると、パソコンのキーボードと連携しているため、ソフトキーボードが表示されません。

このチェックを外したところ、無事にソフトキーボードが表示され、数字しか入力できないように制限されています。

2024年4月6日土曜日

iPhoneアプリ開発講座(問題③)

////  ContentView.swift//  HelloSwiftUI////  Created by jeff on 2024/04/06.//import SwiftUIstruct ContentView: View {    @State var str = "Hello, SwiftUI"    var body: some View {        VStack {            ZStack{                Rectangle()                    .foregroundColor(.yellow)                    .frame(width:300, height: 300)                VStack{                    HStack{                        Rectangle()                            .foregroundColor(.black)                            .frame(width:60, height: 20)                        ZStack{                            Rectangle()                                .foregroundColor(.gray)                                .frame(width:90, height: 90)                            Rectangle()                                .foregroundColor(.white)                                .frame(width:70, height: 70)                            Rectangle()                                .foregroundColor(.black)                                .frame(width:20, height: 20)                        }                        ZStack{                            Rectangle()                                .foregroundColor(.gray)                                .frame(width:90, height: 90)                            Rectangle()                                .foregroundColor(.white)                                .frame(width:70, height: 70)                            Rectangle()                                .foregroundColor(.black)                                .frame(width:20, height: 20)                        }                        Rectangle()                            .foregroundColor(.black)                            .frame(width:60, height: 20)                    }                    ZStack{                        Rectangle()                            .foregroundColor(.black)                            .frame(width:70, height: 40)                        VStack{                            Rectangle()                                .foregroundColor(.white)                                .frame(width:60, height: 10)                            Rectangle()                                .foregroundColor(.red)                                .frame(width:60, height: 10)                        }                    }                }            }            Rectangle()                .foregroundColor(.blue)                .frame(width:300, height: 100)            HStack{                Rectangle()                    .foregroundColor(.black)                    .frame(width:70, height: 30)                Rectangle()                    .foregroundColor(.black)                    .frame(width:70, height: 30)            }        }    }}#Preview {    ContentView()}

iPhoneアプリ開発講座 by Rikuto Sato

iPhoneアプリ開発勉強SwiftUI (問題①、問題②)

////  ContentView.swift//  HelloSwiftUI////  Created by jeff on 2024/04/06.//import SwiftUIstruct ContentView: View {    @State var str = "Hello, SwiftUI"    var body: some View {        VStack {            Rectangle()                .foregroundColor(.orange)                .frame(width:200, height: 50)            Rectangle()                .foregroundColor(.red)                .frame(width:180, height: 20)            Rectangle()                .foregroundColor(.yellow)                .frame(width:180, height: 20)            Rectangle()                .foregroundColor(.brown)                .frame(width:180, height: 20)            Rectangle()                .foregroundColor(.green)                .frame(width:180, height: 20)            Rectangle()                .foregroundColor(.orange)                .frame(width:200, height: 50)        }        ZStack {            Rectangle()                .foregroundColor(.green)                .frame(width:300, height: 300)            VStack {                HStack{                    Rectangle()                        .foregroundColor(.black)                        .frame(width:70, height: 70)                    Rectangle()                        .foregroundColor(.black)                        .frame(width:70, height: 70)                }                Rectangle()                    .foregroundColor(.black)                    .frame(width:50, height: 20)                Rectangle()                    .foregroundColor(.black)                    .frame(width:100, height: 80)            }        }        .padding()    }}#Preview {    ContentView()}

SwiftUIアプリ開発講座 by RikutoSato

2024年3月26日火曜日

生成AIを使ってのプロジェウト立ち上げをしたい。個人でもやれるプロジェクト は10例をください

AIを使用した個人プロジェクトのアイデアは以下の通りです:

1. **個人化された学習アシスタント**: 個々の学習パターンに基づいて、カスタマイズされた学習経験を提供するアプリケーションを開発します。ユーザーの進捗を追跡し、最適な学習計画や資料を提案します。

2. **アート生成アプリ**: GAN(Generative Adversarial Network)などの技術を使用して、ユーザーが指定したパラメータに基づいて新しいアート作品を生成するアプリケーションを開発します。

3. **自動コーディングアシスタント**: プログラミングの問題解決において、コードの一部を自動生成するツールを作成します。特定のタスクや言語に特化したバージョンを提供できます。

4. **音楽生成アプリ**: ニューラルネットワークを使用して、ユーザーの指示に従って新しい音楽を生成するアプリケーションを開発します。音楽のジャンルや雰囲気を指定できるようにします。

5. **自動テキスト要約ツール**: 文章や記事を入力すると、その要約を生成するツールを開発します。要約は重要な情報を抽出し、原文の要点を簡潔にまとめます。

6. **健康管理アプリ**: ユーザーの健康データを収集し、AIを使用して健康状態を分析し、健康的な生活スタイルや改善点を提案するアプリケーションを作成します。

7. **自動運転シミュレーター**: 自動運転アルゴリズムの開発やテストのためのシミュレーターを構築します。リアルな交通シナリオを提供し、さまざまな状況での自動運転の挙動をテストできます。

8. **言語翻訳アプリ**: 様々な言語間でテキストを自動的に翻訳するアプリケーションを作成します。特に、低リソース言語間の翻訳をサポートすることで、より包括的なアプリを提供できます。

9. **ユーザー行動予測ツール**: ユーザーの過去の行動データを分析し、将来の行動やニーズを予測するツールを開発します。これは、個人に合わせた製品やサービスの提案に役立ちます。

10. **感情分析ツール**: テキストや音声などのデータから感情を抽出するツールを作成します。これにより、ソーシャルメディアの投稿や顧客フィードバックなどから意見や感情の傾向を把握できます。

Here are the translated project ideas into English:

  1. Personalized Learning Assistant: Develop an application that provides customized learning experiences based on individual learning patterns. It tracks user progress and suggests optimal learning plans and resources.
  2. Art Generation App: Develop an application that generates new artworks based on parameters specified by the user using techniques like Generative Adversarial Networks (GANs).
  3. Automatic Coding Assistant: Create a tool that automatically generates parts of code for problem-solving in programming. Versions specialized for specific tasks or languages could be provided.
  4. Music Generation App: Develop an application that uses neural networks to generate new music based on user input, allowing users to specify genres and moods.
  5. Automatic Text Summarization Tool: Create a tool that generates summaries of inputted texts or articles. The summaries extract important information and condense the main points of the original text.
  6. Health Management App: Build an application that collects user health data, analyzes health status using AI, and suggests healthy lifestyle choices and improvements.
  7. Autonomous Driving Simulator: Construct a simulator for the development and testing of autonomous driving algorithms. It provides realistic traffic scenarios for testing autonomous driving behavior in various situations.
  8. Language Translation App: Create an application that automatically translates text between various languages. Particularly, support for translation between low-resource languages could make the app more inclusive.
  9. User Behavior Prediction Tool: Develop a tool that analyzes users’ past behavior data to predict future actions and needs. This aids in providing personalized product or service recommendations.
  10. Sentiment Analysis Tool: Build a tool that extracts emotions from data such as text or speech. This allows understanding opinions and sentiment trends from sources like social media posts or customer feedback.

2023年9月3日日曜日

顧客に優しくないY!mobile(ワイモバイル)

 

 Y!mobileのeSIMを使用しているが、気づいたら電波がなくて、電話もかけれなくなりました。iPhoneのモバイル通信を確認すると、どうもeSIMが消えているようです。

状況確認と修復のために、Y!mobileショップに行きました。着いた時間は19:15でした。状況説明と店員さんの以下になっています。

店員さん:どうされましたか?

私:電波がなく、電話もかけれないです。eSIMが消えているようです。ただし、ちょうどいま電源がなくなり、パワーオフになりました。充電したうえ修復をお願いできますか?

店員さん:店では充電対応できません。スマホをお預かりしません。身分証明書を持ってきましたか?

私:身分証明書を撮った写真を持っていますが、使えますか?

店員さん:写真は使えません。物理的な身分証明書がないと受付できません。今はもう19:15なので、今日は受付できないので、明日また来てください。

私:受付終了時間は19:30と書いてあるが、今すぐに取りに行っても良いですか?

店員さん:19:30に戻れますか?

私:頑張って取ってきます。10分程度で戻ってくるので、先に修復対応をお願いできますか?

店員さん:身分証明書を持ってきてからでないと受付できません。

(走って自宅に戻って身分証明書を取って、店に戻った時、19:32でした。)

私:どうですか?受付してもらえますか?

店員さん:いいえ、いまは19:33なので、本日の受付はすでに終了しました。明日9時以降また来てください。システムがクローズされたので、我々は何もできません。

私:なんで身分証明書をいま取ってくると伝えたにもかかわらず、先に受付してもらえないですか?

店員さん:身分証明書がないと受付できないと法律で決まっています?個人情報保護法で身分証明書がないと、我々があなたの情報にアクセスできないです。

結局、スマホの修復は本日できないままでした。

が、Y!mobileは本当に今日中に修復対応しようと思うなら、対応できないでしょうか?顧客のために真剣に考えてくれているでしょうか?

ーーーーーーーーーーーーーー

今回のY!mobileの対応から、以下のようにいくつか疑問に思っています。

1.なんで営業時間中(受付終了19:30だが、営業時間は21:00)には、システムがクローズを理由に、顧客対応できないでしょうか?何のシステムでしょうか?

2.システムを先にクローズするのは妥当でしょうか?

 受付済みの顧客を営業終了時刻までの1時間30分で対応する想定なら、店舗がガラガラで、顧客がいないとき、皆さんは何をされているでしょうか?

3.そもそもなんで店舗で身分証明書の提出を求められるでしょうか?

 電話をかけて対応してもらうときに、生年月日と電話番号などの情報を伝えれば本人確認できたというが、店舗で電話を掛けるときと同じように、情報を伝えるだけでなんでダメでしょうか?

4.法律的に身分証明書を提出しないと受付できないとの決まりは本当にあるでしょうか?どのように規定されているでしょうか?

5.仮に法律で決められていることは本当にあるとしでしたら、Y!mobileは本当に今回のような状況で、柔軟に対応してもらって、顧客が遭遇する問題の解決を先に優先できないでしょうか?

いろいろと法律規定を分かってない部分もありますが、Y!mobileは顧客に優しくない、真剣に顧客のために考えてくれてないと思っています。

同じようなことに遭遇した方はいらっしゃいますでしょうか?どのように考えられているでしょうか?

2023年8月25日金曜日

ロト7(loto7)予測

機械学習を勉強し始めたばかりで、勉強がてらロト7(loto7)の数字予測プログラム(Python)を作成してみました。もちろん、当たるよという保証もないです。

最初習ったのは、ランダムフォレストモデル(RandomForestRegressor)と決定木モデル(DecisionTreeRegressor)なので、この二つモデルをそのまま適用して、過去の当たり数字を学習したうえ、指定された日付の予測数字を出すというプログラムです。

ここに前提としての考えは、宝くじの出現数字はランダムと言いながら、もしかして日付に関連するじゃないか?という考えが入っています。なので、日付を入力すると、日付をもとに数字を予測した数字を7個出力してくれます。

これのソースをloto7.pyの名前で保存したうえ、「python loto7.py」で実行すれば動きます。(中で使用するデータセットloto7_train.csvは以下の場所からダウンロードしてください。https://loto7.thekyo.jp/download/index)

import pandas as pdimport numpy as npfrom sklearn.metrics import mean_absolute_errorfrom sklearn.model_selection import train_test_splitfrom sklearn.tree import DecisionTreeRegressorfrom sklearn.ensemble import RandomForestRegressor# Path of the file to readloto7_file_path = './input/loto7_train.csv'loto_data = pd.read_csv(loto7_file_path)# Create 7th targets object and call it y1 to y7train_y1 = loto_data.Num1train_y2 = loto_data.Num2train_y3 = loto_data.Num3train_y4 = loto_data.Num4train_y5 = loto_data.Num5train_y6 = loto_data.Num6train_y7 = loto_data.Num7# Create Xloto_data['Date'] = pd.to_datetime(loto_data['Date'])loto_data['LotoYear']=loto_data['Date'].dt.yearloto_data['LotoMonth']=loto_data['Date'].dt.monthloto_data['LotoDay']=loto_data['Date'].dt.dayfeatures = ['LotoYear', 'LotoMonth', 'LotoDay']X = loto_data[features]# Define the model. Set random_state to 1rf_model1 = RandomForestRegressor(random_state=1)rf_model2 = RandomForestRegressor(random_state=1)rf_model3 = RandomForestRegressor(random_state=1)rf_model4 = RandomForestRegressor(random_state=1)rf_model5 = RandomForestRegressor(random_state=1)rf_model6 = RandomForestRegressor(random_state=1)rf_model7 = RandomForestRegressor(random_state=1)# fit the model for 7 targets numberrf_model1.fit(X, train_y1)rf_model2.fit(X, train_y2)rf_model3.fit(X, train_y3)rf_model4.fit(X, train_y4)rf_model5.fit(X, train_y5)rf_model6.fit(X, train_y6)rf_model7.fit(X, train_y7)# path to file you will use for predictionstest_data_path = './loto7_test.csv'# read test data file using pandastest_data = pd.read_csv(test_data_path)# create test_X which comes from test_data but includes only the columns you used for prediction.# The list of columns is stored in a variable called featurestest_data['Date'] = pd.to_datetime(test_data['Date'])test_data['LotoYear']=test_data['Date'].dt.yeartest_data['LotoMonth']=test_data['Date'].dt.monthtest_data['LotoDay']=test_data['Date'].dt.dayfeatures = ['LotoYear', 'LotoMonth', 'LotoDay']test_X = test_data[features]# make predictions which we will submit. num1_preds = rf_model1.predict(test_X)num2_preds = rf_model2.predict(test_X)num3_preds = rf_model3.predict(test_X)num4_preds = rf_model4.predict(test_X)num5_preds = rf_model5.predict(test_X)num6_preds = rf_model6.predict(test_X)num7_preds = rf_model7.predict(test_X)# print(num1_preds,num2_preds,num3_preds,num4_preds,num5_preds,num6_preds,num7_preds)print('---------Random Forest Model----------')print('---------小数点以下切り上げ----------')# 小数点以下切り上げprint(np.ceil(num1_preds))print(np.ceil(num2_preds))print(np.ceil(num3_preds))print(np.ceil(num4_preds))print(np.ceil(num5_preds))print(np.ceil(num6_preds))print(np.ceil(num7_preds))print('---------Decision Tree Model----------')# Define the model. Set random_state to 1dt_model1 = DecisionTreeRegressor(random_state=1)dt_model2 = DecisionTreeRegressor(random_state=1)dt_model3 = DecisionTreeRegressor(random_state=1)dt_model4 = DecisionTreeRegressor(random_state=1)dt_model5 = DecisionTreeRegressor(random_state=1)dt_model6 = DecisionTreeRegressor(random_state=1)dt_model7 = DecisionTreeRegressor(random_state=1)# fit the model for 7 targets numberdt_model1.fit(X, train_y1)dt_model2.fit(X, train_y2)dt_model3.fit(X, train_y3)dt_model4.fit(X, train_y4)dt_model5.fit(X, train_y5)dt_model6.fit(X, train_y6)dt_model7.fit(X, train_y7)# path to file you will use for predictionstest_data_path = './loto7_test.csv'# read test data file using pandastest_data = pd.read_csv(test_data_path)# create test_X which comes from test_data but includes only the columns you used for prediction.# The list of columns is stored in a variable called featurestest_data['Date'] = pd.to_datetime(test_data['Date'])test_data['LotoYear']=test_data['Date'].dt.yeartest_data['LotoMonth']=test_data['Date'].dt.monthtest_data['LotoDay']=test_data['Date'].dt.dayfeatures = ['LotoYear', 'LotoMonth', 'LotoDay']test_X = test_data[features]# make predictions which we will submit. num1_preds = dt_model1.predict(test_X)num2_preds = dt_model2.predict(test_X)num3_preds = dt_model3.predict(test_X)num4_preds = dt_model4.predict(test_X)num5_preds = dt_model5.predict(test_X)num6_preds = dt_model6.predict(test_X)num7_preds = dt_model7.predict(test_X)print('---------小数点以下切り上げ----------')# 小数点以下切り上げprint(np.ceil(num1_preds))print(np.ceil(num2_preds))print(np.ceil(num3_preds))print(np.ceil(num4_preds))print(np.ceil(num5_preds))print(np.ceil(num6_preds))print(np.ceil(num7_preds))

いろいろと意見やアドバイスがあるなら、コメントしてください。

2023年8月12日土曜日

中古本の処分はオークションをかけるか、捨てましょう

 引越しでたくさんの中古本が出てきました。皆さんも似たような方はいらっしゃって、悩みながらネット上で調べたりすると思います。ご参考ください。

 結論からいうと、

 中古本は時間をかけてオークションをかけるか、時間がかかることが嫌ならば、ゴミ収集場にそのまま捨てましょう。

 と言いたいです。

 すこしでもお金になるじゃないかと希望を抱えて、ネット上で調べてみました。その結果、ネット上の紹介だと、1箱程度で査定結果は約5000円ちょっと程度でブックオフからの買取サービスを利用していた方がいらっしゃったそうです。

 迷いながらも、2箱で約100冊の本を段ボールでブックオフに出して、査定してもらいました。自分の2箱本なら1万円程度になるじゃないかという夢も見ていました。理由はその中にフルセットの漫画「おしり探偵」新品購入して状態良好も入っているし、C言語やJava言語、サーバー構築、Oracleデータベース関連、Linuxコマンドなどのぶっ厚いIT技術書(4年ほど前に新品で購入して使っていたものもあります)が入っていました。これだと、1万円ぐらい余裕で売れるじゃないかと考えていました。

 その結果、郵送でブックオフに出して、翌日に査定結果は下記のようにメールで連絡してくれました。えっ?1冊161円なのかな?500円売れる本があってもおかしくないがと疑いながら、値段のつく39冊で合計で161円という笑えない事実でした。詐欺と言いませんが、かなり想定から離れた結果です。そして、査定結果を7段階で評価してくださいと依頼もありましたが、もちろん最低の7で評価しました。かなりショックでした。

——————————————————————-

このたびは、お客様の大切な品物をお送りいただきまして、
誠にありがとうございます。

下記、査定の結果についてご案内いたします。

───────────
【明細】
■書籍→39点/161円
■コミック→0点/0円
■CD→0点/0円
■DVD→0点/0円
■GAME→0点/0円
■その他→0点/0円
■買取専用ダンボール→0点/0円
■合計→39点/161円
■お値段のつかなかった商品→63点
■お送りいただいた箱数→2箱

───────────

以下、7段階の評価より
もっとも当てはまるもののリンクを1回クリックしてください。

◎1.とても満足だった

◎2.満足だった

◎3.どちらかと言えば満足だった

◎4.普通

◎5.どちらかといえば満足ではなかった

◎6.満足ではなかった

◎7.まったく満足ではなかった

——————————————————————-